Avoid encoding garbage when ivfenc encounters an unsupported Y4M file.
This change stops ivfenc from treating unsupported Y4M files as raw input. For example, if given an interlaced Y4M file, ivfenc treated the input as if it were raw data because the unsupported Y4M file case previously fell through without being handled. Change-Id: I06caa50f3448e6388741a77346daaebf77c277e1
This commit is contained in:
parent
9fdfb8e928
commit
e703af974d
33
ivfenc.c
33
ivfenc.c
@ -299,12 +299,11 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int file_type,
|
||||
}
|
||||
|
||||
|
||||
unsigned int file_is_y4m(FILE *infile,
|
||||
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;
|
||||
}
|
||||
@ -875,18 +874,26 @@ int main(int argc, const char **argv_)
|
||||
|
||||
if (file_is_y4m(infile, &y4m, detect.buf))
|
||||
{
|
||||
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.
|
||||
*/
|
||||
if (!arg_have_timebase)
|
||||
if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0)
|
||||
{
|
||||
cfg.g_timebase.num = y4m.fps_d;
|
||||
cfg.g_timebase.den = y4m.fps_n;
|
||||
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.
|
||||
*/
|
||||
if (!arg_have_timebase)
|
||||
{
|
||||
cfg.g_timebase.num = y4m.fps_d;
|
||||
cfg.g_timebase.den = y4m.fps_n;
|
||||
}
|
||||
arg_use_i420 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unsupported Y4M stream.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
arg_use_i420 = 0;
|
||||
}
|
||||
else if (file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, detect.buf))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user