From 64b89f1b4b1c0ee17524672962288a69b45d769c Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 6 Jan 2014 16:29:09 -0800 Subject: Fix encoding Raw yv12 and i420 from a pipe. rewind() does not work on pipes. https://code.google.com/p/webm/issues/detail?id=678 Change-Id: I057f1e25c3f5662012d6e33ff4c97c88f50df357 --- ivfdec.c | 5 ----- vpxenc.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ivfdec.c b/ivfdec.c index 4a0816ff0..a37a44c07 100644 --- a/ivfdec.c +++ b/ivfdec.c @@ -17,11 +17,6 @@ int file_is_ivf(struct VpxInputContext *input_ctx) { 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') { diff --git a/vpxenc.c b/vpxenc.c index d0ed9b538..4c933ce6f 100644 --- 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,13 +125,19 @@ int read_frame(struct VpxInputContext *input_ctx, vpx_image_t *img) { 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; } 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 @@ void open_input_file(struct VpxInputContext *input) { 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 @@ void open_input_file(struct VpxInputContext *input) { 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; -- cgit v1.2.3-70-g09d2