Commit 64b89f1b authored by Alex Converse's avatar Alex Converse

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
parent bbb25e6a
......@@ -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') {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment