Audio writing is now buffered. Video output was changed to 256x224.
This commit is contained in:
@@ -1840,8 +1840,9 @@ Code for dumping raw video
|
||||
*/
|
||||
|
||||
#define RAW_BUFFER_FRAMES 10
|
||||
#define RAW_BUFFER_SAMPLES 12800
|
||||
#define RAW_WIDTH 256
|
||||
#define RAW_HEIGHT 223
|
||||
#define RAW_HEIGHT 224
|
||||
#define RAW_PIXEL_SIZE 4
|
||||
#define RAW_FRAME_SIZE (RAW_WIDTH*RAW_HEIGHT)
|
||||
#define RAW_PIXEL_FRAME_SIZE (RAW_FRAME_SIZE*RAW_PIXEL_SIZE)
|
||||
@@ -1856,6 +1857,8 @@ struct
|
||||
size_t frame_index;
|
||||
|
||||
FILE *ap;
|
||||
unsigned short *sample_buffer;
|
||||
size_t sample_index;
|
||||
size_t aud_dsize_pos;
|
||||
} raw_vid;
|
||||
|
||||
@@ -1878,10 +1881,20 @@ static void raw_video_close()
|
||||
|
||||
if (raw_vid.ap)
|
||||
{
|
||||
size_t file_size = ftell(raw_vid.ap); //Get file size
|
||||
if (raw_vid.sample_buffer)
|
||||
{
|
||||
size_t file_size;
|
||||
if (raw_vid.sample_index)
|
||||
{
|
||||
fwrite(raw_vid.sample_buffer, 2, raw_vid.frame_index, raw_vid.ap); //Sample is 2 bytes
|
||||
}
|
||||
|
||||
free(raw_vid.sample_buffer);
|
||||
|
||||
file_size = ftell(raw_vid.ap); //Get file size
|
||||
if (!fseek(raw_vid.ap, 4, SEEK_SET)) //Seek to after RIFF header
|
||||
{
|
||||
fwrite4(file_size - 2, raw_vid.ap); //No idea why -2
|
||||
fwrite4(file_size - 8, raw_vid.ap); //Don't include header or this write, -8
|
||||
}
|
||||
if (!fseek(raw_vid.ap, raw_vid.aud_dsize_pos, SEEK_SET)) //Seek to where the audio data size goes
|
||||
{
|
||||
@@ -1895,6 +1908,7 @@ static void raw_video_close()
|
||||
AudioLogging = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool raw_video_open(const char *video_filename, const char *audio_filename)
|
||||
{
|
||||
@@ -1904,6 +1918,8 @@ static bool raw_video_open(const char *video_filename, const char *audio_filenam
|
||||
if ((raw_vid.frame_buffer = (unsigned int *)malloc(RAW_PIXEL_FRAME_SIZE*RAW_BUFFER_FRAMES)))
|
||||
{
|
||||
if ((raw_vid.ap = fopen(audio_filename, "wb")))
|
||||
{
|
||||
if ((raw_vid.sample_buffer = (unsigned short *)malloc(RAW_BUFFER_SAMPLES*sizeof(short))))
|
||||
{
|
||||
fputs("RIFF", raw_vid.ap); //header
|
||||
fwrite4(~0, raw_vid.ap); //file size - unknown till file close
|
||||
@@ -1924,6 +1940,7 @@ static bool raw_video_open(const char *video_filename, const char *audio_filenam
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
raw_video_close();
|
||||
}
|
||||
return(false);
|
||||
@@ -1977,6 +1994,14 @@ static void raw_video_write_frame()
|
||||
if (temp > 32767) { temp = 32767; }
|
||||
else if (temp < -32768) { temp =-32768; }
|
||||
fwrite2((short)temp, raw_vid.ap);
|
||||
|
||||
raw_vid.sample_index++;
|
||||
|
||||
if (raw_vid.sample_index == RAW_BUFFER_SAMPLES)
|
||||
{
|
||||
fwrite(raw_vid.sample_buffer, 2, RAW_BUFFER_SAMPLES, raw_vid.ap); //Each sample is 2 bytes
|
||||
raw_vid.sample_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user