[FFmpeg-cvslog] ffplay: remove redundant silence buffer
Lukasz Marek
git at videolan.org
Tue Mar 22 00:10:28 CET 2016
ffmpeg | branch: master | Lukasz Marek <lukasz.m.luki2 at gmail.com> | Thu Mar 17 18:26:09 2016 +0100| [df34b700981de606ca4847e1ed0bfdf9ac3e9104] | committer: Lukasz Marek
ffplay: remove redundant silence buffer
Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df34b700981de606ca4847e1ed0bfdf9ac3e9104
---
ffplay.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index ade5159..aab03d1 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -243,7 +243,6 @@ typedef struct VideoState {
AVStream *audio_st;
PacketQueue audioq;
int audio_hw_buf_size;
- uint8_t silence_buf[SDL_AUDIO_MIN_BUFFER_SIZE];
uint8_t *audio_buf;
uint8_t *audio_buf1;
unsigned int audio_buf_size; /* in bytes */
@@ -2532,7 +2531,7 @@ static int audio_decode_frame(VideoState *is)
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
VideoState *is = opaque;
- int audio_size, len1;
+ int audio_size, len1, silence = 0;
audio_callback_time = av_gettime_relative();
@@ -2541,8 +2540,8 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
audio_size = audio_decode_frame(is);
if (audio_size < 0) {
/* if error, just output silence */
- is->audio_buf = is->silence_buf;
- is->audio_buf_size = sizeof(is->silence_buf) / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
+ silence = 1;
+ is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
@@ -2553,11 +2552,11 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
- if (!is->muted && is->audio_volume == SDL_MIX_MAXVOLUME)
+ if (!is->muted && !silence && is->audio_volume == SDL_MIX_MAXVOLUME)
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
else {
- memset(stream, is->silence_buf[0], len1);
- if (!is->muted)
+ memset(stream, 0, len1);
+ if (!is->muted && !silence)
SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
}
len -= len1;
More information about the ffmpeg-cvslog
mailing list