How to disable Dolby Digital AC3 dynamic range compression
#16
I'm having trouble getting it built. The advanced settings bit didn't compile, but I just removed that. Then the av_opt_set_int couldn't be found by the compiler. I found that I needed to include "libavutil/opt.h" in DVDAudioCodecFFmpeg.cpp. Then it compiled, but now the linker can't find av_opt_set_int(void*, char const*, long, int).

Code:
xbmc/cores/dvdplayer/DVDCodecs/Audio/Audio.a(DVDAudioCodecFFmpeg.o): In function `CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo&, CDVDCodecOptions&)':
/home/halfgaar/tmp/xbmc3/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp:92: undefined reference to `av_opt_set_int(void*, char const*, long, int)'

This is where I'm stuck. 'nm' shows the symbol is present in libavutil.a, but I can't get the linker to understand that.

BTW, having the code in the DVD player logic is fine for my test, but don't we ultimately want it everywhere? The AVCodecContext object is used frequently, so perhaps some kind of factory generator is necessary to make sure all instances use one that applies the DRC setting.
Reply
#17
Maybe one of our audio devs may care to comment @FernetMenta @fritsch
Reply
#18
From the above, it seems he is compiling with external ffmpeg. Use our internal supplied version.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#19
sudo apt-get build-dep kodi
./bootstrap ; ./configure ; make

is enough. The apt-get build-dep works after you added the deb-src line from our ppa.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#20
I did those steps @fritsch. I altered the LD_SILENT in the make file to be not silent, and the LD output does show references to the proper libavutil.a:

