[FFmpeg-cvslog] libkvazaar: Replace asserts with proper errors

Arttu Ylä-Outinen git at videolan.org
Wed Oct 7 16:24:08 CEST 2015


ffmpeg | branch: master | Arttu Ylä-Outinen <arttu.yla-outinen at tut.fi> | Mon Sep 28 11:08:19 2015 +0300| [c09419ca80f1b1de4ceb3b9c06f708914150fa45] | committer: Arttu Ylä-Outinen

libkvazaar: Replace asserts with proper errors

Changes function libkvazaar_encode to return proper error codes instead
of crashing when the video dimensions or pixel format change in the
middle of encoding.

Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outinen at tut.fi>

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

 libavcodec/libkvazaar.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index aaaf1f7..a15700a 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -26,6 +26,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 
@@ -149,9 +150,26 @@ static int libkvazaar_encode(AVCodecContext *avctx,
     if (frame) {
         int i = 0;
 
-        av_assert0(frame->width == ctx->config->width);
-        av_assert0(frame->height == ctx->config->height);
-        av_assert0(frame->format == avctx->pix_fmt);
+        if (frame->width != ctx->config->width ||
+                frame->height != ctx->config->height) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "Changing video dimensions during encoding is not supported. "
+                   "(changed from %dx%d to %dx%d)\n",
+                   ctx->config->width, ctx->config->height,
+                   frame->width, frame->height);
+            retval = AVERROR_INVALIDDATA;
+            goto done;
+        }
+
+        if (frame->format != avctx->pix_fmt) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "Changing pixel format during encoding is not supported. "
+                   "(changed from %s to %s)\n",
+                   av_get_pix_fmt_name(avctx->pix_fmt),
+                   av_get_pix_fmt_name(frame->format));
+            retval = AVERROR_INVALIDDATA;
+            goto done;
+        }
 
         // Allocate input picture for kvazaar.
         img_in = ctx->api->picture_alloc(frame->width, frame->height);



More information about the ffmpeg-cvslog mailing list