mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
flv: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
ce5165f8ad
commit
53a132f0c5
@ -629,10 +629,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
|
|||||||
} else if (!strcmp(key, "audiosamplesize") && apar) {
|
} else if (!strcmp(key, "audiosamplesize") && apar) {
|
||||||
apar->bits_per_coded_sample = num_val;
|
apar->bits_per_coded_sample = num_val;
|
||||||
} else if (!strcmp(key, "stereo") && apar) {
|
} else if (!strcmp(key, "stereo") && apar) {
|
||||||
apar->channels = num_val + 1;
|
av_channel_layout_default(&apar->ch_layout, num_val + 1);
|
||||||
apar->channel_layout = apar->channels == 2 ?
|
|
||||||
AV_CH_LAYOUT_STEREO :
|
|
||||||
AV_CH_LAYOUT_MONO;
|
|
||||||
} else if (!strcmp(key, "width") && vpar) {
|
} else if (!strcmp(key, "width") && vpar) {
|
||||||
vpar->width = num_val;
|
vpar->width = num_val;
|
||||||
} else if (!strcmp(key, "height") && vpar) {
|
} else if (!strcmp(key, "height") && vpar) {
|
||||||
@ -1202,12 +1199,10 @@ retry_duration:
|
|||||||
sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
|
sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
|
||||||
FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
|
FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
|
||||||
bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
|
bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
|
||||||
if (!st->codecpar->channels || !st->codecpar->sample_rate ||
|
if (!av_channel_layout_check(&st->codecpar->ch_layout) ||
|
||||||
|
!st->codecpar->sample_rate ||
|
||||||
!st->codecpar->bits_per_coded_sample) {
|
!st->codecpar->bits_per_coded_sample) {
|
||||||
st->codecpar->channels = channels;
|
av_channel_layout_default(&st->codecpar->ch_layout, channels);
|
||||||
st->codecpar->channel_layout = channels == 1
|
|
||||||
? AV_CH_LAYOUT_MONO
|
|
||||||
: AV_CH_LAYOUT_STEREO;
|
|
||||||
st->codecpar->sample_rate = sample_rate;
|
st->codecpar->sample_rate = sample_rate;
|
||||||
st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
|
st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
|
||||||
}
|
}
|
||||||
@ -1217,7 +1212,7 @@ retry_duration:
|
|||||||
flv->last_sample_rate =
|
flv->last_sample_rate =
|
||||||
sample_rate = st->codecpar->sample_rate;
|
sample_rate = st->codecpar->sample_rate;
|
||||||
flv->last_channels =
|
flv->last_channels =
|
||||||
channels = st->codecpar->channels;
|
channels = st->codecpar->ch_layout.nb_channels;
|
||||||
} else {
|
} else {
|
||||||
AVCodecParameters *par = avcodec_parameters_alloc();
|
AVCodecParameters *par = avcodec_parameters_alloc();
|
||||||
if (!par) {
|
if (!par) {
|
||||||
|
@ -138,7 +138,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
|
|||||||
"FLV only supports wideband (16kHz) Speex audio\n");
|
"FLV only supports wideband (16kHz) Speex audio\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
if (par->channels != 1) {
|
if (par->ch_layout.nb_channels != 1) {
|
||||||
av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
|
av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ error:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par->channels > 1)
|
if (par->ch_layout.nb_channels > 1)
|
||||||
flags |= FLV_STEREO;
|
flags |= FLV_STEREO;
|
||||||
|
|
||||||
switch (par->codec_id) {
|
switch (par->codec_id) {
|
||||||
@ -342,7 +342,7 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
|
|||||||
put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
|
put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
|
||||||
|
|
||||||
put_amf_string(pb, "stereo");
|
put_amf_string(pb, "stereo");
|
||||||
put_amf_bool(pb, flv->audio_par->channels == 2);
|
put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
|
||||||
|
|
||||||
put_amf_string(pb, "audiocodecid");
|
put_amf_string(pb, "audiocodecid");
|
||||||
put_amf_double(pb, flv->audio_par->codec_tag);
|
put_amf_double(pb, flv->audio_par->codec_tag);
|
||||||
@ -507,8 +507,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i
|
|||||||
if (!par->extradata_size && (flv->flags & FLV_AAC_SEQ_HEADER_DETECT)) {
|
if (!par->extradata_size && (flv->flags & FLV_AAC_SEQ_HEADER_DETECT)) {
|
||||||
PutBitContext pbc;
|
PutBitContext pbc;
|
||||||
int samplerate_index;
|
int samplerate_index;
|
||||||
int channels = flv->audio_par->channels
|
int channels = flv->audio_par->ch_layout.nb_channels
|
||||||
- (flv->audio_par->channels == 8 ? 1 : 0);
|
- (flv->audio_par->ch_layout.nb_channels == 8 ? 1 : 0);
|
||||||
uint8_t data[2];
|
uint8_t data[2];
|
||||||
|
|
||||||
for (samplerate_index = 0; samplerate_index < 16;
|
for (samplerate_index = 0; samplerate_index < 16;
|
||||||
|
Loading…
Reference in New Issue
Block a user