Code:
g++ -O2 -g -D_DEBUG -Wall  -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -std=gnu++11 -O2 -g -D_DEBUG -Wall  -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -std=gnu++11   -o kodi.bin xbmc/main/main.a -Wl,--start-group xbmc/main/main.a xbmc/linux/linux.a xbmc/network/network.a xbmc/video/windows/videowindows.a xbmc/utils/utils.a xbmc/cores/DllLoader/exports/util/exports_utils.a xbmc/cores/DllLoader/exports/exports.a xbmc/settings/settings.a xbmc/video/video.a xbmc/pvr/addons/pvraddons.a xbmc/pvr/windows/pvrwindows.a xbmc/guilib/guilib.a  /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libavcodec.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libavfilter.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libswresample.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libavformat.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libavutil.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libpostproc.a /home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib/libswscale.a xbmc/cores/dvdplayer/DVDPlayer.a xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.a xbmc/cores/dvdplayer/DVDCodecs/Audio/Audio.a xbmc/cores/dvdplayer/DVDCodecs/Overlay/Overlay.a xbmc/cores/dvdplayer/DVDCodecs/Video/Video.a xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxers.a xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreams.a xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitles.a lib/SlingboxLib/SlingboxLib.a lib/libRTV/librtv.a lib/libXDAAP/libxdaap.a xbmc/addons/addons.a xbmc/cdrip/cdrip.a xbmc/cores/AudioEngine/audioengine.a xbmc/cores/DllLoader/dllloader.a xbmc/cores/ExternalPlayer/ExternalPlayer.a xbmc/cores/VideoRenderers/VideoRenderer.a xbmc/cores/VideoRenderers/VideoShaders/VideoShaders.a xbmc/cores/cores.a xbmc/cores/paplayer/paplayer.a xbmc/cores/playercorefactory/playercorefactory.a xbmc/dbwrappers/dbwrappers.a xbmc/dialogs/dialogs.a xbmc/epg/epg.a xbmc/filesystem/MusicDatabaseDirectory/musicdatabasedirectory.a xbmc/filesystem/VideoDatabaseDirectory/videodatabasedirectory.a xbmc/filesystem/filesystem.a xbmc/input/input.a xbmc/interfaces/generic/interfaces-generic.a xbmc/interfaces/info/info.a xbmc/interfaces/interfaces.a xbmc/interfaces/json-rpc/json-rpc.a xbmc/listproviders/listproviders.a xbmc/media/media.a xbmc/music/dialogs/musicdialogs.a xbmc/music/infoscanner/musicscanner.a xbmc/music/karaoke/karaoke.a xbmc/music/music.a xbmc/music/tags/musictags.a xbmc/music/windows/musicwindows.a xbmc/network/websocket/websocket.a xbmc/peripherals/bus/peripheral-bus.a xbmc/peripherals/devices/peripheral-devices.a xbmc/peripherals/dialogs/peripheral-dialogs.a xbmc/peripherals/peripherals.a xbmc/pictures/pictures.a xbmc/playlists/playlists.a xbmc/powermanagement/powermanagement.a xbmc/profiles/profiles.a xbmc/profiles/dialogs/profiles_dialogs.a xbmc/profiles/windows/profiles_windows.a xbmc/programs/programs.a xbmc/pvr/channels/pvrchannels.a xbmc/pvr/dialogs/pvrdialogs.a xbmc/pvr/pvr.a xbmc/pvr/recordings/pvrrecordings.a xbmc/pvr/timers/pvrtimers.a xbmc/rendering/rendering.a xbmc/settings/dialogs/settings_dialogs.a xbmc/settings/lib/settings_lib.a xbmc/settings/windows/settings_windows.a xbmc/storage/storage.a xbmc/video/dialogs/videodialogs.a xbmc/video/jobs/video-jobs.a xbmc/video/videosync/videosync.a xbmc/view/view.a xbmc/windowing/windowing.a xbmc/windows/windows.a xbmc/xbmc.a xbmc/network/httprequesthandler/httprequesthandlers.a xbmc/network/httprequesthandler/python/httprequesthandlers-python.a xbmc/interfaces/legacy/legacy.a xbmc/interfaces/legacy/wsgi/legacy-wsgi.a xbmc/interfaces/python/python_binding.a xbmc/rendering/gl/rendering_gl.a lib/libUPnP/libupnp.a xbmc/network/upnp/upnp.a xbmc/input/linux/input_linux.a xbmc/network/linux/network_linux.a xbmc/powermanagement/linux/powermanagement_linux.a xbmc/storage/linux/storage_linux.a xbmc/windowing/X11/windowing_X11.a lib/UnrarXLib/UnrarXLib.a -Wl,--end-group xbmc/threads/threads.a xbmc/commons/commons.a -lssh -lXrandr -lavahi-client -lavahi-common -lmicrohttpd -ljasper -lresolv -lbluetooth -lmysqlclient -lssl -lcrypto -lz -llzo2 -lpthread -ltiff -ljpeg -lbz2 -lgcrypt -lgpg-error -lGLU -lGLEW -lGL -L/usr/lib -lpython2.7 -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl -ltinyxml -lyajl -lxml2 -lxslt -lxml2 -lfribidi -lsqlite3 -lpng12 -lpcre -lpcrecpp -lpcre -lfreetype -ltag -lcdio -lm -lasound -ldbus-1 -lSDL2 -lasound -lpulse -lX11 -lXext -ldrm -lXt -lX11 -lXmu -lXt -lX11 -lsmbclient -ludev -pthread -L/home/halfgaar/tmp/xbmc3/tools/depends/target/ffmpeg/ffmpeg-install/lib -lva-x11 -lva -lxcb-shm -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lX11 -lnettle -lhogweed -lgmp -lvorbisenc -lvorbis -logg -lgnutls -lcrystalhd -llzma -lbz2 -lz -lm -lva-x11 -lva   -L/home/halfgaar/tmp/xbmc3/tools/depends/native/libsquish-native/squish-install/lib -lsquish   -lgnutls -lgcrypt -lgpg-error -ltasn1 -lz -lp11-kit   -lvorbisenc -lvorbis -lm -logg   -rdynamic

Without the modifications, it compiles and runs fine.

I did suspect that I may be using the wrong libavutil, but at this point, I don't know how to fix it.
Reply
#21
my change was made dry (no compiler where i did it) - does it do anything good?

Also this is already a generic spot. Its used for all audio which is decoded by ffmpeg - i don't know how to find an even more generic place for this.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#22
I can't get it compiled, or rather, linked. See my previous posts.
Reply
#23
I have added a commit here which should fix compilation and linkage:

https://github.com/Memphiz/xbmc/commits/ac3drc

2 Top most commits are the complete change ...
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#24
It didn't work at first, but I fixed it:

Code:
--- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
@@ -92,8 +92,9 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
     }
   }

