mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Fixed MT #6291
* fixed copy of texture data to bitmap in BGFX * changed AVI dimension to a lowest integral multiple of 4 (2 was still to low for most video players, e.g. VLC) * added audio to AVI record in HLSL * HLSL AVI record now uses window dimension instead of snap dimension
This commit is contained in:
parent
9104c9d523
commit
89af2864ed
@ -189,6 +189,14 @@
|
||||
|
||||
#define AVI_INDEX_2FIELD 0x01
|
||||
|
||||
/**
|
||||
* @def AVI_INTEGRAL_MULTIPLE
|
||||
*
|
||||
* @brief Ensures the integral multiple of the video dimension, because most video players are not capable to playback a video stream with a lower multiple.
|
||||
*/
|
||||
|
||||
#define AVI_INTEGRAL_MULTIPLE 4
|
||||
|
||||
/* HuffYUV definitions */
|
||||
|
||||
/**
|
||||
@ -223,14 +231,6 @@
|
||||
|
||||
#define HUFFYUV_PREDICT_DECORR 0x40
|
||||
|
||||
/**
|
||||
* @def ENSURE_EVEN_WIDTH_HEIGHT
|
||||
*
|
||||
* @brief Ensures that width and height of the output steam are even integers.
|
||||
*/
|
||||
|
||||
#define ENSURE_EVEN_WIDTH_HEIGHT 1
|
||||
|
||||
|
||||
namespace {
|
||||
/***************************************************************************
|
||||
@ -299,17 +299,11 @@ public:
|
||||
std::uint32_t width = info.video_width;
|
||||
std::uint32_t height = info.video_height;
|
||||
|
||||
/* ensure even width and height because most video players are not capable to playback a video stream with uneven width or height */
|
||||
if (ENSURE_EVEN_WIDTH_HEIGHT)
|
||||
std::uint32_t integal_multiple = std::uint32_t(AVI_INTEGRAL_MULTIPLE);
|
||||
if (integal_multiple > 1)
|
||||
{
|
||||
if (width % 2 > 0)
|
||||
{
|
||||
width--;
|
||||
}
|
||||
if (height % 2 > 0)
|
||||
{
|
||||
height--;
|
||||
}
|
||||
width = width - (width % integal_multiple);
|
||||
height = height - (height % integal_multiple);
|
||||
}
|
||||
|
||||
m_type = STREAMTYPE_VIDS;
|
||||
|
@ -129,6 +129,14 @@ public:
|
||||
m_avi_writer->video_frame(m_frame);
|
||||
}
|
||||
|
||||
void add_audio(const INT16 *buffer, int samples_this_frame)
|
||||
{
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
m_avi_writer->audio_frame(buffer, samples_this_frame);
|
||||
}
|
||||
|
||||
IDirect3DSurface9 * target_surface() { return m_vid_surface; }
|
||||
|
||||
private:
|
||||
@ -240,20 +248,30 @@ void shaders::record_movie()
|
||||
}
|
||||
|
||||
auto win = d3d->assert_window();
|
||||
osd_dim wdim = win->get_size();
|
||||
|
||||
int width = snap_width;
|
||||
int height = snap_height;
|
||||
if (win->swap_xy())
|
||||
{
|
||||
std::swap(width, height);
|
||||
}
|
||||
|
||||
recorder = std::make_unique<movie_recorder>(*machine, d3d, width, height);
|
||||
recorder = std::make_unique<movie_recorder>(*machine, d3d, wdim.width(), wdim.height());
|
||||
recorder->record(downcast<windows_options &>(machine->options()).d3d_hlsl_write());
|
||||
recording_movie = true;
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// shaders::record_audio
|
||||
//============================================================
|
||||
|
||||
void shaders::record_audio(const INT16 *buffer, int samples_this_frame)
|
||||
{
|
||||
if (!enabled())
|
||||
return;
|
||||
|
||||
if (recording_movie)
|
||||
{
|
||||
recorder->add_audio(buffer, samples_this_frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// hlsl_render_snapshot
|
||||
//============================================================
|
||||
|
@ -296,6 +296,7 @@ public:
|
||||
|
||||
void save_snapshot();
|
||||
void record_movie();
|
||||
void record_audio(const INT16 *buffer, int samples_this_frame);
|
||||
|
||||
void init_fsfx_quad();
|
||||
|
||||
|
@ -256,11 +256,18 @@ int renderer_bgfx::create()
|
||||
void renderer_bgfx::record()
|
||||
{
|
||||
auto win = assert_window();
|
||||
if (m_avi_writer == nullptr || win->m_index > 0)
|
||||
if (win->m_index > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_avi_writer == nullptr)
|
||||
{
|
||||
m_avi_writer = new avi_write(win->machine(), m_width[0], m_height[0]);
|
||||
m_avi_data = new uint8_t[m_width[0] * m_height[0] * 4];
|
||||
m_avi_bitmap.allocate(m_width[0], m_height[0]);
|
||||
}
|
||||
|
||||
if (m_avi_writer->recording())
|
||||
{
|
||||
m_avi_writer->stop();
|
||||
@ -674,27 +681,20 @@ int renderer_bgfx::draw(int update)
|
||||
{
|
||||
auto win = assert_window();
|
||||
int window_index = win->m_index;
|
||||
if (window_index == 0)
|
||||
{
|
||||
s_current_view = 0;
|
||||
if (m_avi_writer == nullptr)
|
||||
{
|
||||
uint32_t width = win->get_size().width();
|
||||
uint32_t height = win->get_size().height();
|
||||
m_avi_writer = new avi_write(win->machine(), width, height);
|
||||
m_avi_data = new uint8_t[width * height * 4];
|
||||
m_avi_bitmap.allocate(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
m_seen_views.clear();
|
||||
m_ui_view = -1;
|
||||
|
||||
// Set view 0 default viewport.
|
||||
osd_dim wdim = win->get_size();
|
||||
m_width[window_index] = wdim.width();
|
||||
m_height[window_index] = wdim.height();
|
||||
|
||||
// Set view 0 default viewport.
|
||||
if (window_index == 0)
|
||||
{
|
||||
s_current_view = 0;
|
||||
}
|
||||
|
||||
win->m_primlist->acquire_lock();
|
||||
s_current_view += m_chains->handle_screen_chains(s_current_view, win->m_primlist->first(), *win.get());
|
||||
win->m_primlist->release_lock();
|
||||
@ -787,11 +787,16 @@ void renderer_bgfx::update_recording()
|
||||
bgfx::blit(s_current_view > 0 ? s_current_view - 1 : 0, m_avi_texture, 0, 0, m_avi_target->target());
|
||||
bgfx::readTexture(m_avi_texture, m_avi_data);
|
||||
|
||||
UINT32* start = &m_avi_bitmap.pix32(0);
|
||||
// loop over Y
|
||||
for (int i = 0; i < m_width[0] * m_height[0] * 4; i += 4)
|
||||
int i = 0;
|
||||
for (int y = 0; y < m_avi_bitmap.height(); y++)
|
||||
{
|
||||
*start++ = 0xff000000 | (m_avi_data[i + 0] << 16) | (m_avi_data[i + 1] << 8) | m_avi_data[i + 2];
|
||||
UINT32 *dst = &m_avi_bitmap.pix32(y);
|
||||
|
||||
for (int x = 0; x < m_avi_bitmap.width(); x++)
|
||||
{
|
||||
*dst++ = 0xff000000 | (m_avi_data[i + 0] << 16) | (m_avi_data[i + 1] << 8) | m_avi_data[i + 2];
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
|
||||
m_avi_writer->video_frame(m_avi_bitmap);
|
||||
|
@ -145,6 +145,11 @@ void renderer_d3d9::record()
|
||||
get_shaders()->record_movie();
|
||||
}
|
||||
|
||||
void renderer_d3d9::add_audio_to_recording(const INT16 *buffer, int samples_this_frame)
|
||||
{
|
||||
get_shaders()->record_audio(buffer, samples_this_frame);
|
||||
}
|
||||
|
||||
void renderer_d3d9::save()
|
||||
{
|
||||
get_shaders()->save_snapshot();
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual void save() override;
|
||||
virtual void record() override;
|
||||
virtual void toggle_fsfx() override;
|
||||
virtual void add_audio_to_recording(const INT16 *buffer, int samples_this_frame) override;
|
||||
virtual std::vector<ui::menu_item> get_slider_list() override;
|
||||
virtual void set_sliders_dirty() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user