Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-01-17 19:42:13 +0300
committerJames Almer <jamrial@gmail.com>2022-03-15 15:42:34 +0300
commit51c2c6ff597b4a138356e3c9116e6c2eee6cf1bb (patch)
tree5a4b1f5e02b8031824d6c52d6669fcb70f3b925c /libavformat/libopenmpt.c
parenteac3a902a4472270556c9fbd917ca8669603715c (diff)
libopenmpt: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/libopenmpt.c')
-rw-r--r--libavformat/libopenmpt.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index 8006c085df..3ca59f506f 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -40,11 +40,10 @@ typedef struct OpenMPTContext {
const AVClass *class;
openmpt_module *module;
- int channels;
double duration;
/* options */
int sample_rate;
- int64_t layout;
+ AVChannelLayout ch_layout;
int subsong;
} OpenMPTContext;
@@ -53,7 +52,7 @@ typedef struct OpenMPTContext {
#define D AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 48000 }, 1000, INT_MAX, A | D },
- { "layout", "set channel layout", OFFSET(layout), AV_OPT_TYPE_CHANNEL_LAYOUT, { .i64 = AV_CH_LAYOUT_STEREO }, 0, INT64_MAX, A | D },
+ { "layout", "set channel layout", OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, { .str = "stereo" }, 0, 0, A | D },
{ "subsong", "set subsong", OFFSET(subsong), AV_OPT_TYPE_INT, { .i64 = -2 }, -2, INT_MAX, A | D, "subsong"},
{ "all", "all", 0, AV_OPT_TYPE_CONST, { .i64 = -1}, 0, 0, A | D, "subsong" },
{ "auto", "auto", 0, AV_OPT_TYPE_CONST, { .i64 = -2}, 0, 0, A | D, "subsong" },
@@ -120,8 +119,6 @@ static int read_header_openmpt(AVFormatContext *s)
return AVERROR_INVALIDDATA;
#endif
- openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
-
if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
av_log(s, AV_LOG_ERROR, "Invalid subsong index: %d\n", openmpt->subsong);
return AVERROR(EINVAL);
@@ -154,8 +151,10 @@ static int read_header_openmpt(AVFormatContext *s)
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_F32BE, AV_CODEC_ID_PCM_F32LE);
- st->codecpar->channels = openmpt->channels;
st->codecpar->sample_rate = openmpt->sample_rate;
+ ret = av_channel_layout_copy(&st->codecpar->ch_layout, &openmpt->ch_layout);
+ if (ret < 0)
+ return ret;
return 0;
}
@@ -165,13 +164,13 @@ static int read_header_openmpt(AVFormatContext *s)
static int read_packet_openmpt(AVFormatContext *s, AVPacket *pkt)
{
OpenMPTContext *openmpt = s->priv_data;
- int n_samples = AUDIO_PKT_SIZE / (openmpt->channels ? openmpt->channels*4 : 4);
+ int n_samples = AUDIO_PKT_SIZE / (openmpt->ch_layout.nb_channels ? openmpt->ch_layout.nb_channels*4 : 4);
int ret;
if ((ret = av_new_packet(pkt, AUDIO_PKT_SIZE)) < 0)
return ret;
- switch (openmpt->channels) {
+ switch (openmpt->ch_layout.nb_channels) {
case 1:
ret = openmpt_module_read_float_mono(openmpt->module, openmpt->sample_rate,
n_samples, (float *)pkt->data);
@@ -185,7 +184,7 @@ static int read_packet_openmpt(AVFormatContext *s, AVPacket *pkt)
n_samples, (float *)pkt->data);
break;
default:
- av_log(s, AV_LOG_ERROR, "Unsupported number of channels: %d", openmpt->channels);
+ av_log(s, AV_LOG_ERROR, "Unsupported number of channels: %d", openmpt->ch_layout.nb_channels);
return AVERROR(EINVAL);
}
@@ -194,7 +193,7 @@ static int read_packet_openmpt(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
}
- pkt->size = ret * (openmpt->channels * 4);
+ pkt->size = ret * (openmpt->ch_layout.nb_channels * 4);
return 0;
}