[FFmpeg-cvslog] Add silence support for AV_SAMPLE_FMT_U8.

Alex Converse git at videolan.org
Wed Apr 6 03:04:07 CEST 2011


ffmpeg | branch: master | Alex Converse <aconverse at google.com> | Mon Apr  4 16:07:23 2011 -0700| [14cf0fd2f586471fff4ee379739a5734f568af11] | committer: Anton Khirnov

Add silence support for AV_SAMPLE_FMT_U8.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14cf0fd2f586471fff4ee379739a5734f568af11
---

 ffmpeg.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5e50db3..1f7b887 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1390,6 +1390,14 @@ static void print_report(AVFormatContext **output_files,
     }
 }
 
+static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)
+{
+    int fill_char = 0x00;
+    if (sample_fmt == AV_SAMPLE_FMT_U8)
+        fill_char = 0x80;
+    memset(buf, fill_char, size);
+}
+
 /* pkt = NULL means EOF (needed to flush decoder buffers) */
 static int output_packet(AVInputStream *ist, int ist_index,
                          AVOutputStream **ost_table, int nb_ostreams,
@@ -1732,7 +1740,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
                                     int frame_bytes = enc->frame_size*osize*enc->channels;
                                     if (allocated_audio_buf_size < frame_bytes)
                                         ffmpeg_exit(1);
-                                    memset(audio_buf+fifo_bytes, 0, frame_bytes - fifo_bytes);
+                                    generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes);
                                 }
 
                                 ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf);



More information about the ffmpeg-cvslog mailing list