Browse code

ffplay: factorize expression in audio_decode_frame()

Possibly improve readability.

Stefano Sabatini authored on 2012/06/30 07:02:58
Showing 1 changed files
... ...
@@ -1985,6 +1985,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
1985 1985
             if (is->swr_ctx) {
1986 1986
                 const uint8_t *in[] = { is->frame->data[0] };
1987 1987
                 uint8_t *out[] = {is->audio_buf2};
1988
+                int out_count = sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt);
1988 1989
                 if (wanted_nb_samples != is->frame->nb_samples) {
1989 1990
                     if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / dec->sample_rate,
1990 1991
                                                 wanted_nb_samples * is->audio_tgt.freq / dec->sample_rate) < 0) {
... ...
@@ -1992,13 +1993,12 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
1992 1992
                         break;
1993 1993
                     }
1994 1994
                 }
1995
-                len2 = swr_convert(is->swr_ctx, out, sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt),
1996
-                                                in, is->frame->nb_samples);
1995
+                len2 = swr_convert(is->swr_ctx, out, out_count, in, is->frame->nb_samples);
1997 1996
                 if (len2 < 0) {
1998 1997
                     fprintf(stderr, "swr_convert() failed\n");
1999 1998
                     break;
2000 1999
                 }
2001
-                if (len2 == sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt)) {
2000
+                if (len2 == out_count) {
2002 2001
                     fprintf(stderr, "warning: audio buffer is probably too small\n");
2003 2002
                     swr_init(is->swr_ctx);
2004 2003
                 }