summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVignesh Venkatasubramanian <vigneshv@google.com>2014-03-14 08:10:35 -0700
committerVignesh Venkatasubramanian <vigneshv@google.com>2014-03-14 14:44:47 -0700
commit0ffa3836f3ce24596c2101d50c3ac51f79963f92 (patch)
tree32dc663c7e2f4906a2786d65fe763ed1a7878332
parent1f08824d6db735e4cacb0419785a789395e42b2b (diff)
downloadlibvpx-0ffa3836f3ce24596c2101d50c3ac51f79963f92.tar.gz
libvpx-0ffa3836f3ce24596c2101d50c3ac51f79963f92.tar.bz2
libvpx-0ffa3836f3ce24596c2101d50c3ac51f79963f92.zip
Adding a configure flag to control WebM container support
Adding a --(enable|disable)-webm-io flag to control WebM container input and output support. For now, enabling WebM IO by default only when there is a C++ compiler. Doing so because eventually we will move WebM IO to libwebm and it is built using C++. Change-Id: I210ac36c23528e382ed41d3c4322291720481492
-rwxr-xr-xconfigure6
-rw-r--r--examples.mk28
-rw-r--r--vpxdec.c14
-rw-r--r--vpxenc.c32
4 files changed, 62 insertions, 18 deletions
diff --git a/configure b/configure
index d2f17b048..3ace61e8d 100755
--- a/configure
+++ b/configure
@@ -51,6 +51,7 @@ Advanced options:
${toggle_postproc_visualizer} macro block / block level visualizers
${toggle_multi_res_encoding} enable multiple-resolution encoding
${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser
+ ${toggle_webm_io} enable input from and output to WebM container
Codecs:
Codecs can be selectively enabled or disabled individually, or by family:
@@ -314,6 +315,7 @@ CONFIG_LIST="
postproc_visualizer
os_support
unit_tests
+ webm_io
decode_perf_tests
multi_res_encoding
temporal_denoising
@@ -367,6 +369,7 @@ CMDLINE_SELECT="
small
postproc_visualizer
unit_tests
+ webm_io
decode_perf_tests
multi_res_encoding
temporal_denoising
@@ -703,6 +706,9 @@ process_toolchain() {
enabled postproc || die "postproc_visualizer requires postproc to be enabled"
fi
+ # Enable WebM IO by default.
+ soft_enable webm_io
+
# Enable unit tests by default if we have a working C++ compiler.
case "$toolchain" in
*-vs*)
diff --git a/examples.mk b/examples.mk
index 5c6e42d31..5f70300f9 100644
--- a/examples.mk
+++ b/examples.mk
@@ -26,16 +26,18 @@ vpxdec.SRCS += vpx/vpx_integer.h
vpxdec.SRCS += args.c args.h
vpxdec.SRCS += ivfdec.c ivfdec.h
vpxdec.SRCS += tools_common.c tools_common.h
-vpxdec.SRCS += webmdec.c webmdec.h
vpxdec.SRCS += y4menc.c y4menc.h
-vpxdec.SRCS += third_party/nestegg/halloc/halloc.h
-vpxdec.SRCS += third_party/nestegg/halloc/src/align.h
-vpxdec.SRCS += third_party/nestegg/halloc/src/halloc.c
-vpxdec.SRCS += third_party/nestegg/halloc/src/hlist.h
-vpxdec.SRCS += third_party/nestegg/halloc/src/macros.h
-vpxdec.SRCS += third_party/nestegg/include/nestegg/nestegg.h
-vpxdec.SRCS += third_party/nestegg/src/nestegg.c
vpxdec.SRCS += $(LIBYUV_SRCS)
+ifeq ($(CONFIG_WEBM_IO),yes)
+ vpxdec.SRCS += third_party/nestegg/halloc/halloc.h
+ vpxdec.SRCS += third_party/nestegg/halloc/src/align.h
+ vpxdec.SRCS += third_party/nestegg/halloc/src/halloc.c
+ vpxdec.SRCS += third_party/nestegg/halloc/src/hlist.h
+ vpxdec.SRCS += third_party/nestegg/halloc/src/macros.h
+ vpxdec.SRCS += third_party/nestegg/include/nestegg/nestegg.h
+ vpxdec.SRCS += third_party/nestegg/src/nestegg.c
+ vpxdec.SRCS += webmdec.c webmdec.h
+endif
vpxdec.GUID = BA5FE66F-38DD-E034-F542-B1578C5FB950
vpxdec.DESCRIPTION = Full featured decoder
UTILS-$(CONFIG_ENCODERS) += vpxenc.c
@@ -45,15 +47,17 @@ vpxenc.SRCS += ivfenc.c ivfenc.h
vpxenc.SRCS += rate_hist.c rate_hist.h
vpxenc.SRCS += tools_common.c tools_common.h
vpxenc.SRCS += warnings.c warnings.h
-vpxenc.SRCS += webmenc.c webmenc.h
vpxenc.SRCS += vpx_ports/mem_ops.h
vpxenc.SRCS += vpx_ports/mem_ops_aligned.h
vpxenc.SRCS += vpx_ports/vpx_timer.h
vpxenc.SRCS += vpxstats.c vpxstats.h
-vpxenc.SRCS += third_party/libmkv/EbmlIDs.h
-vpxenc.SRCS += third_party/libmkv/EbmlWriter.c
-vpxenc.SRCS += third_party/libmkv/EbmlWriter.h
vpxenc.SRCS += $(LIBYUV_SRCS)
+ifeq ($(CONFIG_WEBM_IO),yes)
+ vpxenc.SRCS += third_party/libmkv/EbmlIDs.h
+ vpxenc.SRCS += third_party/libmkv/EbmlWriter.c
+ vpxenc.SRCS += third_party/libmkv/EbmlWriter.h
+ vpxenc.SRCS += webmenc.c webmenc.h
+endif
vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
vpxenc.DESCRIPTION = Full featured encoder
EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9_spatial_scalable_encoder.c
diff --git a/vpxdec.c b/vpxdec.c
index b69e55eeb..4c3723470 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -218,9 +218,11 @@ static int raw_read_frame(FILE *infile, uint8_t **buffer,
static int read_frame(struct VpxDecInputContext *input, uint8_t **buf,
size_t *bytes_in_buffer, size_t *buffer_size) {
switch (input->vpx_input_ctx->file_type) {
+#if CONFIG_WEBM_IO
case FILE_TYPE_WEBM:
return webm_read_frame(input->webm_ctx,
buf, bytes_in_buffer, buffer_size);
+#endif
case FILE_TYPE_RAW:
return raw_read_frame(input->vpx_input_ctx->file,
buf, bytes_in_buffer, buffer_size);
@@ -663,12 +665,17 @@ int main_loop(int argc, const char **argv_) {
input.vpx_input_ctx->file = infile;
if (file_is_ivf(input.vpx_input_ctx))
input.vpx_input_ctx->file_type = FILE_TYPE_IVF;
+#if CONFIG_WEBM_IO
else if (file_is_webm(input.webm_ctx, input.vpx_input_ctx))
input.vpx_input_ctx->file_type = FILE_TYPE_WEBM;
+#endif
else if (file_is_raw(input.vpx_input_ctx))
input.vpx_input_ctx->file_type = FILE_TYPE_RAW;
else {
fprintf(stderr, "Unrecognized input file type.\n");
+#if !CONFIG_WEBM_IO
+ fprintf(stderr, "vpxdec was built without WebM container support.\n");
+#endif
return EXIT_FAILURE;
}
@@ -691,6 +698,7 @@ int main_loop(int argc, const char **argv_) {
return EXIT_FAILURE;
}
+#if CONFIG_WEBM_IO
if (vpx_input_ctx.file_type == FILE_TYPE_WEBM) {
if (webm_guess_framerate(input.webm_ctx, input.vpx_input_ctx)) {
fprintf(stderr, "Failed to guess framerate -- error parsing "
@@ -698,6 +706,7 @@ int main_loop(int argc, const char **argv_) {
return EXIT_FAILURE;
}
}
+#endif
}
fourcc_interface = get_vpx_decoder_by_fourcc(vpx_input_ctx.fourcc);
@@ -941,9 +950,12 @@ fail:
}
}
+#if CONFIG_WEBM_IO
if (input.vpx_input_ctx->file_type == FILE_TYPE_WEBM)
webm_free(input.webm_ctx);
- else
+#endif
+
+ if (input.vpx_input_ctx->file_type != FILE_TYPE_WEBM)
free(buf);
if (scaled_img) vpx_img_free(scaled_img);
diff --git a/vpxenc.c b/vpxenc.c
index c61d83e41..1cd5e9232 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -123,6 +123,7 @@ int fourcc_is_ivf(const char detect[4]) {
return 0;
}
+#if CONFIG_WEBM_IO
/* Murmur hash derived from public domain reference implementation at
* http:// sites.google.com/site/murmurhash/
*/
@@ -169,7 +170,7 @@ static unsigned int murmur(const void *key, int len, unsigned int seed) {
return h;
}
-
+#endif // CONFIG_WEBM_IO
static const arg_def_t debugmode = ARG_DEF("D", "debug", 0,
"Debug mode (makes output deterministic)");
@@ -218,7 +219,7 @@ static const arg_def_t recontest = ARG_DEF_ENUM(NULL, "test-decode", 1,
static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1,
"Stream frame rate (rate/scale)");
static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0,
- "Output IVF (default is WebM)");
+ "Output IVF (default is WebM if WebM IO is enabled)");
static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0,
"Makes encoder output partitions. Requires IVF output!");
static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1,
@@ -834,7 +835,9 @@ static struct stream_state *new_stream(struct VpxEncoderConfig *global,
/* Initialize remaining stream parameters */
stream->config.stereo_fmt = STEREO_FORMAT_MONO;
stream->config.write_webm = 1;
+#if CONFIG_WEBM_IO
stream->ebml.last_pts_ms = -1;
+#endif
/* Allows removal of the application version from the EBML tags */
stream->ebml.debug = global->debug;
@@ -1143,13 +1146,17 @@ static void open_output_file(struct stream_state *stream,
if (stream->config.write_webm && fseek(stream->file, 0, SEEK_CUR))
fatal("WebM output to pipes not supported.");
+#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
stream->ebml.stream = stream->file;
write_webm_file_header(&stream->ebml, cfg,
&global->framerate,
stream->config.stereo_fmt,
global->codec->fourcc);
- } else {
+ }
+#endif
+
+ if (!stream->config.write_webm) {
ivf_write_file_header(stream->file, cfg, global->codec->fourcc, 0);
}
}
@@ -1162,11 +1169,15 @@ static void close_output_file(struct stream_state *stream,
if (cfg->g_pass == VPX_RC_FIRST_PASS)
return;
+#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
write_webm_file_footer(&stream->ebml, stream->hash);
free(stream->ebml.cue_list);
stream->ebml.cue_list = NULL;
- } else {
+ }
+#endif
+
+ if (!stream->config.write_webm) {
if (!fseek(stream->file, 0, SEEK_SET))
ivf_write_file_header(stream->file, &stream->config.cfg,
fourcc,
@@ -1316,6 +1327,7 @@ static void get_cx_data(struct stream_state *stream,
fprintf(stderr, " %6luF", (unsigned long)pkt->data.frame.sz);
update_rate_histogram(stream->rate_hist, cfg, pkt);
+#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
/* Update the hash */
if (!stream->ebml.debug)
@@ -1324,7 +1336,9 @@ static void get_cx_data(struct stream_state *stream,
stream->hash);
write_webm_block(&stream->ebml, cfg, pkt);
- } else {
+ }
+#endif
+ if (!stream->config.write_webm) {
if (pkt->data.frame.partition_id <= 0) {
ivf_header_pos = ftello(stream->file);
fsize = pkt->data.frame.sz;
@@ -1594,6 +1608,14 @@ int main(int argc, const char **argv_) {
" and --passes=2\n", stream->index, global.pass);
});
+#if !CONFIG_WEBM_IO
+ FOREACH_STREAM({
+ stream->config.write_webm = 0;
+ warn("vpxenc was compiled without WebM container support."
+ "Producing IVF output");
+ });
+#endif
+
/* Use the frame rate from the file only if none was specified
* on the command-line.
*/