]> granicus.if.org Git - libvpx/commitdiff
Removing pass number check from ivf_write_file_header().
authorDmitry Kovalev <dkovalev@google.com>
Mon, 13 Jan 2014 23:21:48 +0000 (15:21 -0800)
committerDmitry Kovalev <dkovalev@google.com>
Mon, 13 Jan 2014 23:21:48 +0000 (15:21 -0800)
Putting appropriate check to open_output_file() and close_output_file().
Before that the output file has been opened twice during two-pass encoding.

Change-Id: I290cecf00513d6a31ca3f45bc20fef7efcb10190

ivfenc.c
vpxenc.c

index fa92566f8cc6d4d62a04a5d1723136efe78eb803..611d6676fef4621350c0931be401f7d8a5626d22 100644 (file)
--- a/ivfenc.c
+++ b/ivfenc.c
@@ -20,9 +20,6 @@ void ivf_write_file_header(FILE *outfile,
                            int frame_cnt) {
   char header[32];
 
-  if (cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
-    return;
-
   header[0] = 'D';
   header[1] = 'K';
   header[2] = 'I';
index 4c933ce6f7e5d25f6e114c820244d6b9e2021e45..91a155cf632032d216cb164d81b1104651d6ccfa 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1393,6 +1393,10 @@ static void show_stream_config(struct stream_state *stream,
 static void open_output_file(struct stream_state *stream,
                              struct VpxEncoderConfig *global) {
   const char *fn = stream->config.out_fn;
+  const struct vpx_codec_enc_cfg *const cfg = &stream->config.cfg;
+
+  if (cfg->g_pass == VPX_RC_FIRST_PASS)
+    return;
 
   stream->file = strcmp(fn, "-") ? fopen(fn, "wb") : set_binary_mode(stdout);
 
@@ -1404,18 +1408,23 @@ static void open_output_file(struct stream_state *stream,
 
   if (stream->config.write_webm) {
     stream->ebml.stream = stream->file;
-    write_webm_file_header(&stream->ebml, &stream->config.cfg,
+    write_webm_file_header(&stream->ebml, cfg,
                            &global->framerate,
                            stream->config.stereo_fmt,
                            global->codec->fourcc);
-  } else
-    ivf_write_file_header(stream->file, &stream->config.cfg,
-                          global->codec->fourcc, 0);
+  } else {
+    ivf_write_file_header(stream->file, cfg, global->codec->fourcc, 0);
+  }
 }
 
 
 static void close_output_file(struct stream_state *stream,
-                              unsigned int         fourcc) {
+                              unsigned int fourcc) {
+  const struct vpx_codec_enc_cfg *const cfg = &stream->config.cfg;
+
+  if (cfg->g_pass == VPX_RC_FIRST_PASS)
+    return;
+
   if (stream->config.write_webm) {
     write_webm_file_footer(&stream->ebml, stream->hash);
     free(stream->ebml.cue_list);