mirror of
https://github.com/libretro/RetroArch.git
synced 2024-05-20 05:20:19 -04:00
Compare commits
2 commits
e0024e6401
...
8bf3b170a1
Author | SHA1 | Date | |
---|---|---|---|
8bf3b170a1 | |||
4a1047151c |
|
@ -65,6 +65,8 @@ extern "C" {
|
|||
s ##_version() >> 8 & 0xFF, \
|
||||
s ##_version() & 0xFF);
|
||||
|
||||
#define HAVE_CH_LAYOUT (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
||||
|
||||
static bool reset_triggered;
|
||||
static bool libretro_supports_bitmasks = false;
|
||||
|
||||
|
@ -1726,8 +1728,14 @@ static void decode_thread(void *data)
|
|||
{
|
||||
swr[i] = swr_alloc();
|
||||
|
||||
#if HAVE_CH_LAYOUT
|
||||
AVChannelLayout out_chlayout = AV_CHANNEL_LAYOUT_STEREO;
|
||||
av_opt_set_chlayout(swr[i], "in_chlayout", &actx[i]->ch_layout, 0);
|
||||
av_opt_set_chlayout(swr[i], "out_chlayout", &out_chlayout, 0);
|
||||
#else
|
||||
av_opt_set_int(swr[i], "in_channel_layout", actx[i]->channel_layout, 0);
|
||||
av_opt_set_int(swr[i], "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
|
||||
#endif
|
||||
av_opt_set_int(swr[i], "in_sample_rate", actx[i]->sample_rate, 0);
|
||||
av_opt_set_int(swr[i], "out_sample_rate", media.sample_rate, 0);
|
||||
av_opt_set_int(swr[i], "in_sample_fmt", actx[i]->sample_fmt, 0);
|
||||
|
|
|
@ -70,6 +70,7 @@ extern "C" {
|
|||
#include "../../verbosity.h"
|
||||
|
||||
#define FFMPEG3 (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100))
|
||||
#define HAVE_CH_LAYOUT (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
||||
|
||||
struct ff_video_info
|
||||
{
|
||||
|
@ -301,9 +302,15 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle, const char *audio_resampler)
|
|||
audio->codec = avcodec_alloc_context3(codec);
|
||||
|
||||
audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
#if HAVE_CH_LAYOUT
|
||||
audio->codec->ch_layout = (param->channels > 1)
|
||||
? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO
|
||||
: (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||
#else
|
||||
audio->codec->channels = param->channels;
|
||||
audio->codec->channel_layout = (param->channels > 1)
|
||||
? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
#endif
|
||||
|
||||
ffmpeg_audio_resolve_format(audio, codec);
|
||||
ffmpeg_audio_resolve_sample_rate(handle, codec);
|
||||
|
@ -351,9 +358,15 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle, const char *audio_resampler)
|
|||
if (!audio->codec->frame_size)
|
||||
audio->codec->frame_size = 1024;
|
||||
|
||||
#if HAVE_CH_LAYOUT
|
||||
int nb_channels = audio->codec->ch_layout.nb_channels;
|
||||
#else
|
||||
int nb_channels = audio->codec->channels;
|
||||
#endif
|
||||
|
||||
audio->buffer = (uint8_t*)av_malloc(
|
||||
audio->codec->frame_size *
|
||||
audio->codec->channels *
|
||||
nb_channels *
|
||||
audio->sample_size);
|
||||
|
||||
if (!audio->buffer)
|
||||
|
@ -1342,20 +1355,30 @@ static bool encode_audio(ffmpeg_t *handle, bool dry)
|
|||
|
||||
frame->nb_samples = handle->audio.frames_in_buffer;
|
||||
frame->format = handle->audio.codec->sample_fmt;
|
||||
#if HAVE_CH_LAYOUT
|
||||
av_channel_layout_copy(&frame->ch_layout, &handle->audio.codec->ch_layout);
|
||||
#else
|
||||
frame->channel_layout = handle->audio.codec->channel_layout;
|
||||
#endif
|
||||
frame->pts = handle->audio.frame_cnt;
|
||||
|
||||
planarize_audio(handle);
|
||||
|
||||
#if HAVE_CH_LAYOUT
|
||||
int nb_channels = handle->audio.codec->ch_layout.nb_channels;
|
||||
#else
|
||||
int nb_channels = handle->audio.codec->channels;
|
||||
#endif
|
||||
|
||||
samples_size = av_samples_get_buffer_size(
|
||||
NULL,
|
||||
handle->audio.codec->channels,
|
||||
nb_channels,
|
||||
handle->audio.frames_in_buffer,
|
||||
handle->audio.codec->sample_fmt, 0);
|
||||
|
||||
av_frame_get_buffer(frame, 0);
|
||||
avcodec_fill_audio_frame(frame,
|
||||
handle->audio.codec->channels,
|
||||
nb_channels,
|
||||
handle->audio.codec->sample_fmt,
|
||||
handle->audio.is_planar
|
||||
? (uint8_t*)handle->audio.planar_buf :
|
||||
|
|
Loading…
Reference in a new issue