mirror of https://github.com/mpv-player/mpv
ad_lavc: switch to AVChannelLayout when available
This commit is contained in:
parent
e7483ced5d
commit
edfd17ab18
|
@ -26,8 +26,11 @@
|
||||||
#include <libavutil/common.h>
|
#include <libavutil/common.h>
|
||||||
#include <libavutil/intreadwrite.h>
|
#include <libavutil/intreadwrite.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "mpv_talloc.h"
|
#include "mpv_talloc.h"
|
||||||
#include "audio/aframe.h"
|
#include "audio/aframe.h"
|
||||||
|
#include "audio/chmap_avchannel.h"
|
||||||
#include "audio/fmt-conversion.h"
|
#include "audio/fmt-conversion.h"
|
||||||
#include "common/av_common.h"
|
#include "common/av_common.h"
|
||||||
#include "common/codecs.h"
|
#include "common/codecs.h"
|
||||||
|
@ -106,8 +109,22 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec,
|
||||||
lavc_context->pkt_timebase = ctx->codec_timebase;
|
lavc_context->pkt_timebase = ctx->codec_timebase;
|
||||||
|
|
||||||
if (opts->downmix && mpopts->audio_output_channels.num_chmaps == 1) {
|
if (opts->downmix && mpopts->audio_output_channels.num_chmaps == 1) {
|
||||||
|
const struct mp_chmap *requested_layout =
|
||||||
|
&mpopts->audio_output_channels.chmaps[0];
|
||||||
|
#if !HAVE_AV_CHANNEL_LAYOUT
|
||||||
lavc_context->request_channel_layout =
|
lavc_context->request_channel_layout =
|
||||||
mp_chmap_to_lavc(&mpopts->audio_output_channels.chmaps[0]);
|
mp_chmap_to_lavc(requested_layout);
|
||||||
|
#else
|
||||||
|
AVChannelLayout av_layout = { 0 };
|
||||||
|
mp_chmap_to_av_layout(&av_layout, requested_layout);
|
||||||
|
|
||||||
|
// Always try to set requested output layout - currently only something
|
||||||
|
// supported by AC3, MLP/TrueHD, DTS and the fdk-aac wrapper.
|
||||||
|
av_opt_set_chlayout(lavc_context, "downmix", &av_layout,
|
||||||
|
AV_OPT_SEARCH_CHILDREN);
|
||||||
|
|
||||||
|
av_channel_layout_uninit(&av_layout);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always try to set - option only exists for AC3 at the moment
|
// Always try to set - option only exists for AC3 at the moment
|
||||||
|
|
Loading…
Reference in New Issue