int main( ) { static char svg_buf[MAX_SVG]; ssize_t read_ret; size_t read_pos = 0; /* slurp input */ while (read_pos < MAX_SVG) { read_ret = read(STDIN_FILENO, svg_buf + read_pos, MAX_SVG - read_pos); if (read_ret < 0) { perror("read"); exit(1); } else if (read_ret == 0) { break; } else { read_pos += read_ret; } } /* create SVG frame */ RawFrame *svg = RsvgFrame::render_svg(svg_buf, read_pos); /* dump raw BGRAn8 video to stdout */ fprintf(stderr, "w=%d h=%d\n", svg->w( ), svg->h( )); svg->write_to_fd(STDOUT_FILENO); }
RawFrame *upscale(RawFrame *in) { RawFrame *out = new RawFrame(1920, 1080, RawFrame::CbYCrY8422); uint8_t *scaled_1 = new uint8_t[2*1920]; uint8_t *scaled_2 = new uint8_t[2*1920]; for (int i = 0; i < out->h( ); i++) { int src_scan = i * 4 / 9; uint8_t *scanline_1 = in->scanline(src_scan); uint8_t *scanline_2; if (src_scan + 1 < in->h( )) { scanline_2 = in->scanline(src_scan + 1); } else { scanline_2 = in->scanline(src_scan); } upscale_scanline(scaled_1, scanline_1); upscale_scanline(scaled_2, scanline_2); interpolate_scanline(out->scanline(i), scaled_1, scaled_2, (4 * i) % 9); } return out; }