diff --git a/desmume/src/windows/aviout.cpp b/desmume/src/windows/aviout.cpp index a3cb251ea..5dff6d379 100644 --- a/desmume/src/windows/aviout.cpp +++ b/desmume/src/windows/aviout.cpp @@ -28,9 +28,12 @@ #include "../GPU_osd.h" #include "../SPU.h" +#include "video.h" #include "windriver.h" #include "main.h" +extern VideoInfo video; + static void EMU_PrintError(const char* msg) { LOG(msg); } @@ -46,8 +49,6 @@ static void EMU_PrintMessage(const char* msg) { #define VIDEO_STREAM 0 #define AUDIO_STREAM 1 -#define VIDEO_WIDTH 256 - static struct AVIFile { int valid; @@ -72,7 +73,8 @@ static struct AVIFile int video_frames; int sound_samples; - u8 convert_buffer[256*384*3]; + u8 *convert_buffer; + int prescaleLevel; int start_scanline; int end_scanline; @@ -178,6 +180,7 @@ static void avi_destroy(struct AVIFile** avi_out) (*avi_out)->avi_file = NULL; } + free_aligned((*avi_out)->convert_buffer); free(*avi_out); *avi_out = NULL; } @@ -213,13 +216,6 @@ static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const W // create the object avi_create(&avi_file); - // set video size and framerate - /*avi_file->start_scanline = vsi->start_scanline; - avi_file->end_scanline = vsi->end_scanline; - avi_file->fps = vsi->fps; - avi_file->fps_scale = 16777216-1; - avi_file->convert_buffer = new u8[256*384*3];*/ - // open the file if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL))) break; @@ -228,6 +224,9 @@ static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const W set_video_format(pbmih, avi_file); memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO)); + avi_file->prescaleLevel = video.prescaleHD; + avi_file->convert_buffer = (u8*)malloc_alignedCacheLine(video.prescaleHD*video.prescaleHD*256*384*3); + avi_file->avi_video_header.fccType = streamtypeVIDEO; avi_file->avi_video_header.dwScale = 6*355*263; avi_file->avi_video_header.dwRate = 33513982; @@ -311,13 +310,15 @@ static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const W } //converts 16bpp to 24bpp and flips -static void do_video_conversion(const u16* buffer) +static void do_video_conversion(AVIFile* avi, const u16* buffer) { - u8* outbuf = avi_file->convert_buffer + 256*(384-1)*3; + int width = avi->prescaleLevel*256; + int height = avi->prescaleLevel*384; + u8* outbuf = avi_file->convert_buffer + width*(height-1)*3; - for(int y=0;y<384;y++) + for(int y=0;yvalid) return; - do_video_conversion(buffer); + const NDSDisplayInfo& dispInfo = GPU->GetDisplayInfo(); + const u16* buffer = dispInfo.masterCustomBuffer; + + //dont do anything if prescale has changed, it's just going to be garbage + if(video.prescaleHD != avi_file->prescaleLevel) + return; + + do_video_conversion(avi_file, buffer); if(FAILED(AVIStreamWrite(avi_file->compressed_streams[VIDEO_STREAM], avi_file->video_frames, 1, avi_file->convert_buffer, diff --git a/desmume/src/windows/aviout.h b/desmume/src/windows/aviout.h index b34f43b4f..5eed3f20b 100644 --- a/desmume/src/windows/aviout.h +++ b/desmume/src/windows/aviout.h @@ -24,6 +24,6 @@ bool DRV_AviBegin(const char* fname); void DRV_AviEnd(); void DRV_AviSoundUpdate(void* soundData, int soundLen); bool AVI_IsRecording(); -void DRV_AviVideoUpdate(const u16* buffer); +void DRV_AviVideoUpdate(); #endif diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 8ddf16d11..b2c0e9f3c 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2143,7 +2143,7 @@ static void StepRunLoop_Core() win_sound_samplecounter = DESMUME_SAMPLE_RATE/60; } inFrameBoundary = true; - DRV_AviVideoUpdate(GPU->GetDisplayInfo().masterNativeBuffer); + DRV_AviVideoUpdate(); extern bool rewinding;