Add experimental config flag for ivf file parsing.
BUG=aomedia:3101
Change-Id: Ib9efad2af3d8667b669a1c743dd2f1a7467ceef6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7bedab..ae7d68d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,9 @@
set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
-include("${AOM_ROOT}/common/ivf_dec.cmake")
+if(CONFIG_THREE_PASS)
+ include("${AOM_ROOT}/common/ivf_dec.cmake")
+endif()
include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
@@ -301,7 +303,9 @@
endif()
# Setup dependencies.
-setup_ivf_dec_targets()
+if(CONFIG_THREE_PASS)
+ setup_ivf_dec_targets()
+endif()
setup_aom_dsp_targets()
setup_aom_mem_targets()
setup_aom_ports_targets()
diff --git a/av1/encoder/thirdpass.c b/av1/encoder/thirdpass.c
index 53374bb..1647758 100644
--- a/av1/encoder/thirdpass.c
+++ b/av1/encoder/thirdpass.c
@@ -16,8 +16,12 @@
#include "av1/encoder/firstpass.h"
#include "av1/encoder/thirdpass.h"
#include "av1/common/blockd.h"
-#include "common/ivfdec.h"
+#if CONFIG_THREE_PASS
+#include "common/ivfdec.h"
+#endif
+
+#if CONFIG_THREE_PASS
static void setup_two_pass_stream_input(
struct AvxInputContext **input_ctx_ptr, const char *input_file_name,
struct aom_internal_error_info *err_info) {
@@ -72,11 +76,13 @@
"with CONFIG_AV1_DECODER=1.");
#endif
}
+#endif // CONFIG_THREE_PASS
// Return 0: success
// 1: cannot read because this is end of file
// -1: failure to read the frame
static int read_frame(THIRD_PASS_DEC_CTX *ctx) {
+#if CONFIG_THREE_PASS
if (!ctx->input_ctx || !ctx->decoder.iface) {
init_third_pass(ctx);
}
@@ -93,6 +99,10 @@
ctx->end_frame = ctx->frame + ctx->bytes_in_buffer;
ctx->have_frame = 1;
}
+#else
+ aom_internal_error(ctx->err_info, AOM_CODEC_ERROR,
+ "Cannot parse bitstream without CONFIG_THREE_PASS.");
+#endif
Av1DecodeReturn adr;
if (aom_codec_decode(&ctx->decoder, ctx->frame,
(unsigned int)ctx->bytes_in_buffer,
@@ -283,8 +293,10 @@
if (ctx->decoder.iface) {
aom_codec_destroy(&ctx->decoder);
}
+#if CONFIG_THREE_PASS
if (ctx->input_ctx && ctx->input_ctx->file) fclose(ctx->input_ctx->file);
aom_free(ctx->input_ctx);
+#endif
if (ctx->buf) free(ctx->buf);
aom_free(ctx);
}
diff --git a/av1/encoder/thirdpass.h b/av1/encoder/thirdpass.h
index a081c79..4c80585 100644
--- a/av1/encoder/thirdpass.h
+++ b/av1/encoder/thirdpass.h
@@ -36,8 +36,10 @@
/* --- Input and decoding related members --- */
// the input file
const char *input_file_name;
+#if CONFIG_THREE_PASS
// input context
struct AvxInputContext *input_ctx;
+#endif
// decoder codec context
aom_codec_ctx_t decoder;
// start of the frame in buf
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 32760c5..4e851a0 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -153,6 +153,8 @@
"AV1 experiment with alternative partition search order.")
set_aom_config_var(CONFIG_BITRATE_ACCURACY 0
"AV1 experiment to improve bitrate accuracy.")
+set_aom_config_var(CONFIG_THREE_PASS 0
+ "AV1 experiment: Enable three-pass encoding.")
#
# Variables in this section control optional features of the build system.