/* movtar_yuv422 ============= Read a JPEG image and generate a ZR36060 compatible version of it. The main task is to convert the YUV-space from 4:1:1 or 4:4:4 to 4:2:2. Besides that, two images are generated if so necessary. The resolution is unchanged. (The resolution defines the number of JPEG fields per buffer) The result is written as a jpeg to stdout. See this more as example code than a really useful tool. Usage: movtar_index -i filename (see movtar_index -h for help (or have a look at the function "usage")) Copyright (C) 2000 Gernot Ziegler (gz@lysator.liu.se) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #define MAXPIXELS (1024*1024) /* Maximum size of final image */ static unsigned char outBuffer[MAXPIXELS*3]; int main(int argc, char **argv) { int img_height, img_width, field = 0, y, ystart; unsigned char *addr; struct jpeg_decompress_struct dinfo; struct jpeg_compress_struct newinfo; struct jpeg_error_mgr jerr; dinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&dinfo); jpeg_stdio_src(&dinfo, stdin); jpeg_read_header(&dinfo, TRUE); dinfo.out_color_space = JCS_YCbCr; jpeg_start_decompress(&dinfo); if(dinfo.output_components != 3) { fprintf(stderr,"Output components of JPEG image = %d, must be 3\n",dinfo.output_components); exit(1); } img_width = dinfo.output_width; img_height = dinfo.output_height; fprintf(stderr, "Image dimensions are %dx%d\n", img_width, img_height); if(img_width*img_height>MAXPIXELS) { fprintf(stderr,"Img dimension %dx%d too big\n",img_width,img_height); exit(1); } for (y=0; y