STORE.C
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:1k
- #include <stdlib.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include "mp4_vars.h"
- #include "debug.h"
- #include "store.h"
- /**
- *
- **/
- static void store_yuv (char *name, unsigned char *src, int offset, int incr, int width, int height);
- static void putbyte (int c);
- /**/
- FILE * outfile;
- int create_flag = 1;
- const char mode_create[] = "wb";
- const char mode_open[] = "ab";
- /***/
- void storeframe (unsigned char *src[], int width, int height)
- {
- int offset = 0;
- int hor_size = mp4_state->horizontal_size;
- store_yuv (mp4_state->outputname, src[0], offset, width, hor_size, height);
- offset >>= 1;
- width >>= 1;
- height >>= 1;
- hor_size >>= 1;
- store_yuv (mp4_state->outputname, src[1], offset, width, hor_size, height);
- store_yuv (mp4_state->outputname, src[2], offset, width, hor_size, height);
- }
- /***/
- static void store_yuv (char *name, unsigned char *src, int offset,
- int incr, int width, int height)
- {
- int i;
- unsigned char *p;
- const char * mode = create_flag ? mode_create : mode_open;
- if (create_flag)
- create_flag = 0;
- if ((outfile = fopen (name, mode)) == NULL)
- {
- _Print ("Error: Couldn't append to %sn", name);
- exit(0);
- }
- for (i = 0; i < height; i++)
- {
- p = src + offset + incr * i;
- fwrite(p, width, 1, outfile);
- }
- fclose (outfile);
- }