Doxygen Source Code Documentation
sample1.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
Go to the source code of this file.
Defines | |
#define | BUFFER_SIZE 4096 |
Functions | |
void | save_pgm (int width, int height, uint8_t *const *buf, int num) |
void | sample1 (FILE *file) |
int | main (int argc, char **argv) |
Define Documentation
|
|
Function Documentation
|
Definition at line 86 of file sample1.c. References argc, file, and sample1().
|
|
Definition at line 51 of file sample1.c. References fbuf_t::buf, mpeg2_info_t::display_fbuf, file, sequence_t::height, mpeg2_buffer(), mpeg2_close(), mpeg2_info(), mpeg2_init(), mpeg2_parse(), save_pgm(), mpeg2_info_t::sequence, STATE_END, STATE_SLICE, uint8_t, and sequence_t::width. Referenced by main().
00052 { 00053 #define BUFFER_SIZE 4096 00054 uint8_t buffer[BUFFER_SIZE]; 00055 mpeg2dec_t * mpeg2dec; 00056 const mpeg2_info_t * info; 00057 int state; 00058 int size; 00059 int framenum = 0; 00060 00061 mpeg2dec = mpeg2_init (); 00062 if (mpeg2dec == NULL) 00063 exit (1); 00064 info = mpeg2_info (mpeg2dec); 00065 00066 size = BUFFER_SIZE; 00067 do { 00068 state = mpeg2_parse (mpeg2dec); 00069 switch (state) { 00070 case -1: 00071 size = fread (buffer, 1, BUFFER_SIZE, file); 00072 mpeg2_buffer (mpeg2dec, buffer, buffer + size); 00073 break; 00074 case STATE_SLICE: 00075 case STATE_END: 00076 if (info->display_fbuf) 00077 save_pgm (info->sequence->width, info->sequence->height, 00078 info->display_fbuf->buf, framenum++); 00079 break; 00080 } 00081 } while (size); 00082 00083 mpeg2_close (mpeg2dec); 00084 } |
|
Definition at line 30 of file sample1.c. Referenced by sample1().
00031 { 00032 char filename[100]; 00033 FILE * pgmfile; 00034 int i; 00035 00036 sprintf (filename, "%d.pgm", num); 00037 pgmfile = fopen (filename, "wb"); 00038 if (!pgmfile) 00039 return; 00040 fprintf (pgmfile, "P5\n%d %d\n255\n", width, height * 3 / 2); 00041 fwrite (buf[0], width, height, pgmfile); 00042 width >>= 1; 00043 height >>= 1; 00044 for (i = 0; i < height; i++) { 00045 fwrite (buf[1] + i * width, width, 1, pgmfile); 00046 fwrite (buf[2] + i * width, width, 1, pgmfile); 00047 } 00048 fclose (pgmfile); 00049 } |