From: Toni Wilen Date: Sun, 13 Dec 2015 18:01:05 +0000 (+0200) Subject: AVIOutput alignment, optional size/offset parameters. X-Git-Tag: 3220~15 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=6a964d1ffa52bd6aff482f79a4fe3d2641864aa1;p=francis%2Fwinuae.git AVIOutput alignment, optional size/offset parameters. --- diff --git a/include/options.h b/include/options.h index ce30cd31..aab95e30 100644 --- a/include/options.h +++ b/include/options.h @@ -678,6 +678,7 @@ struct uae_prefs { struct slirp_redir slirp_redirs[MAX_SLIRP_REDIRS]; #endif int statecapturerate, statecapturebuffersize; + int aviout_width, aviout_height, aviout_xoffset, aviout_yoffset; /* input */ diff --git a/od-win32/avioutput.cpp b/od-win32/avioutput.cpp index e405e496..1f68d025 100644 --- a/od-win32/avioutput.cpp +++ b/od-win32/avioutput.cpp @@ -63,6 +63,8 @@ static int first_frame = 1; int avioutput_audio, avioutput_video, avioutput_enabled, avioutput_requested; static int videoallocated; +static int aviout_width_out, aviout_height_out; +static int aviout_xoffset_out, aviout_yoffset_out; int avioutput_width, avioutput_height, avioutput_bits; int avioutput_fps = VBLANK_HZ_PAL; int avioutput_framelimiter = 0, avioutput_nosoundoutput = 0; @@ -505,6 +507,8 @@ void AVIOutput_ReleaseVideo (void) static int AVIOutput_AllocateVideo (void) { avioutput_width = avioutput_height = avioutput_bits = 0; + aviout_width_out = aviout_height_out = 0; + aviout_xoffset_out = aviout_yoffset_out = 0; avioutput_fps = (int)(vblank_hz + 0.5); if (!avioutput_fps) @@ -516,6 +520,10 @@ static int AVIOutput_AllocateVideo (void) } else { freertgbuffer (getrtgbuffer (&avioutput_width, &avioutput_height, &pitch, &avioutput_bits, NULL)); } + aviout_width_out = avioutput_width + 15; + aviout_width_out &= ~15; + aviout_height_out = avioutput_height + 1; + aviout_height_out &= ~1; } if (avioutput_width == 0 || avioutput_height == 0 || avioutput_bits == 0) { @@ -531,14 +539,30 @@ static int AVIOutput_AllocateVideo (void) avioutput_height = workprefs.gfx_size.height; avioutput_bits = WIN32GFX_GetDepth (0); } + if (!aviout_height_out) + aviout_height_out = avioutput_height; + if (!aviout_width_out) + aviout_width_out = avioutput_width; + + if (avioutput_originalsize) { + if (currprefs.aviout_width > 0) + aviout_width_out = currprefs.aviout_width; + if (currprefs.aviout_height > 0) + aviout_height_out = currprefs.aviout_height; + if (currprefs.aviout_xoffset >= 0) + aviout_xoffset_out = currprefs.aviout_xoffset; + if (currprefs.aviout_yoffset >= 0) + aviout_yoffset_out = currprefs.aviout_yoffset; + } + if (avioutput_bits == 0) avioutput_bits = 24; if (avioutput_bits > 24) avioutput_bits = 24; lpbi = (LPBITMAPINFOHEADER)xcalloc (uae_u8, lpbisize ()); lpbi->biSize = sizeof (BITMAPINFOHEADER); - lpbi->biWidth = avioutput_width; - lpbi->biHeight = avioutput_height; + lpbi->biWidth = aviout_width_out; + lpbi->biHeight = aviout_height_out; lpbi->biPlanes = 1; lpbi->biBitCount = avioutput_bits; lpbi->biCompression = BI_RGB; // uncompressed format @@ -951,7 +975,7 @@ static int getFromBuffer (struct avientry *ae, int original) int maxw, maxh; mem = NULL; - dpitch = ((avioutput_width * avioutput_bits + 31) & ~31) / 8; + dpitch = ((aviout_width_out * avioutput_bits + 31) & ~31) / 8; if (original || WIN32GFX_IsPicassoScreen ()) { if (!WIN32GFX_IsPicassoScreen ()) { src = getfilterbuffer (&w, &h, &spitch, &d); @@ -970,16 +994,46 @@ static int getFromBuffer (struct avientry *ae, int original) } if (!src) return 0; - dst += dpitch * avioutput_height; - for (y = 0; y < (maxh > avioutput_height ? avioutput_height : maxh); y++) { - uae_u8 *d; + + int xoffset = currprefs.aviout_xoffset < 0 ? (aviout_width_out - avioutput_width) / 2 : -currprefs.aviout_xoffset; + int yoffset = currprefs.aviout_yoffset < 0 ? (aviout_height_out - avioutput_height) / 2 : -currprefs.aviout_yoffset; + + dst += dpitch * aviout_height_out; + if (yoffset > 0) { + if (yoffset >= aviout_height_out - avioutput_height) + yoffset = aviout_height_out - avioutput_height; + dst -= dpitch * yoffset; + } else if (yoffset < 0) { + yoffset = -yoffset; + if (yoffset >= avioutput_height - aviout_height_out) + yoffset = avioutput_height - aviout_height_out; + src += spitch * yoffset; + } + int xoffset2 = 0; + if (xoffset < 0) { + xoffset2 = -xoffset; + xoffset = 0; + } + int dbpx = avioutput_bits / 8; + int sbpx = avioutput_bits / 8; + if (sbpx == 3) + sbpx = 4; + + for (y = 0; y < avioutput_height && y < maxh && y < aviout_height_out; y++) { + uae_u8 *s, *d; dst -= dpitch; d = dst; - for (x = 0; x < (maxw > avioutput_width ? avioutput_width : maxw); x++) { + s = src; + if (xoffset > 0) { + d += xoffset * dbpx; + } else if (xoffset2 > 0) { + s += xoffset2 * sbpx; + } + for (x = 0; x < avioutput_width && x < maxw && x < aviout_width_out; x++) { if (avioutput_bits == 8) { - *d++ = src[x]; + *d++ = s[x]; } else if (avioutput_bits == 16) { - uae_u16 v = ((uae_u16*)src)[x]; + uae_u16 v = ((uae_u16*)s)[x]; uae_u16 v2 = v; if (rgb_type == 3) { v2 = v & 31; @@ -993,11 +1047,11 @@ static int getFromBuffer (struct avientry *ae, int original) ((uae_u16*)d)[0] = v2; d += 2; } else if (avioutput_bits == 32) { - uae_u32 v = ((uae_u32*)src)[x]; + uae_u32 v = ((uae_u32*)s)[x]; ((uae_u32*)d)[0] = v; d += 4; } else if (avioutput_bits == 24) { - uae_u32 v = ((uae_u32*)src)[x]; + uae_u32 v = ((uae_u32*)s)[x]; *d++ = v; *d++ = v >> 8; *d++ = v >> 16; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 73a5c307..ae48770d 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -3440,6 +3440,8 @@ void target_default_options (struct uae_prefs *p, int type) WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof buf / sizeof (TCHAR)); for (int i = 0; i < GAMEPORT_INPUT_SETTINGS; i++) _stprintf (p->input_config_name[i], buf, i + 1); + p->aviout_xoffset = -1; + p->aviout_yoffset = -1; } if (type == 1 || type == 0 || type == 3) { p->win32_uaescsimode = UAESCSI_CDEMU; @@ -3570,6 +3572,11 @@ void target_save_options (struct zfile *f, struct uae_prefs *p) cfgfile_target_dwrite (f, _T("framelatency"), _T("%d"), forcedframelatency); if (scsiromselected > 0) cfgfile_target_write(f, _T("expansion_gui_page"), expansionroms[scsiromselected].name); + + cfgfile_target_dwrite(f, _T("recording_width"), _T("%d"), p->aviout_width); + cfgfile_target_dwrite(f, _T("recording_height"), _T("%d"), p->aviout_height); + cfgfile_target_dwrite(f, _T("recording_x"), _T("%d"), p->aviout_xoffset); + cfgfile_target_dwrite(f, _T("recording_y"), _T("%d"), p->aviout_yoffset); } void target_restart (void) @@ -3615,7 +3622,7 @@ int target_parse_option (struct uae_prefs *p, const TCHAR *option, const TCHAR * int i, v; bool tbool; - int result = (cfgfile_yesno(option, value, _T("middle_mouse"), &p->win32_middle_mouse) + if (cfgfile_yesno(option, value, _T("middle_mouse"), &p->win32_middle_mouse) || cfgfile_yesno(option, value, _T("map_drives"), &p->win32_automount_drives) || cfgfile_yesno(option, value, _T("map_drives_auto"), &p->win32_automount_removable) || cfgfile_yesno(option, value, _T("map_cd_drives"), &p->win32_automount_cddrives) @@ -3656,8 +3663,14 @@ int target_parse_option (struct uae_prefs *p, const TCHAR *option, const TCHAR * || cfgfile_yesno(option, value, _T("right_control_is_right_win"), &p->right_control_is_right_win_key) || cfgfile_intval(option, value, _T("extraframewait"), &extraframewait, 1) || cfgfile_intval(option, value, _T("framelatency"), &forcedframelatency, 1) - || cfgfile_intval(option, value, _T("cpu_idle"), &p->cpu_idle, 1)); + || cfgfile_intval(option, value, _T("cpu_idle"), &p->cpu_idle, 1)) + return 1; + if (cfgfile_intval(option, value, _T("recording_width"), &p->aviout_width, 1) + || cfgfile_intval(option, value, _T("recording_height"), &p->aviout_height, 1) + || cfgfile_intval(option, value, _T("recording_x"), &p->aviout_xoffset, 1) + || cfgfile_intval(option, value, _T("recording_y"), &p->aviout_yoffset, 1)) + return 1; if (cfgfile_string(option, value, _T("expansion_gui_page"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) { TCHAR *p = _tcschr(tmpbuf, ','); @@ -3867,7 +3880,7 @@ int target_parse_option (struct uae_prefs *p, const TCHAR *option, const TCHAR * i++; } - return result; + return 0; } static void createdir (const TCHAR *path)