Fix for Qt AVI encoding of dwRate and dwScale in the stream header.
This commit is contained in:
parent
d13ef4cdbe
commit
ba5be09a28
|
@ -444,7 +444,7 @@ int aviRecordOpenFile( const char *filepath )
|
||||||
{
|
{
|
||||||
char fourcc[8];
|
char fourcc[8];
|
||||||
gwavi_audio_t audioConfig;
|
gwavi_audio_t audioConfig;
|
||||||
unsigned int fps;
|
double fps;
|
||||||
char fileName[1024];
|
char fileName[1024];
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -519,7 +519,7 @@ int aviRecordOpenFile( const char *filepath )
|
||||||
{
|
{
|
||||||
delete gwavi; gwavi = NULL;
|
delete gwavi; gwavi = NULL;
|
||||||
}
|
}
|
||||||
fps = FCEUI_GetDesiredFPS() >> 24;
|
fps = ((double)FCEUI_GetDesiredFPS()) / 16777216.0;
|
||||||
|
|
||||||
g_config->getOption("SDL.Sound.Rate", &audioSampleRate);
|
g_config->getOption("SDL.Sound.Rate", &audioSampleRate);
|
||||||
|
|
||||||
|
@ -770,7 +770,8 @@ AviRecordDiskThread_t::~AviRecordDiskThread_t(void)
|
||||||
void AviRecordDiskThread_t::run(void)
|
void AviRecordDiskThread_t::run(void)
|
||||||
{
|
{
|
||||||
int numPixels, width, height, numPixelsReady = 0;
|
int numPixels, width, height, numPixelsReady = 0;
|
||||||
int fps = 60, numSamples = 0;
|
int numSamples = 0;
|
||||||
|
double fps = 60.0;
|
||||||
unsigned char *rgb24;
|
unsigned char *rgb24;
|
||||||
int16_t *audioOut;
|
int16_t *audioOut;
|
||||||
uint32_t *videoOut;
|
uint32_t *videoOut;
|
||||||
|
@ -781,7 +782,7 @@ void AviRecordDiskThread_t::run(void)
|
||||||
|
|
||||||
setPriority( QThread::HighestPriority );
|
setPriority( QThread::HighestPriority );
|
||||||
|
|
||||||
fps = FCEUI_GetDesiredFPS() >> 24;
|
fps = ((double)FCEUI_GetDesiredFPS()) / 16777216.0;
|
||||||
|
|
||||||
avgAudioPerFrame = ( audioSampleRate / fps) + 1;
|
avgAudioPerFrame = ( audioSampleRate / fps) + 1;
|
||||||
|
|
||||||
|
|
|
@ -91,9 +91,11 @@ gwavi_t::~gwavi_t(void)
|
||||||
|
|
||||||
int
|
int
|
||||||
gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
|
gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
|
||||||
const char *fourcc, unsigned int fps, struct gwavi_audio_t *audio)
|
const char *fourcc, double fps, struct gwavi_audio_t *audio)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
unsigned int usec;
|
||||||
|
|
||||||
memset( this->fourcc, 0, sizeof(this->fourcc) );
|
memset( this->fourcc, 0, sizeof(this->fourcc) );
|
||||||
strcpy( this->fourcc, fourcc );
|
strcpy( this->fourcc, fourcc );
|
||||||
|
|
||||||
|
@ -112,10 +114,12 @@ gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
|
||||||
perror("gwavi_open: failed to open file for writing");
|
perror("gwavi_open: failed to open file for writing");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
usec = (unsigned int)(1000000.0 / fps);
|
||||||
|
printf("FPS: %f %u\n", fps, usec );
|
||||||
|
|
||||||
/* set avi header */
|
/* set avi header */
|
||||||
avi_header.time_delay= 1000000 / fps;
|
avi_header.time_delay= usec;
|
||||||
avi_header.data_rate = width * height * 3;
|
avi_header.data_rate = width * height * 3 * (((unsigned int)fps)+1);
|
||||||
avi_header.flags = 0x10;
|
avi_header.flags = 0x10;
|
||||||
|
|
||||||
if (audio)
|
if (audio)
|
||||||
|
@ -156,8 +160,8 @@ gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
|
||||||
/* set stream header */
|
/* set stream header */
|
||||||
(void)strcpy(stream_header_v.data_type, "vids");
|
(void)strcpy(stream_header_v.data_type, "vids");
|
||||||
(void)memcpy(stream_header_v.codec, fourcc, 4);
|
(void)memcpy(stream_header_v.codec, fourcc, 4);
|
||||||
stream_header_v.time_scale = 1;
|
stream_header_v.time_scale = usec;
|
||||||
stream_header_v.data_rate = fps;
|
stream_header_v.data_rate = 1000000;
|
||||||
stream_header_v.buffer_size = size;
|
stream_header_v.buffer_size = size;
|
||||||
stream_header_v.data_length = 0;
|
stream_header_v.data_length = 0;
|
||||||
|
|
||||||
|
@ -498,10 +502,15 @@ fseek_failed:
|
||||||
* @return 0 on success, -1 on error.
|
* @return 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
gwavi_t::set_framerate(unsigned int fps)
|
gwavi_t::set_framerate(double fps)
|
||||||
{
|
{
|
||||||
stream_header_v.data_rate = fps;
|
unsigned int usec;
|
||||||
avi_header.time_delay = (10000000 / fps);
|
|
||||||
|
usec = (unsigned int)(1000000.0 / fps);
|
||||||
|
|
||||||
|
stream_header_v.time_scale = usec;
|
||||||
|
stream_header_v.data_rate = 1000000;
|
||||||
|
avi_header.time_delay = usec;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ class gwavi_t
|
||||||
~gwavi_t(void);
|
~gwavi_t(void);
|
||||||
|
|
||||||
int open(const char *filename, unsigned int width,
|
int open(const char *filename, unsigned int width,
|
||||||
unsigned int height, const char *fourcc, unsigned int fps,
|
unsigned int height, const char *fourcc, double fps,
|
||||||
struct gwavi_audio_t *audio);
|
struct gwavi_audio_t *audio);
|
||||||
|
|
||||||
int close(void);
|
int close(void);
|
||||||
|
@ -131,7 +131,7 @@ class gwavi_t
|
||||||
|
|
||||||
int set_size( unsigned int width, unsigned int height);
|
int set_size( unsigned int width, unsigned int height);
|
||||||
|
|
||||||
int set_framerate(unsigned int fps);
|
int set_framerate(double fps);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
Loading…
Reference in New Issue