-  if (!g_advancedSettings.m_audioApplyDrc)
-    av_opt_set_int(m_pCodecContext, "drc_scale", 0, 0);
+  // drc scale is actually a double between 0 and 1, but Kodi settings don't account for that, currently.
+  int drc_scale = g_advancedSettings.m_audioApplyDrc ? 1 : 0;
+  av_opt_set_int(m_pCodecContext, "drc_scale", drc_scale, AV_OPT_SEARCH_CHILDREN);

   if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
   {

I wrote it with the ternary operator, otherwise the application of DRC depends on the default of ffmpeg when g_advancedSettings.m_audioApplyDrc == false. Now it's dependent on the applydrc setting in advancedsettings.xml. When I don't have that file, DRC is applied. When I do, dynamic range is good.

That brings me to the question of what the default should be. As someone who designs and builds sound system for high quality reproduction, I am very amazed that so many decoders, hard- and software, apply DRC by default. Kodi does too, apparently. I feel very strongly that this should be off by default. Someone who wants it on is more likely to look in the settings to do something about the 'barely audible dialog', than somebody is to fix the bad sound quality of a recording (because it takes a very trained ear to hear that the audio of the film your listening too has been compressed, as opposed to just bad).

Also, as it stands now, Kodi only applies it to AC3 streams by default, because as was stated in this thread, there is no global DRC algorithm in Kodi, and AC3 is the only codec that has it integrated in the 3rdparty libraries. This also explains my hypothesis from before, why I think that this is the reason so many people think AC3 sounds worse than DTS. It does for most people, but it shouldn't have to. I'll see about making those recordings so show you the difference.

So, in my perhaps not so humble opinion, applydrc should be false by default Smile.
Reply
#25
To continue with my last post, here are the screenshots and audiofiles of a DTS capture, AC3 no DRC and AC3 with DRC capture:

Image

And you can download the audio:

Pretty clear, isn't it?
Reply
#26
i have pinged our audio engine chief about this thread (though he is on cebit atm - so patience until he responds). Thx for testing and the test files - usefull stuff Smile
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#27
(2015-03-18, 19:55)halfgaar Wrote: So, in my perhaps not so humble opinion, applydrc should be false by default Smile.

With default settings we try to play back the stream closest to the information coded in the stream. the default value of drc_scale is 1.0 and does:

Code:
powf(x,  s->drc_scale)

where x is coded in the ac3 stream. This means that we don't change the original value intended by the recorder.
Reply
#28
I'm not following. FFmpeg/libavcodec has drc_scale default at 1, true. I don't know where that line of code comes from, but ffmpeg/libavcodec clearly consider a value of 1 as having DRC applied. That is not the intended sound. Why would the sound engineer want the Dolby Digital stream to sound so much worse compared to the DTS, where they have the potential to sound the same?

The DRC metadata present in the stream is for those who want to apply controlled DRC to the stream. If you want the original cinema sound, DRC has to be turned off. That is accomplished by setting it at 0, as my screenshots and recordings and the mpv man page show.

As the Dolby's metadata PDF says:

Quote:The engineer is ultimately responsible for optimizing the multichannel mix for best
reproduction in the optimal listening environment. However, care should be taken to
ensure that less optimal listening environments are accounted for, as well. On the
contrary, enjoyment of a television program should not be limited to only those
consumers with full-blown home theater systems. Dolby Digital and metadata combine to
provide a simple and easily used method to provide for the best quality reproduction
without regard to the number of speaker channels, ambient noise levels, or quality of
equipment in a consumer’s home.

By applying DRC by default, you are forcing all users to play AC3 (and only AC3) to play it as though it was a mediocre quality sound system.
Reply
#29
powf(x, s->drc_scale) which means: x^1 = x -> nothing happens.

Edit: https://github.com/FFmpeg/FFmpeg/blob/ma.../ac3.h#L91
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#30
But isn't that just setting the dynamic range
https://github.com/FFmpeg/FFmpeg/blob/ma...dec.c#L843
which gets converted to a gain:
https://github.com/FFmpeg/FFmpeg/blob/ma...ec.c#L1341
which scales the samples:
https://github.com/FFmpeg/FFmpeg/blob/ma...ec.c#L1349

So a drc_scale of 0 and a powf(x, s->drc_scale) = 1 would make sense to leave the audio untouched.
Reply

Logout Mark Read Team Forum Stats Members Help
How to disable Dolby Digital AC3 dynamic range compression0