Opened 18 years ago

Closed 16 years ago

#1104 closed enhancement (fixed)

multi channel audio support

Reported by: Mark Spieth Owned by: danielk
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: medium Keywords: audio
Cc: Ticket locked: no

Description

this ticket is to help me keep patches together for multi channel audio support. this includes analog out and reencoding AC3/DTS back to AC3 digital (no dts encoder) after timestretch. 6 channel or stereo/dolby prologic encoded stereo support support is envisaged.

Attachments (37)

mythtv_ac3.12.patch (75.2 KB) - added by Mark Spieth 18 years ago.
mythtv_ac3.14.patch (76.7 KB) - added by Mark Spieth 18 years ago.
mythtv_ac3.15.patch (87.5 KB) - added by Mark Spieth 18 years ago.
6 ch mmx support
mythtv_ac3.17.patch (91.5 KB) - added by Mark Spieth 18 years ago.
mythtv_ac3.release-19-fixes.patch (110.6 KB) - added by oa@… 18 years ago.
includes merge of 8941 (trunk) in order to apply to release-19-fixes
mythtv_multitimestretch.patch (24.2 KB) - added by Mark Spieth 18 years ago.
mythtv_ac3.18.patch (66.3 KB) - added by makspieth 18 years ago.
mythtv_ac3.19.patch (63.9 KB) - added by Mark Spieth 18 years ago.
includes a small bug fix for encoder not initialized in aob
mythtv_ac3.22.patch (60.1 KB) - added by Mark Spieth 17 years ago.
mythtv_ac3.25.patch (66.8 KB) - added by Mark Spieth 17 years ago.
mythtv_ac3.27.patch (69.0 KB) - added by Mark Spieth 17 years ago.
mythtv_ac3.28.patch (61.4 KB) - added by Mark Spieth 17 years ago.
mythtv_ac3.29.patch (61.9 KB) - added by Mark Spieth 17 years ago.
mythtv_ac3.30.patch (60.0 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.32.patch (57.8 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.33.patch (100.5 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.34.patch (100.8 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.35.patch (105.4 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.36.patch (107.7 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.37.patch (117.6 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.38.patch (122.3 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.39.patch (123.4 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.40.patch (126.5 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.42.patch (124.1 KB) - added by Mark Spieth 16 years ago.
mythtv_mm_mad.1.patch (1.1 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.43.patch (71.1 KB) - added by danielk 16 years ago.
Mark's patch after a bit of code review. I still need to do some testing…
mythtv_ac3.44.patch (59.6 KB) - added by danielk 16 years ago.
Updatd patch
mythtv_ac3.45.patch (63.1 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.46.patch (60.0 KB) - added by Mark Spieth 16 years ago.
mythtv_ac3.47.patch (62.1 KB) - added by Mark Spieth 16 years ago.
same as 46 but formatted to daniels reviewed version
mythtv_ac3.48.patch (70.7 KB) - added by Mark Spieth 16 years ago.
fixed passthru and intrastream channel switch hiccup
ac3enc.patch (723 bytes) - added by cizek@… 16 years ago.
Possible fix for bad re-encoding
mythtv_ac3.49.patch (126.4 KB) - added by Mark Spieth 16 years ago.
support for ffmpeg fft, fix for passthru reenc
mythtv_ac3.50.patch (479 bytes) - added by Mark Spieth 16 years ago.
missed lib dependency
mythtv_ac3.51.patch (3.4 KB) - added by Mark Spieth 16 years ago.
patch for mingw
swab-and-tidy.patch (2.3 KB) - added by anonymous 16 years ago.
mythtv_ac3.52.patch (783 bytes) - added by Mark Spieth 16 years ago.
should fix multichannel timestretch with spdif

Change History (153)

Changed 18 years ago by Mark Spieth

Attachment: mythtv_ac3.12.patch added

Changed 18 years ago by Mark Spieth

Attachment: mythtv_ac3.14.patch added

comment:1 Changed 18 years ago by Mark Spieth

added 14 which fixes

  • ac3 audio amplitude levels are now invariant (encode/decode produces same levels)
  • only allow 2 and 6 channel modes
  • if 6 channel on decode and want 2 then use DOLBY surround encoding
  • decode to and encode from L,R,LS,RS,C,LFE format

Changed 18 years ago by Mark Spieth

Attachment: mythtv_ac3.15.patch added

6 ch mmx support

comment:2 Changed 18 years ago by Mark Spieth

improvements to 15

  • mmx support for 6 channel timestretch.

almost there. just 1 knwon problem to go :)

Changed 18 years ago by Mark Spieth

Attachment: mythtv_ac3.17.patch added

comment:3 Changed 18 years ago by Mark Spieth

No major change but is now .19 compatible (I hope). not enough time at the moment. TODO: audio always convert to 6ch analog if selected. major change. comments to *me* about mythmusic suitability of multichannel audio or if 2 ch is pref. selection of channel mode from menu dts decoder fixup to handle multichannel (currently really hobbled) things I havent thought of

comment:4 Changed 18 years ago by anonymous

Works great, but i had to change the audio-output-device from /dev/dsp to ALSA:plug:surround51:0 to get 5.1 and not only Dolby surround. Finding that out was pretty tricky.

If everybody has to make this setting, a little hint would be good. Perhaps in the Help-Text if you choose "6 Channels".

comment:5 Changed 18 years ago by oa@…

would love to test this out, but having difficulties applying cleanly to the release-19-fixes branch. So many rejects it's hard to patch by hand without knowing the code better.

Changed 18 years ago by oa@…

includes merge of 8941 (trunk) in order to apply to release-19-fixes

comment:6 Changed 18 years ago by oa@…

Perhaps it's due to me applying this to release-19-fixes, but I'm experiencing freezes in mythfrontend with some recordings. A couple do work, but with most the frontend freezes up completely even while previewing...

Changed 18 years ago by Mark Spieth

comment:7 Changed 18 years ago by Mark Spieth

broke out multichannel libmythsoundtouch patch for commit if noone has anything bad to say about it. seems ok to me and Ive been using it in 2ch mode for a while.

comment:8 Changed 18 years ago by Mark Spieth

Owner: changed from Mark Spieth to Isaac Richards

comment:9 Changed 18 years ago by danielk

Milestone: unknown0.20
Owner: changed from Isaac Richards to danielk

I'll have a look at this.

comment:10 Changed 18 years ago by danielk

(In [9996]) Refs #1104. SoundTouch? resync.

Syncs to 1.31.

I didn't take the MMX changes because our MMX code is faster and more versatile. I also didn't take the SSE & the windows specific changes, we don't use the floating point sample code, and don't have a functioning windows port to test the changes with.

comment:11 Changed 18 years ago by danielk

(In [9998]) Refs #1104. Apply soundtouch portion of multi channel audio support.

You need to use different calls to use this code, so just changing the audio channel define in AvFormatDecoder? will not enable this. I haven't made the call changes because the MMX optimized version of one of the multi-channel soundtouch functions is not complete.

But you can test this using the mythtv_ac3.17.patch on the #1104 ticket.

The changes are not extensive. The buffer needs to be be bigger to fit the extra audio channels, and the audio processing functions need to use a bigger stride.

comment:12 Changed 18 years ago by danielk

Owner: changed from danielk to Mark Spieth

comment:13 Changed 18 years ago by danielk

(In [10003]) Refs #1104. Removes a SoundTouch? 1.3.1 change that induces clipping.

This restores the 1.3.0 behavior of passing 1.0 timestretch samples through putSamples() unmolested. The 1.3.1 version treats 1.0 as a special case of slowdown, where the slowdown is 0%. But this causes clipping for Cougar when MMX is enabled.

The clipping is probably dependent on source volume since no one else has reported it, but it's a regression and we don't experience the problem that the SoundTouch? 1.3.1 is trying to avoid because we don't use the features of SoundTouch? which trigger the problem.

Changed 18 years ago by makspieth

Attachment: mythtv_ac3.18.patch added

comment:14 Changed 18 years ago by Mark Spieth

Owner: changed from Mark Spieth to danielk

added patch to latest interface changes given that I cant figure out a better/nicer way to do this, its ready for commit. not there are a couple of other fixes which while not directly applicable I feel are important.

  1. long long audio timecode rep. in audiooutputbase
  2. extra debugging, debug changes mostly to include VB_TIMESTAMP
  3. avf has a reseek to 0 after estimatetimings as it causes the first frame to be displayed as the 2nd keyframe. line 850
  4. a couple of avsync tweeks in nvp.cpp lines 2163, 2199
  5. AUTORESYNC off as it doesnt help. line 3476

include these at your discretion. 3 may cause slower startup. If you want a cleanup of these and other #if 0 in the code let me know.

comment:15 Changed 18 years ago by danielk

Owner: changed from danielk to Isaac Richards

This is more in Issac's area of expertise than mine.

Changed 18 years ago by Mark Spieth

Attachment: mythtv_ac3.19.patch added

includes a small bug fix for encoder not initialized in aob

comment:16 Changed 18 years ago by danielk

Milestone: 0.200.21

too late to make such a big change before 0.20...

comment:17 Changed 18 years ago by lueddich@…

Hi,

i tried your patch yesterday and have the problem, that the center-sound is on the surround-left speaker. I use a Pundit-R with an ATI IXP chipset and atiixp-ALSA-module (release 1.0.12rc2)... Is there any more information I could give to you? Which way do you want infos? Here or in the dev-maillist?

-Jan

comment:18 Changed 18 years ago by l-case@…

i get a compile error with this patch actual svn and gcc 4.1 audiooutputbase.cpp:38: error: extra qualification ‘DigitalEncoder::’ on member ‘Init’

comment:19 in reply to:  description Changed 18 years ago by anonymous

Replying to Mark Spieth:

this ticket is to help me keep patches together for multi channel audio support. this includes analog out and reencoding AC3/DTS back to AC3 digital (no dts encoder) after timestretch. 6 channel or stereo/dolby prologic encoded stereo support support is envisaged.

Work fine for me / With Ati RADEON X200 Chipset (Ali sound).

comment:20 in reply to:  17 Changed 18 years ago by anonymous

Replying to lueddich@gmx.de:

i tried your patch yesterday and have the problem, that the center-sound is on the surround-left speaker. I use a Pundit-R with an ATI IXP chipset and atiixp-ALSA-module (release 1.0.12rc2)... Is there any more information I could give to you? Which way do you want infos? Here or in the dev-maillist?

Have you confirmed that channels are mapped correctly with other ALSA apps, such as speaker-test? I have VIA onboard sound on my motherboard and the default ALSA configuration for that device swaps the surround and center/LFE jacks. To fix it, I just swap the plugs.

comment:21 Changed 18 years ago by jonner@…

I am using mythtv_ac3.19.patch with SVN and ATSC recordings. It works fine for both stereo (2 channel) and 5.1 (6 channel) AC3 streams. However, on certain shows and movies, mythfrontend seems to think that there are 5 channels in the AC3 stream. When playing these, the audio is extremely distorted. The pitch of the voices sounds much too low and there's a constant high-frequency noise. I suspect that the audio is actually 6 channels, but that mythfrontend is misinterpreting something. Mplayer reports that the same streams are 6 channel and has no problem playing the files.

comment:22 Changed 18 years ago by jmd

Patch didn't compile with current svn (0.20 version)

comment:23 Changed 18 years ago by oa@…

Patch does compile for me with 0.20-fixes and works, BUT the channel assignment for Dolby 5.1 is different from what MPlayer does. Using the "Elephants Dream" movie as a test case, the MPlayer positions the channels correctly, but MythTV plays the center channel from the left rear speaker, etc. I don't have a nice test video clip that would help name each channel correctly, otherwise I'd send a full list of how the channels end up.

comment:24 Changed 18 years ago by jmd

Strange !! for me when it compil the channels assignement was good in mythtv and not in MPLAYER ??

comment:25 in reply to:  24 Changed 18 years ago by sphery <mtdean@…>

Replying to jmd:

Strange !! for me when it compil the channels assignement was good in mythtv and not in MPLAYER ??

Please see the entire thread starting at http://www.gossamer-threads.com/lists/mythtv/dev/218017#218017 and please (everyone) use--and search--the lists (-dev or -users) for discussion.

comment:26 Changed 17 years ago by anonymous

is this patch will apply cleanly on svn version?

comment:27 in reply to:  23 Changed 17 years ago by anonymous

For the record (since I complained about channel arrangement in my earlier comment), my setup is now perfectly functional since I stopped using ALSA:surround51 as my device with the patch and instead use ALSA:nforce. Similarly I use that same device for output in MPlayer, Xine and Totem as well, and all assign the channels the same way. So it was the ALSA surround51 config that mixed the channels for me.

comment:28 in reply to:  18 ; Changed 17 years ago by anonymous

Replying to l-case@gmx.net:

i get a compile error with this patch actual svn and gcc 4.1 audiooutputbase.cpp:38: error: extra qualification ‘DigitalEncoder::’ on member ‘Init’

I'm getting the same error. I tried it with two versions of myth. First was 0.20, and just now mythtv-0.20-svn20061209 (from debian's unstable branch). For those familiar with debian, I'm using "apt-get build-dep mythtv", then "apt-get source mythtv". It's downloaded and unpacked. I then go to that directory and "patch -p0 < mythtv_ac3.19.patch". I get one one error about one hunk; can't remember exact one. I then "debian/rules install". Then I get the above error listed by the previous user. Seems I may be missing a lib or something??? Any help is appreciate.

comment:29 in reply to:  28 Changed 17 years ago by anonymous

Replying to anonymous:

Replying to l-case@gmx.net:

i get a compile error with this patch actual svn and gcc 4.1 audiooutputbase.cpp:38: error: extra qualification ‘DigitalEncoder::’ on member ‘Init’

I'm getting the same error. I tried it with two versions of myth. First was 0.20, and just now mythtv-0.20-svn20061209 (from debian's unstable branch). For those familiar with debian, I'm using "apt-get build-dep mythtv", then "apt-get source mythtv". It's downloaded and unpacked. I then go to that directory and "patch -p0 < mythtv_ac3.19.patch". I get one one error about one hunk; can't remember exact one. I then "debian/rules install". Then I get the above error listed by the previous user. Seems I may be missing a lib or something??? Any help is appreciate.

Okay, here's the problem/solution to this error. Apparently gcc 4.1 now throws errors at extra qualifications, which is when "a declaration within a class explicitly puts the class name before the declaration". In line 38 of outputaudiobase.cpp change " bool DigitalEncoder::Init(CodecID codec_id, int bitrate, int samplerate, int channels);" to " bool Init(CodecID codec_id, int bitrate, int samplerate, int channels);"

It then should compile with myth 0.20

Changed 17 years ago by Mark Spieth

Attachment: mythtv_ac3.22.patch added

comment:30 Changed 17 years ago by Mark Spieth

I have added a cleaned up patch which only includes multi channel audio stuff. there is a new config method for those with analog 6 channel output with no surround amp attached. for the sound output device set AudioOutputDevice? (in FE setup) to ALSA:ch51dup|surround51

in ~mythtv/.asoundrc (or whatever) add

pcm.ch51dup {

type route slave.pcm surround51 slave.channels 6 ttable.0.0 1 ttable.1.1 1 ttable.0.2 1 ttable.1.2 -1 ttable.0.3 1 ttable.1.3 -1 ttable.0.4 0.5 ttable.1.4 0.5 ttable.0.5 0.5 ttable.1.5 0.5

}

this does simple passive prologic dematrixing to 6 channels. the best I can do until someone writes a proper prologic decoder plugin for alsa. sounds good though.

I believe this is ready for commit. sorry for taking so long

comment:31 Changed 17 years ago by Geoffrey Hausheer

I've been playing with this, and it seems to work pretty well, however I have a similar problem of channel mapping being off compared to mplayer/speaker-test. The problem seems to be that a52dec.c decodes ac3 channels as 0->0, 1->1, 2->2 etc, whereas the correct order for alsa (as used by liba52) is 0->1, 1->2,...5->0 (at least for 5.1 audio) I found this patch concerning the difference:

http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2003-September/028756.html

Which was posted over 3 years ago, and is quite nasty, but seems to work well.

Alternatively, I tried mapping the channels in asoundrc using a route, but myth doesn't seem to like using custom pcm routes for 6channel audio (I get lots of:

NVP::AddAudioData():p1: Audio buffer overflow, audio data lost!

even though the ch51dup pcm route works fine

Other additions that would be nice include: supporting different alsa devices for a given number of channels so 4.0, 4.1, and 5.1 audio all work properly

Ability to tie multiple volume controls together (at least on my card I need to control both 'Master' and 'Master Surround' to keep volume balanced.

I'll post some patches for these features if anyone's interested.

comment:32 Changed 17 years ago by anonymous

Here is the mapping I had to use to get the proper channels

pcm.myth51 {
 type route
 slave.pcm surround51
 slave.channels 6
 ttable.0.1 1
 ttable.1.2 1
 ttable.2.4 1
 ttable.3.3 1
 ttable.4.0 1
 ttable.5.5 1
}

Changed 17 years ago by Mark Spieth

Attachment: mythtv_ac3.25.patch added

comment:33 Changed 17 years ago by Mark Spieth

Ive updated the ac3 multichannel patch to work with the latest ffmpeg update you need the external liba52 library installed from your favorite repository. configure with --enable-liba52bin --enable-liba52 --disable-decoder=ac3 --enable-decoder=liba52 so that ac3 works correctly (may not be needed in the future) works ok for me

comment:34 Changed 17 years ago by anonymous

The patch breaks mythtv-0-20-fixes-20070920 audiooutputbase.cpp and avformatdecoder.cpp.

comment:35 Changed 17 years ago by Mark Spieth

update for current HEAD r14586 works with both internal ac3dec and a52dec. channel ordering is L C R SL SR LFE for both ac3dec and a52dec modes. (LFE since internal AC3 is last not first)

my .asoundrc for 2ch upmix (passive matrix) and 6ch straight though AudioOutputDevice? in setup is ALSA:ch51dup|surround51m works for a 6ch PC speaker setup.

pcm.ch51dup {
        type route
        slave.pcm surround51
        slave.channels 6
        ttable.0.0 1
        ttable.1.1 1
        ttable.0.2 1
        ttable.1.2 -1
        ttable.0.3 1
        ttable.1.3 -1
        ttable.0.4 0.5
        ttable.1.4 0.5
        ttable.0.5 0.5
        ttable.1.5 0.5
}

pcm.surround51m {
        type route
        slave.pcm surround51
        slave.channels 6
        ttable.0.0 1
        ttable.2.1 1
        ttable.3.2 1
        ttable.4.3 1
        ttable.1.4 1
        ttable.5.5 1
}

Changed 17 years ago by Mark Spieth

Attachment: mythtv_ac3.27.patch added

Changed 17 years ago by Mark Spieth

Attachment: mythtv_ac3.28.patch added

comment:36 Changed 17 years ago by Mark Spieth

28 removes some unrelated guff from the patch.

comment:37 Changed 17 years ago by Tyson Harding <tharding@…>

I am trying to use this latest patch (myth_ac3.28.patch) I am unable to compile, it fails with an "undefined reference to 'ac3_sync'" error. Here is the final few lines of the failed compile.

ccache g++  -o mythtv main.o    -L/usr/share/qt3/lib -L../../libs/libmyth -L../../libs/libmythtv -L../../libs/libavutil -L../../libs/libavcodec -L../../libs/libavformat -L../../libs/libmythfreemheg -L../../libs/libmythui -L../../libs/libmythupnp -L../../libs/libmythlivemedia -lmythtv-0.20 -lmythavformat-0.20 -lmythavutil-0.20 -lmythavcodec-0.20 -lmythfreemheg-0.20 -lmythupnp-0.20 -lmythlivemedia-0.20 -lmyth-0.20 -lmythui-0.20 -lfreetype -lz -lmp3lame -lasound -L/usr/X11R6/lib -lXinerama -lXv -lXxf86vm -lXrandr -lXvMCW -lXvMC -lqt-mt -lGLU -lGL -lXmu -lXext -lX11 -lm -lpthread
../../libs/libmyth/libmyth-0.20.so: undefined reference to `ac3_sync'
collect2: ld returned 1 exit status
make[2]: *** [mythtv] Error 1
make[2]: Leaving directory `/usr/src/mythtv/mythtv/programs/mythtv'
make[1]: *** [sub-mythtv] Error 2
make[1]: Leaving directory `/usr/src/mythtv/mythtv/programs'
make: *** [sub-programs] Error 2

I have tried this patch with a fresh checkout of r14586 and this is the error I get.

Here is the output of configure

configure --prefix=/usr --enable-proc-opt
# Basic Settings
Compile type     release
Compiler cache   yes
DistCC           no
Install prefix   /usr
CPU              x86_32 (model name     : Intel(R) Pentium(R) 4 CPU 2.20GHz)
big-endian       no
MMX enabled      yes
CMOV enabled     yes
CMOV is fast     no

# Input Support
Joystick menu    yes
lirc support     yes
Apple Remote     no
Video4Linux sup. yes
ivtv support     yes
FireWire support no
DVB support      yes [/usr/include]
DBox2 support    yes
HDHomeRun sup.   yes
IPTV support     yes

# Sound Output Support
OSS support      yes
ALSA support     yes
aRts support     no
JACK support     no
DTS passthrough  no

# Video Output Support
x11 support      yes
xrandr support   yes
xv support       yes
XvMC support     yes
XvMC VLD support yes
XvMC pro support no
XvMC OpenGL sup. no
XvMC libs        -lXvMCW
OpenGL video     no
Mac acceleration no
OpenGL vsync     no
DirectFB         no

# Misc Features
Frontend         yes
Backend          yes

# Bindings
bindings_perl    yes

Creating libs/libmyth/mythconfig.h and libs/libmyth/mythconfig.mak

WARNING: When using --enable-proc-opt you must include the
         output of ./configure along with any bug report.

If you need any more information about the system I would be happy to provide it.

comment:38 Changed 17 years ago by paul@…

I'm seeing the same error as above - with an SVN checkout from this morning [14616] patched with patchset 28.

I've ensured liba52 is installed and I've done a make distclean and reconfigured with the configure options above.

make[2]: Entering directory `/home/mythtv/svnnew/mythtv/programs/mythtv' distcc g++ -o mythtv main.o -L/usr/qt/3/lib -L../../libs/libmyth -L../../lib s/libmythtv -L../../libs/libavutil -L../../libs/libavcodec -L../../libs/libavfor mat -L../../libs/libmythfreemheg -L../../libs/libmythui -L../../libs/libmythupnp -L../../libs/libmythlivemedia -lmythtv-0.20 -lmythavformat-0.20 -lmythavutil-0. 20 -lmythavcodec-0.20 -lmythfreemheg-0.20 -lmythupnp-0.20 -lmythlivemedia-0.20 - lmyth-0.20 -lmythui-0.20 -lfreetype -lz -lmp3lame -lasound -L/usr/X11R6/lib -lXi nerama -lXv -lXxf86vm -lXrandr -lXvMCNVIDIA -lXvMC -lqt-mt -lGLU -lGL -lXmu -lXe xt -lX11 -lm -lpthread make[2]: Entering directory `/home/mythtv/svnnew/mythtv/programs/mythfrontend' distcc g++ -o mythfrontend version.o main.o manualbox.o playbackbox.o viewsched uled.o globalsettings.o manualschedule.o programrecpriority.o channelrecpriority .o statusbox.o networkcontrol.o mediarenderer.o masterselection.o custompriority .o moc_manualbox.o moc_playbackbox.o moc_viewscheduled.o moc_globalsettings.o mo c_manualschedule.o moc_programrecpriority.o moc_channelrecpriority.o moc_statusb ox.o moc_networkcontrol.o moc_custompriority.o moc_masterselection.o -L/usr/qt /3/lib -L../../libs/libmyth -L../../libs/libmythtv -L../../libs/libavutil -L../. ./libs/libavcodec -L../../libs/libavformat -L../../libs/libmythfreemheg -L../../ libs/libmythui -L../../libs/libmythupnp -L../../libs/libmythlivemedia -lmythtv-0 .20 -lmythavformat-0.20 -lmythavutil-0.20 -lmythavcodec-0.20 -lmythfreemheg-0.20 -lmythupnp-0.20 -lmythlivemedia-0.20 -lmyth-0.20 -lmythui-0.20 -lfreetype -lz - lmp3lame -lasound -L/usr/X11R6/lib -lXinerama -lXv -lXxf86vm -lXrandr -lXvMCNVID IA -lXvMC -lqt-mt -lGLU -lGL -lXmu -lXext -lX11 -lm -lpthread ../../libs/libmyth/libmyth-0.20.so: undefined reference to `ac3_sync' ../../libs/libavcodec/libmythavcodec-0.20.so: undefined reference to `ac3_decode r'

comment:39 Changed 17 years ago by paul@…

Since the above, I've tested a recompile with "--disable-liba52 --enable-decoder=ac3 --disable-decoder=liba52" as well as with the inverse - both result in the same error.

In my SVN tree, only parser.c has any reference to ac3_decoder, and the downloaded liba52 tree doesn't have a mention of it in any file.

I'm, clearly, not very good at programming, so I'm a bit stuck with this...

FFMpeg's current SVN tree does, however, have an ac3_parser.c/h and that includes reference to the ac3_sync.

(diskless) myth ffmpeg # less ./libavcodec/ac3_parser.c |grep ac3_sync static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,

s->sync = ac3_sync;

Hope this helps someone work out the issue! :-)

Changed 17 years ago by Mark Spieth

Attachment: mythtv_ac3.29.patch added

comment:40 Changed 17 years ago by Mark Spieth

looks like parser.c change to remove the static wasnt added. patchset 29 fixes this.

comment:41 Changed 17 years ago by paul@…

Thanks Mark, that's fixed compilation for me. Cheers! PC

comment:42 Changed 17 years ago by anonymous

I've just tried using the feature, by changing my alsa output device to the "ALSA:<usual-one>|surround51m" as mentioned above. I've created the surround51m device in my asound.conf, and confimed it works via aplay - it also looks to use the same routing as my normal one. I usually use one I've called softvol, which is a software scaling PCM slaved to fakerear, which is an upmixer slaved to sblive-audio.

Anyhow, that makes my output device line: ALSA:softvol|surround51m - which results in no audio at all. With logging at important,general,audio - I get:

2007-10-07 23:06:41.374 AFD: Setting maxchannels to 2, -1 2007-10-07 23:06:41.374 AFD: Audio Track #1 is A/V stream #1 and has 2 channels in the English language(6647399). 2007-10-07 23:06:41.374 AFD: Setting maxchannels to 2, -1 2007-10-07 23:06:41.374 AFD: Audio Track #2 is A/V stream #2 and has 1 channels in the English language(6647399). 2007-10-07 23:06:41.471 AFD: Trying to select audio track (w/lang) 2007-10-07 23:06:41.471 AFD: Trying to select audio track (wo/lang) 2007-10-07 23:06:41.471 AFD: Selected track 1: English MP2 2ch (A/V Stream #1) 2007-10-07 23:06:41.471 AFD: Initializing audio parms from audio track #1 2007-10-07 23:06:41.471 AFD: Audio format changed

from id(NONE) -1Hz -1ch 0bps ; id(NONE) -1Hz -1ch 0bps to id( MP3) 48000Hz 2ch 16bps ; id( MP3) 48000Hz 2ch 16bps

2007-10-07 23:06:41.474 No useable audio output driver found. 2007-10-07 23:06:41.474 Don't disable OSS support unless you're not running on Linux. 2007-10-07 23:06:41.474 NVP: Disabling Audio, reason is: Unable to create AudioOutput?.

[From live TV].

comment:43 Changed 17 years ago by paul@…

Sorry, the last post was me too! [paul@…].

Anyhow, I've spotted why the above didn't work. When I enter that into the settings page, if I key down-arrow to move down to "Next>" en route to "Finish", it clears the box. If I arrow-up, it leaves it in place but when I return to that settings page later, it's gone and is blank.

Having just changed to back to ALSA:softvol, arrow-down works properly and doesn't delete the field. If I then change that to ALSA:softvol|surround51m, arrow-down reverts that to ALSA:softvol.

Does this look like a validation problem in the field handling for that settings page?

If you point me in the right direction, I can possibly sort it?

Ta, PC

comment:44 Changed 17 years ago by paul@…

In the mean time I've tried setting the database field to the "ALSA:softvol|surround51m" value and although my upmixed audio works as usual, trying a DVD with the internal player appears to use 'softvol' rather than the 5.1 PCM...

That's what it 'sounds' like in any case, and I'm guessing that the 'channels=2' in the setparameters line at the bottom of the following log confirms that?

Interesting it doesn't report the audio device it's trying to open - that would be useful - is that debug line enabled by a different -v flag?

Ta, PC

2007-10-07 23:25:01.247 AFD: Warning, video codec 0x877fdb0 id(MPEG2VIDEO) type (Video) already open. 2007-10-07 23:25:01.708 AFD: Setting maxchannels to 2, -1 No accelerated IMDCT transform found 2007-10-07 23:25:01.709 AFD: Audio Track #1 is A/V stream #1 and has 0 channels in the Unknown language(0). 2007-10-07 23:25:01.722 AFD: Selected track 1: English (A/V Stream #1) 2007-10-07 23:25:01.766 AFD: Warning, video codec 0x877fdb0 id(MPEG2VIDEO) type (Video) already open. 2007-10-07 23:25:02.094 AFD: Setting maxchannels to 2, -1 No accelerated IMDCT transform found 2007-10-07 23:25:02.095 AFD: Audio Track #1 is A/V stream #1 and has 0 channels in the Unknown language(0). 2007-10-07 23:25:02.112 AFD: Selected track 1: English AC3 5.1ch (A/V Stream #1) 2007-10-07 23:25:02.113 AFD: Initializing audio parms from audio track #1 2007-10-07 23:25:02.113 AFD: Audio format changed

from id(NONE) -1Hz -1ch 0bps ; id(NONE) -1Hz -1ch 0bps to id( AC3) 48000Hz 6ch 16bps ; id( AC3) 48000Hz 2ch 16bps

2007-10-07 23:25:02.119 AO: Killing AudioOutputDSP 2007-10-07 23:25:02.389 in SetParameters?(format=2, channels=2, rate=48000, buffer_time=100000, period_time=25000)

comment:45 Changed 17 years ago by paul@…

Right, it seems [and it didn't use to be like this!] that if I list my -v flags as general,important,audio I only get important and audio. Putting the general at the end means I get the "VERBOSE(VB_GENERAL, QString("Opening ALSA audio device '%1'.") .arg(real_device));" from audiooutputalsa.cpp.

This results in the following, which seems to show it opening the surround device, then opening the softvol. Odd!

I'm guessing that audio_channels holds the target stream's number of channels which should be 6 in this case. In which case, the real_device.mid(index+1) should return the surround51m. This doesn't seem to be the case though, as the "Opening Audio device" line shows the combined entry.

Does this mean that whatever decides whether a device is ALSA or not is deciding that the combined device name of ALSA:softvol|surround51 isn't actually an ALSA device?

2007-10-07 23:38:17.349 AFD: Opened codec 0x83d98f0, id(AC3) type(Audio) 2007-10-07 23:38:17.349 AFD: Audio Track #3 is A/V stream #3 and has 0 channels in the Unknown language(0). 2007-10-07 23:38:17.349 AFD: Initializing audio parms from audio track #1 2007-10-07 23:38:17.349 AFD: Audio format changed

from id( AC3) 0Hz 0ch 0bps ; id( AC3) 0Hz 0ch 0bps to id( AC3) 48000Hz 6ch 16bps ; id( AC3) 48000Hz 2ch 16bps

2007-10-07 23:38:17.352 AO: Killing AudioOutputDSP 2007-10-07 23:38:17.352 Opening audio device 'softvol|surround51m'. ch 2 sr 48000 2007-10-07 23:38:17.352 Opening ALSA audio device 'softvol'. 2007-10-07 23:38:17.370 in SetParameters?(format=2, channels=2, rate=48000, buffer_time=100000, period_time=25000)

comment:46 Changed 17 years ago by paul@…

The next slightly odd thing, to my useless coding mind, is this:

VERBOSE(VB_GENERAL, QString("Opening audio device '%1'. ch %2 sr %3")

.arg(audio_main_device).arg(audio_channels).arg(audio_samplerate));

Actually do the device specific open call if (OpenDevice()) {

VERBOSE(VB_AUDIO, LOC_ERR + "Aborting reconfigure"); pthread_mutex_unlock(&avsync_lock); pthread_mutex_unlock(&audio_buflock); if (GetError?().isEmpty())

Error("Aborting reconfigure");

VERBOSE(VB_AUDIO, "Aborting reconfigure"); return;

}

SyncVolume?();

VERBOSE(VB_AUDIO, LOC + QString("Audio fragment size: %1")

.arg(fragment_size));

I see the first verbose log call as it claims to be trying to open the "ALSA:softvol|surround51m" device.

I don't see either of the "Aborting reconfigure" or the "Audio fragment" log messages - at all, as you can see from the above log.

I've checked back, and on previous SVN [from March], unpatched for multi-channel, I do get the fragment messages.

It looks like the call to open the device is getting lost somewhere - althought that doesn't explain why I don't get the first Aborting reconfigure message.

I think I've probably got to the limit of my usefulness now!

Any ideas?

PC

comment:47 Changed 17 years ago by paul@…

Hmm, I've added some debugging messages to the various OpenDevice? instances to see if the above segment of code is dying somewhere whilst checking whether the device is already open. You can see from the below, that it does actually get inside the ALSA-specific OpenDevice? instance.

[insert 10 min delay here...]

Right, after adding some extra debugging [badly], it appears that when finally deciding what to open, the number of channels is still set to 2, rather than the 6 which is indicated by the AC3 stream. See below!

2007-10-08 00:50:31.010 AFD: Audio format changed

from id( AC3) 0Hz 0ch 0bps ; id( AC3) 0Hz 0ch 0bps to id( AC3) 48000Hz 6ch 16bps ; id( AC3) 48000Hz 2ch 16bps

2007-10-08 00:50:31.013 AO: Killing AudioOutputDSP 2007-10-08 00:50:31.013 Opening audio device 'softvol|surround51m'. ch 2 sr 48000 2007-10-08 00:50:31.013 Inside ALSA:OpenDevice QString::arg(): Argument missing: Audio channels is two, so should open primary upmixer! Audio channels=, 2 2007-10-08 00:50:31.013 Audio channels is two, so should open primary upmixer! Audio channels= 2007-10-08 00:50:31.013 Opening ALSA audio device 'softvol'.

comment:48 Changed 17 years ago by paul@…

I've given up, my Myth knowledge just isn't up to working out where the quantity of channels comes from and why it isn't the same as the number in the selected stream!

I changed MAXCHANNELSELECT from 1 to 0 in the following, to see if that made a difference, but to no avail...

/* Changing this next line inserted by me */ / Set to zero to allow any number of AC3 channels. */ #define MAXCHANNELSELECT 0 #if MAXCHANNELSELECT #define MAX_OUTPUT_CHANNELS compiler error #else #define MAX_OUTPUT_CHANNELS 2 #endif

The only odd thing I note is that after the log segment shown above, where the AC3 is showing as 6 channels - I get the following, very late on. There is *no* mention of any 'opening device' or similar, after this, presumably because the device is already open? In any case, it's odd, but it doesn't seem to be related.

2007-10-08 01:19:48.332 Audio Codec Used: not set 2007-10-08 01:19:48.332 AO: Ending reconfigure 2007-10-08 01:19:48.332 NVP: Enabling Audio 2007-10-08 01:19:48.332 AFD: Audio stream type changed. 2007-10-08 01:19:48.346 AFD: Trying to reselect audio track 2007-10-08 01:19:48.346 AFD: Selected track 1: English AC3 5.1ch (A/V Stream #2) 2007-10-08 01:19:48.346 AFD: Initializing audio parms from audio track #1 2007-10-08 01:19:48.346 AFD: Audio format changed

from id( AC3) 48000Hz 6ch 16bps ; id( AC3) 48000Hz 2ch 16bps to id( AC3) 48000Hz 2ch 16bps ; id( AC3) 48000Hz 2ch 16bps

2007-10-08 01:19:48.347 AO: SetEffDsp?: 4800000 2007-10-08 01:19:48.376 AO: kickoffOutputAudioLoop: pid = 8150 2007-10-08 01:19:48.376 AO: OutputAudioLoop?: Play Event

comment:49 Changed 17 years ago by Tyson Harding <tharding@…>

I got this all working using patch 29, and a small change.

I couldn't get this to play DVDs with "Extra Audio Buffering" enabled. Six channel audio would not work, the frontend would get stuck in a loop with a black screen. The logs showed

[ac3 @ 0xb7330ba8] buffer 192000 too small

printed repeatedly and the frontend would not respond. I was able to fix the problem by either turning off "Extra Audio Buffering", or changing the AVCODEC_MAX_AUDIO_FRAME_SIZE value from 192000 to 384000, so now avcodec.h has

#define AVCODEC_MAX_AUDIO_FRAME_SIZE 384000 // 2 second of 48khz 32bit audio

This seems to make sense since six audio channels will require more buffer space than two. The fix works, but I don't know what other impacts this change has.

Thanks for a great patch.

comment:50 Changed 16 years ago by derliebegott@…

FYI: The patch 29 does not work anymore with latest MythTv? from SVN.

comment:51 Changed 16 years ago by FuzzyWuzzy

Can anyone else confirm that patches >25 won't compile against the snapshot in the Mythbuntu packages (mythtv-common 0.20.2-0ubuntu10)

comment:52 in reply to:  50 Changed 16 years ago by anonymous

Replying to derliebegott@gmail.com:

FYI: The patch 29 does not work anymore with latest MythTv? from SVN.

patch applied without a problem to 0.21 from svn. I was able to get everything working perfectly using the .asoundrc from markspieth. Thanks a lot. This is great.

Christoph

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.30.patch added

comment:53 Changed 16 years ago by Mark Spieth

updated patch to apply with latest avcodec sync. untested for liba52 but should work.

comment:54 Changed 16 years ago by anonymous

I am using markspieth's .asoundrc file, and it is working great.

But I have two problems:

  1. Sound in MythMusic "crackles" a little bit. Changing volume does not help.
  1. If the volume of PCM (I have no Master) is on 0 (zero), I can still hear some sound on the speakers. Sound is gone only if I mute it directly in alsamixer. MythTv?'s muting does not actually mute the sound, but it sets it to zero.

I have no Master in alsamixer, and I thought about putting a softvol device called Master, to be able to use it in MythTv?. I used this code, but it does not work:

pcm.!default {

type softvol slave.pcm "ch51dup" control {

name "Master" card 0

}

}

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.32.patch added

comment:55 Changed 16 years ago by Mark Spieth

update with cleaned up code agains HEAD. hopefully this can get committed. if not can a dev provide a detailed reason why.

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.33.patch added

comment:56 Changed 16 years ago by Mark Spieth

I have just added 33 which uses freesound upmixing and no longer requires the .asound devices.

To use set the device to

ALSA:surround51

output will always be in 5.1 in the format L R LS RS C LFE

initial testing shows that it sounds really good for 2ch upmixed videos with good separation. 6ch audio is reordered so that it conforms with the output device format. 4ch audio currently not supported but mono is.

music and phone is handled with wider centre width and phasemode.

down side is that it depends on libfftw3f but mythmusic already uses this. This can be changed later if desired to use fft lib from avcodec.

comment:57 Changed 16 years ago by anonymous

I just compiled revision 15184 with mythtv_ac3.33.patch applied. I needed to remove the line

#include "systems.h"

from freesurround.h because the headerfile could not be found on my system (and seems not to be needed anyway).

Otherwise it compiles and works fine with me. Output is aligned correctly. Thanks a lot mark.

Christoph

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.34.patch added

comment:58 Changed 16 years ago by Mark Spieth

update which fixes the LFE rumble present in 33.

added ALSA:surround51 as an option in audio config.

comment:59 Changed 16 years ago by mythtv@…

Hi, seems I was a little bit to fast in saying that everything works ok. While watching TV or playing video/dvd works fine, mythmusic does not. I get a lot of errors like

AO, ERROR: Audio buffer overflow, 5599 audio samples lost!

and audioplayback is very distorted. Another thing I noticed is that when I'm using mythmusic compiled against the unpatched mythtv (but mythtv itself is already running with the patch) it seems to work fine, but after a while I noticed that it plays the songs to fast (a 5:00 song is played in about 4:50). But there are no buffer overflows. After recompiling mythmusic the overflow errors occure.

If you need more information please let me know.

Christoph

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.35.patch added

comment:60 Changed 16 years ago by Mark Spieth

35 fixes mythmusic issue

changed music centre width to 50% so that some comes out of the centre speaker

comment:61 Changed 16 years ago by mythtv@…

Everything seems to work fine now. I needed to uncomment #define FILTERED_LFE, though. Otherwise I get the "rumble" you mentioned earlier.

Christoph

comment:62 Changed 16 years ago by mythtv@…

Sorry, again I have to correct myself. I now know what you mean with "rumble". With FILTERED_LFE defined I do have rumble (only with watching TV, mythvideo and mythmusic are fine). The problem I noticed before (without FILTERED_LFE defined) is more like an echo in LFE or like LFE is not playing the correct data. I don't know how to describe this further. This is just happening while watching TV. mythvideo and mythmusic are fine.

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.36.patch added

comment:63 Changed 16 years ago by Mark Spieth

36 hopefully will help the buffer underrun issue

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.37.patch added

comment:64 Changed 16 years ago by Mark Spieth

37 has reduced buffer requirements, slightly more cpu but optimizations to come.

new config for upmix type

Passive (low cpu, similar to old alsa type but not tied to alsa) Active Simple (higher cpu) Active Linear (highest cpu)

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.38.patch added

comment:65 Changed 16 years ago by anonymous

38 has more performance optimizations.

filtered_lfe fixed and is now enabled

gain normalization between passive and active modes

should be quite good.

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.39.patch added

comment:66 Changed 16 years ago by Mark Spieth

39 fixes 64 bit compile error

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.40.patch added

comment:67 Changed 16 years ago by Mark Spieth

40 fixes up gain values to eliminate clipping found in some cases.

For the testers please check relative gain modes for upmix/6ch in any modes you care to use. Thanks.

Also has fix for mythmusic nonblocking mode.

comment:68 Changed 16 years ago by elkin@…

Hi, does not apply to 15387... but I'd like to try it.

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.42.patch added

comment:69 Changed 16 years ago by Mark Spieth

42 fixes scaling issue to prevent clipping. works ok with mythmusic too.

Also a minor performance increase

Changed 16 years ago by Mark Spieth

Attachment: mythtv_mm_mad.1.patch added

comment:70 Changed 16 years ago by Mark Spieth

added a patch for mythmusic maddecoder as this one calls reconfigure every time through the output loop. its the ony one that does it too which is strange but there may be a reason, so it is now qualified so it does it only when the params it calls it with change.

paulh may like to review this one.

comment:71 Changed 16 years ago by elkin@…

patch 42 woks fine on my system. Both normal TV/recordings + mythmusic

comment:72 in reply to:  70 Changed 16 years ago by paul@…

Replying to markspieth:

added a patch for mythmusic maddecoder as this one calls reconfigure every time through the output loop. its the ony one that does it too which is strange but there may be a reason, so it is now qualified so it does it only when the params it calls it with change.

paulh may like to review this one.

This patch has fixed the log messages from Mythmusic - cheers Mark!

TV and recordings both sound good. No sign of clipping anywhere.

Have we lost a bit of gain somewhere with p42? I've had to turn the master [physical] volume control up a bit.

Top work though!

PC

comment:73 Changed 16 years ago by derliebegott@…

working great also here. nor problems at all.

Have we lost a bit of gain somewhere with p42? I've had to turn the master [physical] volume control up a bit.

I did not notice that.

comment:74 Changed 16 years ago by mythtv@…

working great here. No clipping with p42 anywhere. No rumble, no echos. Also tested with dvd playback (where i had clipping issues with p40).

comment:75 Changed 16 years ago by keller999

First, thanks for the great patch - surround has never been easier or better.

I'm seeing an issue that you may already be aware of - when the ac3 stream changes from 6 channel to 2 channel, the audio heavily distorts until 6ch comes back. Looking in the code, it seems that the code tries to compensate for this and switch to reading the stream correctly, but in my case it just displays the "audio stream changed" message and plays the distorted sound.

Anything I can do to help provide more information, please let me know. Thanks again!

-Keller

comment:76 Changed 16 years ago by danielk

Owner: changed from Isaac Richards to danielk
Status: newassigned

I'm going to try to get this into 0.21...

comment:77 Changed 16 years ago by anonymous

mythtv_ac3.42.patch does not apply to the latest SVN 15561.

comment:78 Changed 16 years ago by laga+mythtv@…

Yes, mythtv_ac3.42.patch was broken by the multirec merge. I'm also experiencing the problem where sound is heavily distorted when switching from 6ch ac3 to 2ch ac3. It doesn't go away if I switch to a normal mp2 stream either.

comment:79 Changed 16 years ago by danielk

(In [15635]) Refs #1104. Adds small freesurround lib for Mark Spieth's extended multi-channel audio sound support.

Changed 16 years ago by danielk

Attachment: mythtv_ac3.43.patch added

Mark's patch after a bit of code review. I still need to do some testing...

comment:80 Changed 16 years ago by Mark Spieth

thanks daniel

a couple of comments reading your patch.

audiooutputalsa.cpp doesnt need realdevice split anymore as it doesnt need to switch devices. Ill correct this as soon as you commit and we get in sync.

other than that it looks identical. I was just going to post an updated patch which I wont do now :)

comment:81 Changed 16 years ago by danielk

(In [15728]) Refs #1104. Commits some more safe parts of mutli channel audio enhancement patch to shrink size of patch.

Changed 16 years ago by danielk

Attachment: mythtv_ac3.44.patch added

Updatd patch

comment:82 Changed 16 years ago by danielk

Mark, how much work would it be to use ffmpeg's fourier transforms if fftw3 isn't available?

Also, if we do use fftw3, we're going to need to check for it in ./configure and not use it if it isn't installed..

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.45.patch added

comment:83 Changed 16 years ago by Mark Spieth

added patch (use 46) for fixing multichannel 2-6 in the same stream. sorry daniel I havent updated my source to your reviewed patchset yet. Any advice on how to merge easily instead of waiting for commit. The adjusted files are avfd.cpp in getframe, audiooutputbase.cpp and lavc(ac3dec.c dca.c liba52.c}

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.46.patch added

comment:84 Changed 16 years ago by Mark Spieth

just a note about style I observed syncing the 2 patches.

if you put say

virtual float GetStretchFactor?(void) { return 1.0; }

in the class def, every time the class def is referenced, it will create a copy of this function. This is why even for a small method, its better practice to put it in the .cpp

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.47.patch added

same as 46 but formatted to daniels reviewed version

comment:85 Changed 16 years ago by Mark Spieth

DVB radio with sample provided tested ok for me with latest patches. Couldnt play it at all previously. For those interested, please test.

comment:86 Changed 16 years ago by anonymous

For this:

virtual float GetStretchFactor??(void) { return 1.0; }

Sure, it is virtual so it won't be inlined and you're right. If you want to move it back that's fine. I don't think this function is big enough to worry about.

I like to keep these 'return one value' functions in the header so that when tracing a method through it saves one step. On PC's I don't worry about memory efficiency for code, just data.

Thanks for the fixes. I'm setting up my 5.1 speaker setup in my living room today, so I can test this properly. :)

comment:87 Changed 16 years ago by danielk

Ok, so in my testing so far ALSA:analog works great at 2ch and 5.1ch. Kudos.

But with "ALSA:spdif":

AC3 passthrough only when "Max Audio Channels" is set to "Stereo".

When time stretch is engaged (disabling passthrough) CPU usage goes through the roof (110% of on an AMD 64 X2 4200+), there is sound, but it is very corrupted.

Without AC3 passthrough checked, there is no sound at all.

I have not tested with other audio output methods yet or to see if DTS passthrough sound still works. Before I do, had you tested SPDIF output? If so and you got sound, what kind of CPU usage were you seeing?

comment:88 Changed 16 years ago by anonymous

Hello, I have tried this patch a few times over the past year or so, but I could never get it to patch correctly. I downloaded the latest mythtv_ac3.47.patch and tried to run "patch -p0 < myth_ac3.47.patch" from within /usr/src/myth-0.20.2.svn20080126. I get:

can't find file to patch at input line 1525 Perhaps you used the wrong -p or --strip option? The text leading up to this was:


|Index: libs/libavcodec/liba52.c |===================================================================

libs/libavcodec/liba52.c (revision 15728)

|+++ libs/libavcodec/liba52.c (working copy)


I can't even find a file called liba52.c.

Is there a newer patch for this version of Mythtv? I always see references on this site about patch versions, but I can never find out what version the patch works for. I'm fairly linux competent, but not a programmer (other than what little I remember from my CS classes in college; but I'm a network admin and haven't used that in years).

Thanks in advance for your help.

comment:89 in reply to:  88 ; Changed 16 years ago by Roo <roo.watt@…>

Replying to anonymous:

Hello, I have tried this patch a few times over the past year or so, but I could never get it to patch correctly. I downloaded the latest mythtv_ac3.47.patch and tried to run "patch -p0 < myth_ac3.47.patch" from within /usr/src/myth-0.20.2.svn20080126.

The patch is for trunk and it appears you are trying to patch against source from the 0.20-fixes branch.

That would explain the "missing" file.

HTH.

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.48.patch added

fixed passthru and intrastream channel switch hiccup

comment:90 Changed 16 years ago by Mark Spieth

ac3 passthru and reencode should work again with 48.

use maxchannels 2 for passthrough modes due to alsa requiring 2ch open.

comment:91 in reply to:  89 Changed 16 years ago by anonymous

Thanks for the info. But I'm not sure how to get what I need. Do I need to get: svn co http://svn.mythtv.org/svn/trunk/mythtv svn co http://svn.mythtv.org/svn/trunk/mythplugins svn co http://svn.mythtv.org/svn/trunk/myththemes

Is this code likely to hit an actual release anytime soon? If so, maybe I'll wait. I hope I'm right and this will allow me to use my analog jacks (SI7012) for 6 channel sound? Will it do regular surround also (encoded stereo surround like on analog broadcast tv)? That's what I really want, that and to be able to use the internal mythdvd player with 5.1. Thanks again for the info and all your work guys.

Replying to Roo <roo.watt@gmail.com>:

Replying to anonymous:

Hello, I have tried this patch a few times over the past year or so, but I could never get it to patch correctly. I downloaded the latest mythtv_ac3.47.patch and tried to run "patch -p0 < myth_ac3.47.patch" from within /usr/src/myth-0.20.2.svn20080126.

The patch is for trunk and it appears you are trying to patch against source from the 0.20-fixes branch.

That would explain the "missing" file.

HTH.

comment:92 Changed 16 years ago by danielk

Mark, passthru works with 48, but I'm just getting a lot of noise on re-encode... are you sending the right AC3 marker bits in the re-encoded stream?

BTW The for the mix problem in analog, just play any old PVR-250 recording. If you've adjusted your system correctly for 5.1, it sounds as if these 2ch recordings are being mixed to 5.1 so that they voices are very low volume while the background sounds are still at the correct volume; overall the volume is lower than 5.1 ATSC sources. I also see this on ads in Sunday's Superbowl, at minute 50:30 the Pepsi ad is ok, at 51:00 the salesgenie ad has very low volume, and the Fox terminator promo at 51:30 mostly sounds ok but sound noticeably dips in a few of the cuts.

comment:93 Changed 16 years ago by jppoet@…

I tested this with svn rev 15806.

With the mythtv_ac3.48.patch, timestretch is complete unusable. As soon as I hit the "TOGGLESTRETCH" key (ctrl-s on my system), all I get are clicks and pops -- the audio completely goes away. Toggling the timestretch to go back to 1.0x speed does not fix the problem -- The only way to get the audio back is to stop the show and start playing it again.

I have pass-though enabled and only use the S/PDIF connection to my preamp.

John

Changed 16 years ago by cizek@…

Attachment: ac3enc.patch added

Possible fix for bad re-encoding

comment:94 Changed 16 years ago by cizek@…

I use pass-through using S/PDIF also. I had to change the AudioOutputDigitalEncoder? class to get it to work right. My change is in ac3enc.patch. It's a hack, but it works for me.

HTH, Bill

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.49.patch added

support for ffmpeg fft, fix for passthru reenc

comment:95 Changed 16 years ago by Mark Spieth

49 now has

lavc fft support
passthru reencode fix as found by bill
consolidated gain values

new configure option '--enable-libfftw3'

without it it uses the lavc fft. not sure but from simple tests, performance seems to be about the same, which confuses me as I always thought fftw3 was heaps better. perhaps others would like to test this too. I almost lean towards lavcfft as being slightly better (using top to measure).

with new gain settings, centerlevel is bigger and music centerwidth has been adjusted to 70% to get good output from the L/R speakers.

If anyone finds any clipping occuring in either music or movie modes, let me know but it shouldnt happen.

hopefully there is nothing else wrong.

if all gets committed perhaps some user controls for some settings from menu may be desirable. also continuous reencode for all modes as has been requested in the past. open to suggestions/patches.

comment:96 Changed 16 years ago by danielk

(In [15893]) Refs #1104. Applies patch from Mark Spieth to improve 6 speaker audio support in MythTV.

This adds six speaker decoding for analog ALSA outputs, and allows timestretch to be used with external AC3 decoders. See ticket for details.

You must rerun ./configure and recompile both MythTV and the plugins due to audio ABI changes.

comment:97 Changed 16 years ago by Janne Grunau

(In [15894]) display whether libfftw3 is enabled. Refs #1104

comment:98 Changed 16 years ago by Robin Gilks <g8ecj@…>

Is there now an option to always have the 6 speaker synthesis for external decoder enabled or is it just in timestretch mode?

I only connect via S/PDIF but would like to make use of the 2 to 6 channel expansion 100% of the time eg. in MythMusic (with automatic passthrough if the source is 5.1 to start with). Is this now possible?

Cheers

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.50.patch added

missed lib dependency

comment:99 Changed 16 years ago by Mark Spieth

missed a lib dependency for libmyth

comment:100 Changed 16 years ago by Janne Grunau

(In [15898]) add ../libmythfreesurround to DEPENDPATH. Refs #1104

comment:101 Changed 16 years ago by anonymous

15893 and later doesn't seem to build under win32. Neither 'AudioCodecMode?' nor 'AUDIOCODECMODE_NORMAL' are "declared in this scope".

relevant compile output: In file included from audiooutput.cpp:13: audiooutputdx.h:42: error: `AudioCodecMode?' has not been declared audiooutputdx.h:42: error: ISO C++ forbids declaration of `aom' with no type audiooutputdx.h:42: error: `AUDIOCODECMODE_NORMAL' was not declared in this scope

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.51.patch added

patch for mingw

comment:102 Changed 16 years ago by Mark Spieth

51 should support mingw compilation.

note no support for BIGENDIAN as yet for audiooutputreencoder. swab does this for LITTLEENDIAN but not sure if removing it is all that is required for BIGENDIAN support. someone may wish to try.

comment:103 Changed 16 years ago by dave@…

I have the following card:

front:CARD=CMI8738MC6,DEV=0

C-Media PCI CMI8738-MC6, C-Media PCI DAC/ADC Front speakers

iec958:CARD=CMI8738MC6,DEV=0

C-Media PCI CMI8738-MC6, C-Media PCI DAC/ADC IEC958 (S/PDIF) Digital Audio Output

null

Discard all samples (playback) or generate zero samples (capture)

When I enable the upmix, I get the following in my stdout 2008-02-12 21:13:01.286 Opening ALSA audio device 'default'. 2008-02-12 21:13:01.287 AudioOutput? Error: Channels count (6) not available: Invalid argument 2008-02-12 21:13:01.287 AudioOutput? Error: Unable to set ALSA parameters

What am I doing wrong?

comment:104 Changed 16 years ago by danielk

(In [16001]) Refs #1104. Fixes MINGW compilation after multi channel audio commit w/patch from Mark Spieth.

comment:105 Changed 16 years ago by danielk

Resolution: fixed
Status: assignedclosed

(In [16006]) Fixes #1104. Applies final patch of Mark Spieth's multi channel audio changes. This fixes a problem where the audio would hickup when MythMusic reset the audiooutput when it didn't need to.

comment:106 Changed 16 years ago by Nigel

Mark, thanks for the win patch. Daniel, it wasn't quite right (it changed the sig of Reconfigure to a bool for audio_passthru, and didn't cast the second arg of swab(). I will commit re-repair soon. [BR? Mark, audiooutputdigitalencoder.cpp has a lot of (data+8). Any objection to this change:

Changed 16 years ago by anonymous

Attachment: swab-and-tidy.patch added

comment:107 Changed 16 years ago by Nigel

(In [16007]) MinGW compile fixes. See #1104, [16001] and [16005]

comment:108 Changed 16 years ago by Nigel

(In [16008]) MinGW compile fixes. See #1104, [16001] and [16005]

comment:109 in reply to:  105 Changed 16 years ago by Matt S <skd5aner@…>

Replying to danielk:

(In [16006]) Fixes #1104. Applies final patch of Mark Spieth's multi channel audio changes. This fixes a problem where the audio would hickup when MythMusic reset the audiooutput when it didn't need to.

Was 16006 also committed to trunk?

comment:110 Changed 16 years ago by luitjens@…

Can someone please post the library requirements and the configure options needed for this to work?

I'm using fedora core 8 and tried to follow the configure options listed earlier (--enable-liba52bin --enable-liba52 --disable-decoder=ac3 --enable-decoder=liba52) and got the following linking error:

g++ -o mythfrontend version.o main.o manualbox.o playbackbox.o viewscheduled.o globalsettings.o manualschedule.o programrecpriority.o channelrecpriority.o statusbox.o networkcontrol.o mediarenderer.o custompriority.o mythappearance.o moc_manualbox.o moc_playbackbox.o moc_viewscheduled.o moc_globalsettings.o moc_manualschedule.o moc_programrecpriority.o moc_channelrecpriority.o moc_statusbox.o moc_networkcontrol.o moc_custompriority.o moc_mythappearance.o -L/usr/lib/qt-3.3/lib -L../../libs/libmyth -L../../libs/libmythtv -L../../libs/libavutil -L../../libs/libavcodec -L../../libs/libavformat -L../../libs/libmythfreemheg -L../../libs/libmythui -L../../libs/libmythupnp -L../../libs/libmythlivemedia -lmythtv-0.21 -lmythavformat-0.21 -lmythavutil-0.21 -lmythavcodec-0.21 -lmythfreemheg-0.21 -lmythupnp-0.21 -lmythlivemedia-0.21 -lmyth-0.21 -lmythui-0.21 -lfreetype -lmp3lame -lasound -lartsc -lgmodule-2.0 -ldl -lgthread-2.0 -lrt -lglib-2.0 -ljack -lraw1394 -liec61883 -lavc1394 -lrom1394 -lXinerama -lXv -lXxf86vm -lXrandr -lXvMCW -lXvMC -lqt-mt -lGLU -lGL -lXmu -lXext -lX11 -lm -lpthread /usr/bin/ld: warning: liba52.so.0, needed by ../../libs/libavcodec/libmythavcodec-0.21.so, not found (try using -rpath or -rpath-link) ../../libs/libavcodec/libmythavcodec-0.21.so: undefined reference to `ac3_decoder'

I have following a52 libraries installed:

a52dec.i386 0.7.4-8.fc7 a52dec-devel.i386 0.7.4-8.fc7

Thanks

Changed 16 years ago by Mark Spieth

Attachment: mythtv_ac3.52.patch added

should fix multichannel timestretch with spdif

comment:111 in reply to:  49 Changed 16 years ago by Denys Dmytriyenko <denis@…>

Replying to Tyson Harding <tharding@cs.utah.edu>:

I couldn't get this to play DVDs with "Extra Audio Buffering" enabled. Six channel audio would not work, the frontend would get stuck in a loop with a black screen. The logs showed

[ac3 @ 0xb7330ba8] buffer 192000 too small

printed repeatedly and the frontend would not respond. I was able to fix the problem by either turning off "Extra Audio Buffering", or changing the AVCODEC_MAX_AUDIO_FRAME_SIZE value from 192000 to 384000, so now avcodec.h has

#define AVCODEC_MAX_AUDIO_FRAME_SIZE 384000 // 2 second of 48khz 32bit audio

I'm now experiencing this same issue with latest SVN playing some/most DVDs. None of the suggested fixes work for me - Extra Audio buffering is off and FRAME_SIZE increased to 384000.

I see this (I believe "audio stream changed" is the cause):

[ac3 @ 0xb7392688]buffer 192000 too small
audio stream changed
NVP: Disabling Audio, params(0,-1,48000)
[ac3 @ 0xb7392688]buffer 192000 too small
[ac3 @ 0xb7392688]buffer 192000 too small
[ac3 @ 0xb7392688]buffer 192000 too small
...

comment:112 Changed 16 years ago by joe.yasi@…

Is it possible to get this to work with 5 channel audio? The CBS affiliate in my area broadcasts in AC3 5.0 instead of 5.1. 6 channel audio works, but I get no sound in mythtv from this 5 channel source.

comment:113 Changed 16 years ago by Nigel

(In [16413]) Tidy encode_frame by applying swab-and-tidy.patch. See #1104

comment:114 Changed 16 years ago by Doug Goldstein <cardoe@…>

Resolution: fixed
Status: closednew

We have a user request for this functionality in 0.21, is it possible to backport this to 0.21?

http://bugs.gentoo.org/show_bug.cgi?id=176480

comment:115 Changed 16 years ago by Doug Goldstein <cardoe@…>

ugh. I'm being stupid. Please close.

comment:116 Changed 16 years ago by Janne Grunau

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.