Skip to content

Conversation

ulmus-scott
Copy link
Contributor

This contains some minor cleanups to the libmyth/audio code and moves the resulting code to libmythtv/audio.

libmyth/mythav* are also moved to libmythtv so libmyth no longer uses FFmpeg, is no longer used by other libraries, and contains just MythContext and GUI files for libmythupnp. It is essentially now libmythupnp-ui, but I have not renamed it.

Checklist

@ulmus-scott ulmus-scott force-pushed the audio branch 4 times, most recently from 58efc7e to cb74f4a Compare July 3, 2025 05:43
Use <>, not "", since it is not a header defined by MythTV.
and move it from libmyth/output.h to libmyth/audio/audiooutput.h.
and move it from libmyth/visual.h to libmyth/audio/visualization.h.
and return a copy, since QString is COW.

Also, it makes no sense to convert from UTF-16 to UTF-8 and then back to UTF-16,
so don't.
AudioReencodeBuffer subclasses AudioOutput, neither of which use
AudioOutput::m_lastError, so calling ClearError() does nothing.
and use it to replace most uses of GetError().

AudioOutput::Error() already logs the message, so remove duplicate log entries
in MusicPlayer::openOutputDevice() and MythRAOPConnection::OpenAudioDevice().

AudioOutputBase::Reconfigure() sets m_isConfigured to false for all of the early
returns, which it should have been doing for m_configureSucceeded.
AudioPlayer::ReinitAudio()'s return value is unused, so this only changes the
notification and log.  However, the former message text is in the log and is
available as an event if desired.
and replace Error() with LOG() and dispatchError(), a renamed error().
The mixing coefficient matrices should be transposed so the coefficients for
each output channel are contiguous in memory and line up with the input data.
The matrix multiplication would probably be faster and easier to vectorize.

This probably could be implemented with FFmpeg’s pan filter.
https://trac.ffmpeg.org/wiki/AudioChannelManipulation
https://ffmpeg.org/ffmpeg-filters.html#pan

I have no idea where the mixing coefficients come from and throwing away the
LFE information is not optimal.  The coefficients don’t match ATSC A/52:2012
section 7.8.2 Downmixing into Two Channels nor Ogg’s
(https://www.rfc-editor.org/rfc/rfc7845#section-5.1.1.5).
Additionally, the coefficients are not normalized, so this could cause clipping.

Other coefficients: https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg#1410620
instead of forwarding through AudioOutputUtil.

Also move the test code from TestAudioUtils to TestAudioConvert.
The only difference is the AVFrame AudioOutput::m_frame will be reused instead
of allocating and freeing an AVFrame with every call and the samples will be
converted to FORMAT_S16 if AudioOutput::CanProcess() returns false.  However,
FORMAT_S16 is the desired format and no conversion was performed, so the
audio samples were assumed to already be FORMAT_S16.
It is a Visualization and they were the only files in audio/
that used libmythui.
libmyth is now MythContext and GUI files for libmythupnp.
It is no longer used by any other library.
It is only used by MythContext so move the files to be with mythcontext.*.
for moving libmyth/audio to libmythtv.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant