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.
Unified · Split
| @@ -299,12 +299,11 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int file_type, · 298 unmodified lines | ||
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | |
| 302 | −unsigned int file_is_y4m(FILE *infile, | |
| 302 | +unsigned int file_is_y4m(FILE *infile, | |
| 303 | 303 | y4m_input *y4m, |
| 304 | 304 | char detect[4]) |
| 305 | 305 | { |
| 306 | − if(memcmp(detect, "YUV4", 4) == 0 && | |
| 307 | − y4m_input_open(y4m, infile, detect, 4) >= 0) | |
| 306 | + if(memcmp(detect, "YUV4", 4) == 0) | |
| 308 | 307 | { |
| 309 | 308 | return 1; |
| 310 | 309 | } |
| @@ -875,18 +874,26 @@ int main(int argc, const char **argv_) · 564 unmodified lines | ||
| 875 | 874 | |
| 876 | 875 | if (file_is_y4m(infile, &y4m, detect.buf)) |
| 877 | 876 | { |
| 878 | − file_type = FILE_TYPE_Y4M; | |
| 879 | − cfg.g_w = y4m.pic_w; | |
| 880 | − cfg.g_h = y4m.pic_h; | |
| 881 | − /* Use the frame rate from the file only if none was specified on the | |
| 882 | − * command-line. | |
| 883 | − */ | |
| 884 | − if (!arg_have_timebase) | |
| 877 | + if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0) | |
| 885 | 878 | { |
| 886 | − cfg.g_timebase.num = y4m.fps_d; | |
| 887 | − cfg.g_timebase.den = y4m.fps_n; | |
| 879 | + file_type = FILE_TYPE_Y4M; | |
| 880 | + cfg.g_w = y4m.pic_w; | |
| 881 | + cfg.g_h = y4m.pic_h; | |
| 882 | + /* Use the frame rate from the file only if none was specified | |
| 883 | + * on the command-line. | |
| 884 | + */ | |
| 885 | + if (!arg_have_timebase) | |
| 886 | + { | |
| 887 | + cfg.g_timebase.num = y4m.fps_d; | |
| 888 | + cfg.g_timebase.den = y4m.fps_n; | |
| 889 | + } | |
| 890 | + arg_use_i420 = 0; | |
| 891 | + } | |
| 892 | + else | |
| 893 | + { | |
| 894 | + fprintf(stderr, "Unsupported Y4M stream.\n"); | |
| 895 | + return EXIT_FAILURE; | |
| 888 | 896 | } |
| 889 | − arg_use_i420 = 0; | |
| 890 | 897 | } |
| 891 | 898 | else if (file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, detect.buf)) |
| 892 | 899 | { |