[x265-commits] [x265] encoder: do not allow encode to continue if check failure...

Steve Borho steve at borho.org
Sat Feb 14 05:12:09 CET 2015


details:   http://hg.videolan.org/x265/rev/14dcdf7596d8
branches:  
changeset: 9349:14dcdf7596d8
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 13 12:46:56 2015 -0600
description:
encoder: do not allow encode to continue if check failure has occurred

In general, we will either output invalid bitstreams or crash if we continue to
run after one of these internal check failures. They usually indicate a serious
bug or memory alignment problem.

diffstat:

 source/common/common.cpp   |  4 ++++
 source/common/common.h     |  3 ++-
 source/encoder/encoder.cpp |  7 +++++++
 3 files changed, 13 insertions(+), 1 deletions(-)

diffs (46 lines):

diff -r 9ab104096834 -r 14dcdf7596d8 source/common/common.cpp
--- a/source/common/common.cpp	Wed Feb 11 16:15:33 2015 -0600
+++ b/source/common/common.cpp	Fri Feb 13 12:46:56 2015 -0600
@@ -33,6 +33,10 @@
 #include <sys/time.h>
 #endif
 
+#if CHECKED_BUILD || _DEBUG
+int g_checkFailures;
+#endif
+
 int64_t x265_mdate(void)
 {
 #if _WIN32
diff -r 9ab104096834 -r 14dcdf7596d8 source/common/common.h
--- a/source/common/common.h	Wed Feb 11 16:15:33 2015 -0600
+++ b/source/common/common.h	Fri Feb 13 12:46:56 2015 -0600
@@ -114,9 +114,10 @@ extern "C" intptr_t x265_stack_align(voi
 /* If compiled with CHECKED_BUILD perform run-time checks and log any that
  * fail, both to stderr and to a file */
 #if CHECKED_BUILD || _DEBUG
+extern int g_checkFailures;
 #define X265_CHECK(expr, ...) if (!(expr)) { \
     x265_log(NULL, X265_LOG_ERROR, __VA_ARGS__); \
-    DEBUG_BREAK(); \
+    DEBUG_BREAK(); g_checkFailures++; \
     FILE *fp = fopen("x265_check_failures.txt", "a"); \
     if (fp) { fprintf(fp, "%s:%d\n", __FILE__, __LINE__); fprintf(fp, __VA_ARGS__); fclose(fp); } \
 }
diff -r 9ab104096834 -r 14dcdf7596d8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Feb 11 16:15:33 2015 -0600
+++ b/source/encoder/encoder.cpp	Fri Feb 13 12:46:56 2015 -0600
@@ -365,6 +365,13 @@ void Encoder::updateVbvPlan(RateControl*
  *         negative on malloc error or abort */
 int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)
 {
+#if CHECKED_BUILD || _DEBUG
+    if (g_checkFailures)
+    {
+        x265_log(m_param, X265_LOG_ERROR, "encoder aborting because of internal error\n");
+        return -1;
+    }
+#endif
     if (m_aborted)
         return -1;
 


More information about the x265-commits mailing list