Merge "Avoid encoding garbage when ivfenc encounters an unsupported Y4M file."

This commit is contained in:
John Koleszar
2010-06-16 11:54:39 -07:00
committed by Code Review

View File

@@ -303,8 +303,7 @@ unsigned int file_is_y4m(FILE *infile,
y4m_input *y4m,
char detect[4])
{
if(memcmp(detect, "YUV4", 4) == 0 &&
y4m_input_open(y4m, infile, detect, 4) >= 0)
if(memcmp(detect, "YUV4", 4) == 0)
{
return 1;
}
@@ -874,12 +873,14 @@ int main(int argc, const char **argv_)
detect.valid = 0;
if (file_is_y4m(infile, &y4m, detect.buf))
{
if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0)
{
file_type = FILE_TYPE_Y4M;
cfg.g_w = y4m.pic_w;
cfg.g_h = y4m.pic_h;
/* Use the frame rate from the file only if none was specified on the
* command-line.
/* Use the frame rate from the file only if none was specified
* on the command-line.
*/
if (!arg_have_timebase)
{
@@ -888,6 +889,12 @@ int main(int argc, const char **argv_)
}
arg_use_i420 = 0;
}
else
{
fprintf(stderr, "Unsupported Y4M stream.\n");
return EXIT_FAILURE;
}
}
else if (file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, detect.buf))
{
file_type = FILE_TYPE_IVF;