[FFmpeg-cvslog] Exit ffmpeg if swr_convert() fails.

Carl Eugen Hoyos git at videolan.org
Mon Feb 27 22:23:33 CET 2012


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Mon Feb 27 19:01:53 2012 +0100| [7b4e1466d4cb9283facd874fa109b6b3389b67e2] | committer: Carl Eugen Hoyos

Exit ffmpeg if swr_convert() fails.

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

 ffmpeg.c                   |    4 ++++
 libswresample/swresample.h |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index c907201..4bdca88 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1267,6 +1267,10 @@ need_realloc:
         buftmp = audio_buf;
         size_out = swr_convert(ost->swr, (      uint8_t*[]){buftmp}, audio_buf_size / (enc->channels * osize),
                                          (const uint8_t*[]){buf   }, size / (dec->channels * isize));
+        if (size_out < 0) {
+            av_log(NULL, AV_LOG_FATAL, "swr_convert failed\n");
+            exit_program(1);
+        }
         size_out = size_out * enc->channels * osize;
     } else {
         buftmp = buf;
diff --git a/libswresample/swresample.h b/libswresample/swresample.h
index 4a3f451..50f2910 100644
--- a/libswresample/swresample.h
+++ b/libswresample/swresample.h
@@ -106,7 +106,7 @@ void swr_free(struct SwrContext **s);
  * @param in        input buffers, only the first one need to be set in case of packed audio
  * @param in_count  number of input samples available in one channel
  *
- * @return number of samples output per channel
+ * @return number of samples output per channel, negative value on error
  */
 int swr_convert(struct SwrContext *s, uint8_t *out[SWR_CH_MAX], int out_count,
                                 const uint8_t *in [SWR_CH_MAX], int in_count);



More information about the ffmpeg-cvslog mailing list