[x265] [PATCH] encoder: do not allow encode to continue if check failure has occurred
Steve Borho
steve at borho.org
Fri Feb 13 19:47:08 CET 2015
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1423853216 21600
# Fri Feb 13 12:46:56 2015 -0600
# Node ID 14dcdf7596d8b0e1a8189a9d2b65209a9e6b296d
# Parent 9ab104096834f51bd799ea1cf1160092f8182944
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.
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 @@
/* 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 @@
* 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-devel
mailing list