Skip to content

Commit

Permalink
ActiveAE: set resampling quality to low when changing ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Aug 1, 2013
1 parent 534e3be commit 385b2f7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ void CActiveAE::StateMachine(int signal, Protocol *port, Message *msg)
if ((unsigned int)(par->stream->m_resampleBuffers->m_format.m_sampleRate * par->parameter.double_par) != par->stream->m_resampleBuffers->m_outSampleRate)
{
par->stream->m_resampleBuffers->m_resampleRatio = par->parameter.double_par;
par->stream->m_resampleBuffers->m_resampleQuality = AE_QUALITY_LOW;
par->stream->m_resampleBuffers->m_changeResampler = true;
}
}
Expand Down

10 comments on commit 385b2f7

@Karlson2k
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean, that while constantly changing ratio (on video playback synced to video) we always get "AE_QUALITY_LOW"?

@FernetMenta
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with higher quality it takes quite a long time to reinit the resampler. This would result in audio drop-outs on low power systems.

@FernetMenta
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aballier swr does not directly support changing resample ratio on the fly. After changing a parameter swr_init has to be called. This is quite expensive. On an Atom system i measured 80ms (low quality), 160ms (medium), 650ms (high) for the init call. Do you know if direct support is planned for swr? Soxr would support it but but the swr api does not.

@aballier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know but I would bet that no: The idea as I understand it is to have a costly swr_alloc + swr_init that precomputes what is needed so that swr_convert is faster afterwards. You should ask in #ffmpeg-devel @ freenode to get a good answer though. They'll know better than me the internals and maybe they can come up with a solution avoiding swr_init.

With the current swr 'philosophy' I'd say the best is to try to keep constant output parameters by all means.

@aballier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that I read a bit the code, swr has 'async', 'max_soft_comp' & friends options which could be what is needed for this case

@FernetMenta
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I checked the code for async. As far as I can see it operates on timestamps we don't feed the resampler with. How would this work? The API doc says swr_init has to be called after change of any option.

@aballier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it'd be more complicated I think: I really don't know the details so don't trust me but as I understand it if you want to sync audio on video you'll have to feed it with timestamps and set some compensation. The compensation / async is set at swr_init and never changes, then you play with pts to achieve syncrhonisation.

@Karlson2k
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FernetMenta ActiveAE will always use "AE_QUALITY_LOW" with video playback synced on video? Did I understand it right?

So why we use quality settings? I think that settings are used to achieve acceptable performance on slow systems and good quality on powerful systems.

@FernetMenta
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not supposed to be final but until we have a proper solution for changing resample ratio on the fly it is better than sound drop-outs.

@FernetMenta
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: the audio resample mode in dvdplayer has more flaws because it forces a resampler even if source rate matches destination rate. at beginning of a video there is always a slight discontinuity which the resampler then needs to correct. later it is not needed anymore but still around. also not good for quality.

Please sign in to comment.