r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / quicktime / decore50 / store.c
blob4d1926e5bb959c9ae7b89f713ea4685a33907553
1 /**************************************************************************
2 * *
3 * This code has been developed by Andrea Graziani. This software is an *
4 * implementation of a part of one or more MPEG-4 Video tools as *
5 * specified in ISO/IEC 14496-2 standard. Those intending to use this *
6 * software module in hardware or software products are advised that its *
7 * use may infringe existing patents or copyrights, and any such use *
8 * would be at such party's own risk. The original developer of this *
9 * software module and his/her company, and subsequent editors and their *
10 * companies (including Project Mayo), will have no liability for use of *
11 * this software or modifications or derivatives thereof. *
12 * *
13 * Project Mayo gives users of the Codec a license to this software *
14 * module or modifications thereof for use in hardware or software *
15 * products claiming conformance to the MPEG-4 Video Standard as *
16 * described in the Open DivX license. *
17 * *
18 * The complete Open DivX license can be found at *
19 * http://www.projectmayo.com/opendivx/license.php *
20 * *
21 **************************************************************************/
22 /**
23 * Copyright (C) 2001 - Project Mayo
25 * Andrea Graziani
27 * DivX Advanced Research Center <darc@projectmayo.com>
29 **/
30 // store.c //
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <fcntl.h>
36 #include "mp4_vars.h"
38 #include "debug.h"
39 #include "store.h"
41 /**
43 **/
45 static void store_yuv (char *name, unsigned char *src, int offset, int incr, int width, int height);
46 static void putbyte (int c);
48 /**/
50 FILE * outfile;
51 int create_flag = 1;
52 const char mode_create[] = "wb";
53 const char mode_open[] = "ab";
55 /***/
57 // Purpose: store a frame in yuv format
58 void storeframe (unsigned char *src[], int width, int height)
60 int offset = 0;
61 int hor_size = mp4_state->horizontal_size;
63 store_yuv (mp4_state->outputname, src[0], offset, width, hor_size, height);
65 offset >>= 1;
66 width >>= 1;
67 height >>= 1;
68 hor_size >>= 1;
70 store_yuv (mp4_state->outputname, src[1], offset, width, hor_size, height);
71 store_yuv (mp4_state->outputname, src[2], offset, width, hor_size, height);
74 /***/
76 static void store_yuv (char *name, unsigned char *src, int offset,
77 int incr, int width, int height)
79 int i;
80 unsigned char *p;
81 const char * mode = create_flag ? mode_create : mode_open;
84 if (create_flag)
85 create_flag = 0;
87 if ((outfile = fopen (name, mode)) == NULL)
89 _Print ("Error: Couldn't append to %s\n", name);
90 exit(0);
93 for (i = 0; i < height; i++)
95 p = src + offset + incr * i;
96 fwrite(p, width, 1, outfile);
99 fclose (outfile);