aboutsummaryrefslogtreecommitdiffstats
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-13 16:45:01 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-13 16:47:50 +0200
commitd0707677fa50f7d75a945e234287a4661962c851 (patch)
tree468e706ef8e800e86ec3e1cdb3a6b48152e1acac /ffplay.c
parent15ef1cfe6431179fb1cd5707b360a7d6d6bdb9d9 (diff)
downloadffmpeg-d0707677fa50f7d75a945e234287a4661962c851.tar.gz
ffplay: use audio parameters from the decoded frame instead of AVCodecContext
Based on commit by Justin Ruggles (the changed code is too different to apply as is) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/ffplay.c b/ffplay.c
index 438c11d17b..5a2c7728fc 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1974,34 +1974,34 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
flush_complete = 1;
continue;
}
- data_size = av_samples_get_buffer_size(NULL, dec->channels,
+ data_size = av_samples_get_buffer_size(NULL, is->frame->channels,
is->frame->nb_samples,
- dec->sample_fmt, 1);
+ is->frame->format, 1);
dec_channel_layout =
- (dec->channel_layout && dec->channels == av_get_channel_layout_nb_channels(dec->channel_layout)) ?
- dec->channel_layout : av_get_default_channel_layout(dec->channels);
+ (is->frame->channel_layout && is->frame->channels == av_get_channel_layout_nb_channels(is->frame->channel_layout)) ?
+ is->frame->channel_layout : av_get_default_channel_layout(is->frame->channels);
wanted_nb_samples = synchronize_audio(is, is->frame->nb_samples);
- if (dec->sample_fmt != is->audio_src.fmt ||
- dec_channel_layout != is->audio_src.channel_layout ||
- dec->sample_rate != is->audio_src.freq ||
- (wanted_nb_samples != is->frame->nb_samples && !is->swr_ctx)) {
+ if (is->frame->format != is->audio_src.fmt ||
+ dec_channel_layout != is->audio_src.channel_layout ||
+ is->frame->sample_rate != is->audio_src.freq ||
+ (wanted_nb_samples != is->frame->nb_samples && !is->swr_ctx)) {
swr_free(&is->swr_ctx);
is->swr_ctx = swr_alloc_set_opts(NULL,
is->audio_tgt.channel_layout, is->audio_tgt.fmt, is->audio_tgt.freq,
- dec_channel_layout, dec->sample_fmt, dec->sample_rate,
+ dec_channel_layout, is->frame->format, is->frame->sample_rate,
0, NULL);
if (!is->swr_ctx || swr_init(is->swr_ctx) < 0) {
fprintf(stderr, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n",
- dec->sample_rate, av_get_sample_fmt_name(dec->sample_fmt), dec->channels,
+ is->frame->sample_rate, av_get_sample_fmt_name(is->frame->format), (int)is->frame->channels,
is->audio_tgt.freq, av_get_sample_fmt_name(is->audio_tgt.fmt), is->audio_tgt.channels);
break;
}
is->audio_src.channel_layout = dec_channel_layout;
- is->audio_src.channels = dec->channels;
- is->audio_src.freq = dec->sample_rate;
- is->audio_src.fmt = dec->sample_fmt;
+ is->audio_src.channels = is->frame->channels;
+ is->audio_src.freq = is->frame->sample_rate;
+ is->audio_src.fmt = is->frame->format;
}
if (is->swr_ctx) {
@@ -2009,8 +2009,8 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
uint8_t *out[] = {is->audio_buf2};
int out_count = sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt);
if (wanted_nb_samples != is->frame->nb_samples) {
- if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / dec->sample_rate,
- wanted_nb_samples * is->audio_tgt.freq / dec->sample_rate) < 0) {
+ if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate,
+ wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) {
fprintf(stderr, "swr_set_compensation() failed\n");
break;
}
@@ -2035,7 +2035,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
pts = is->audio_clock;
*pts_ptr = pts;
is->audio_clock += (double)data_size /
- (dec->channels * dec->sample_rate * av_get_bytes_per_sample(dec->sample_fmt));
+ (is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format));
#ifdef DEBUG
{
static double last_clock;