shithub: libvpx

Download patch

ref: 7900c80e5aa44099ed4f1f8d3f9565a89695cc14
parent: 166d8142ac5a68a5e5a8646029c8beb796b3b99c
parent: 64b89f1b4b1c0ee17524672962288a69b45d769c
author: Alex Converse <aconverse@google.com>
date: Mon Jan 6 12:22:21 EST 2014

Merge "Fix encoding Raw yv12 and i420 from a pipe."

--- a/ivfdec.c
+++ b/ivfdec.c
@@ -17,11 +17,6 @@
   char raw_hdr[32];
   int is_ivf = 0;
 
-  // TODO(tomfinegan): This can eventually go away, but for now it's required
-  // because the means by which file types are detected differ in vpxdec and
-  // vpxenc.
-  rewind(input_ctx->file);
-
   if (fread(raw_hdr, 1, 32, input_ctx->file) == 32) {
     if (raw_hdr[0] == 'D' && raw_hdr[1] == 'K' &&
         raw_hdr[2] == 'I' && raw_hdr[3] == 'F') {
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -26,7 +26,6 @@
 
 #include "third_party/libyuv/include/libyuv/scale.h"
 #include "./args.h"
-#include "./ivfdec.h"
 #include "./ivfenc.h"
 
 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
@@ -126,7 +125,7 @@
   return !shortread;
 }
 
-int file_is_y4m(FILE *infile, y4m_input *y4m, const char detect[4]) {
+int file_is_y4m(const char detect[4]) {
   if (memcmp(detect, "YUV4", 4) == 0) {
     return 1;
   }
@@ -133,6 +132,12 @@
   return 0;
 }
 
+int fourcc_is_ivf(const char detect[4]) {
+  if (memcmp(detect, "DKIF", 4) == 0) {
+    return 1;
+  }
+  return 0;
+}
 
 /* Murmur hash derived from public domain reference implementation at
  *   http:// sites.google.com/site/murmurhash/
@@ -1044,7 +1049,7 @@
   input->detect.position = 0;
 
   if (input->detect.buf_read == 4
-      && file_is_y4m(input->file, &input->y4m, input->detect.buf)) {
+      && file_is_y4m(input->detect.buf)) {
     if (y4m_input_open(&input->y4m, input->file, input->detect.buf, 4,
                        input->only_i420) >= 0) {
       input->file_type = FILE_TYPE_Y4M;
@@ -1055,7 +1060,7 @@
       input->use_i420 = 0;
     } else
       fatal("Unsupported Y4M stream.");
-  } else if (input->detect.buf_read == 4 && file_is_ivf(input)) {
+  } else if (input->detect.buf_read == 4 && fourcc_is_ivf(input->detect.buf)) {
     fatal("IVF is not supported as input.");
   } else {
     input->file_type = FILE_TYPE_RAW;