Successful recording of small avi in RGB24 format.
This commit is contained in:
parent
fb30f57bec
commit
9b4b9b6549
|
@ -11,30 +11,54 @@ static gwavi_t *gwavi = NULL;
|
|||
static bool recordEnable = false;
|
||||
//**************************************************************************************
|
||||
|
||||
static void convertRgb_32_to_24( const char *src, char *dest, int nPix )
|
||||
static void convertRgb_32_to_24( const unsigned char *src, unsigned char *dest, int w, int h, int nPix )
|
||||
{
|
||||
int i=0, j=0, s;
|
||||
int i=0, j=0, x, y;
|
||||
|
||||
s = nPix * 4;
|
||||
// Uncompressed RGB needs to be flipped vertically
|
||||
y = h-1;
|
||||
|
||||
while ( i < s )
|
||||
while ( y >= 0 )
|
||||
{
|
||||
dest[j] = src[i]; i++; j++;
|
||||
dest[j] = src[i]; i++; j++;
|
||||
dest[j] = src[i]; i++; j++;
|
||||
i++;
|
||||
x = 0;
|
||||
i = y*w*4;
|
||||
|
||||
while ( x < w )
|
||||
{
|
||||
dest[j] = src[i]; i++; j++;
|
||||
dest[j] = src[i]; i++; j++;
|
||||
dest[j] = src[i]; i++; j++;
|
||||
i++;
|
||||
x++;
|
||||
}
|
||||
y--;
|
||||
}
|
||||
}
|
||||
//**************************************************************************************
|
||||
int aviRecordOpenFile( const char *filepath, int format, int width, int height )
|
||||
{
|
||||
char fourcc[8];
|
||||
gwavi_audio_t audioConfig;
|
||||
|
||||
if ( gwavi != NULL )
|
||||
{
|
||||
delete gwavi; gwavi = NULL;
|
||||
}
|
||||
audioConfig.channels = 1;
|
||||
audioConfig.bits = 16;
|
||||
audioConfig.samples_per_second = 48000;
|
||||
|
||||
memset( fourcc, 0, sizeof(fourcc) );
|
||||
|
||||
gwavi = new gwavi_t();
|
||||
|
||||
if ( gwavi->open( "/tmp/test.avi", nes_shm->video.ncol, nes_shm->video.nrow, fourcc, 60, &audioConfig ) )
|
||||
{
|
||||
printf("Error: Failed to open AVI file.\n");
|
||||
recordEnable = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
recordEnable = true;
|
||||
return 0;
|
||||
}
|
||||
|
@ -55,20 +79,52 @@ int aviRecordAddFrame( void )
|
|||
numPixels = nes_shm->video.ncol * nes_shm->video.nrow;
|
||||
bufferSize = numPixels * sizeof(uint32_t);
|
||||
|
||||
//gwavi->
|
||||
{
|
||||
unsigned char rgb24[bufferSize];
|
||||
convertRgb_32_to_24( (const unsigned char*)nes_shm->pixbuf, rgb24,
|
||||
nes_shm->video.ncol, nes_shm->video.nrow, numPixels );
|
||||
gwavi->add_frame( rgb24, numPixels*3 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//**************************************************************************************
|
||||
int aviRecordAddAudioFrame( int32_t *buf, int numSamples )
|
||||
{
|
||||
if ( !recordEnable )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( gwavi == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int16_t lclBuf[numSamples];
|
||||
|
||||
for (int i=0; i<numSamples; i++)
|
||||
{
|
||||
lclBuf[i] = buf[i];
|
||||
}
|
||||
gwavi->add_audio( (unsigned char *)lclBuf, numSamples*2);
|
||||
}
|
||||
//**************************************************************************************
|
||||
int aviRecordClose(void)
|
||||
{
|
||||
recordEnable = false;
|
||||
|
||||
if ( gwavi != NULL )
|
||||
{
|
||||
gwavi->close();
|
||||
|
||||
delete gwavi; gwavi = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//**************************************************************************************
|
||||
bool aviRecordRunning(void)
|
||||
{
|
||||
return recordEnable;
|
||||
}
|
||||
//**************************************************************************************
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
// AviRecord.h
|
||||
//
|
||||
#include <stdint.h>
|
||||
|
||||
int aviRecordOpenFile( const char *filepath, int format, int width, int height );
|
||||
|
||||
int aviRecordAddFrame( void );
|
||||
|
||||
int aviRecordAddAudioFrame( int32_t *buf, int numSamples );
|
||||
|
||||
int aviRecordClose(void);
|
||||
|
||||
bool aviRecordRunning(void);
|
||||
|
|
|
@ -3096,7 +3096,19 @@ void consoleWin_t::recordMovieAs(void)
|
|||
|
||||
void consoleWin_t::aviOpen(void)
|
||||
{
|
||||
aviRecordOpenFile( NULL, 0, 256, 240 );
|
||||
printf("AVI!!!\n");
|
||||
if ( aviRecordRunning() )
|
||||
{
|
||||
fceuWrapperLock();
|
||||
aviRecordClose();
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
fceuWrapperLock();
|
||||
aviRecordOpenFile( NULL, 0, 256, 240 );
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
}
|
||||
|
||||
void consoleWin_t::aboutFCEUX(void)
|
||||
|
|
|
@ -531,7 +531,7 @@ gwavi_t::check_fourcc(const char *fourcc)
|
|||
"NVT0 NVT1 NVT2 NVT3 NVT4 NVT5"
|
||||
"PDVC PGVV PHMO PIM1 PIM2 PIMJ PIXL PJPG PVEZ PVMM PVW2"
|
||||
"QPEG QPEQ"
|
||||
"RGBT RLE RLE4 RLE8 RMP4 RPZA RT21 RV20 RV30 RV40 S422 SAN3"
|
||||
"RGB2 RGBT RLE RLE4 RLE8 RMP4 RPZA RT21 RV20 RV30 RV40 S422 SAN3"
|
||||
"SDCC SEDG SFMC SMP4 SMSC SMSD SMSV SP40 SP44 SP54 SPIG SQZ2"
|
||||
"STVA STVB STVC STVX STVY SV10 SVQ1 SVQ3"
|
||||
"TLMS TLST TM20 TM2X TMIC TMOT TR20 TSCC TV10 TVJP TVMJ TY0N"
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "Qt/sdl-video.h"
|
||||
#include "Qt/nes_shm.h"
|
||||
#include "Qt/unix-netplay.h"
|
||||
#include "Qt/AviRecord.h"
|
||||
#include "Qt/HexEditor.h"
|
||||
#include "Qt/SymbolicDebug.h"
|
||||
#include "Qt/CodeDataLogger.h"
|
||||
|
@ -981,6 +982,7 @@ FCEUD_Update(uint8 *XBuf,
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
aviRecordAddAudioFrame( Buffer, Count );
|
||||
|
||||
int ocount = Count;
|
||||
// apply frame scaling to Count
|
||||
|
|
Loading…
Reference in New Issue