History

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.

Tom Finegan committed 16 years ago

Commit e703af91 parent 9fdfb8e1 file · +20 −13Browse files

Unified · Split

ivfenc.c+20−13
@@ -299,12 +299,11 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int file_type, · 298 unmodified lines
299299 }
300300
301301
302−unsigned int file_is_y4m(FILE *infile,
302+unsigned int file_is_y4m(FILE *infile,
303303 y4m_input *y4m,
304304 char detect[4])
305305 {
306− if(memcmp(detect, "YUV4", 4) == 0 &&
307− y4m_input_open(y4m, infile, detect, 4) >= 0)
306+ if(memcmp(detect, "YUV4", 4) == 0)
308307 {
309308 return 1;
310309 }
@@ -875,18 +874,26 @@ int main(int argc, const char **argv_) · 564 unmodified lines
875874
876875 if (file_is_y4m(infile, &y4m, detect.buf))
877876 {
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)
885878 {
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;
888896 }
889− arg_use_i420 = 0;
890897 }
891898 else if (file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, detect.buf))
892899 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t