fate: teach videogen/rotozoom to output a single raw video stream

This makes videogen/rotozoom output a raw video stream on stdout
if no output directory is specified.

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard
2012-05-17 15:55:14 +01:00
parent e999b641df
commit 7e5880e0cb
4 changed files with 49 additions and 18 deletions

View File

@@ -115,20 +115,37 @@ static void pgmyuv_save(const char *filename, int w, int h,
rgb24_to_yuv420p(lum_tab, cb_tab, cr_tab, rgb_tab, w, h);
f = fopen(filename, "wb");
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
if (filename) {
f = fopen(filename, "wb");
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
} else {
f = stdout;
}
err_if(fwrite(lum_tab, 1, w * h, f) != w * h);
h2 = h / 2;
w2 = w / 2;
cb = cb_tab;
cr = cr_tab;
for (i = 0; i < h2; i++) {
err_if(fwrite(cb, 1, w2, f) != w2);
err_if(fwrite(cr, 1, w2, f) != w2);
cb += w2;
cr += w2;
if (filename) {
for (i = 0; i < h2; i++) {
err_if(fwrite(cb, 1, w2, f) != w2);
err_if(fwrite(cr, 1, w2, f) != w2);
cb += w2;
cr += w2;
}
fclose(f);
} else {
for (i = 0; i < h2; i++) {
err_if(fwrite(cb, 1, w2, f) != w2);
cb += w2;
}
for (i = 0; i < h2; i++) {
err_if(fwrite(cr, 1, w2, f) != w2);
cr += w2;
}
}
fclose(f);
free(lum_tab);
free(cb_tab);