summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2016-07-16 20:53:25 +0200
committer ImJezze <jezze@gmx.net>2016-07-16 20:54:37 +0200
commit89af2864ed8c2bde525532d1bf72542da2c76ae0 (patch)
treefb2941f3055e9adcf8dc5c8b8715889c118703fb /src
parent9104c9d52336a879ad4dc519af003833acb63eca (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/util/aviio.cpp30
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp34
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h1
-rw-r--r--src/osd/modules/render/drawbgfx.cpp41
-rw-r--r--src/osd/modules/render/drawd3d.cpp5
-rw-r--r--src/osd/modules/render/drawd3d.h1
6 files changed, 68 insertions, 44 deletions
diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp
index 7a75330abe7..93f5bac1a1c 100644
--- a/src/lib/util/aviio.cpp
+++ b/src/lib/util/aviio.cpp
@@ -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;
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 093f8d98d9e..866143b3b3c 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -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,21 +248,31 @@ 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
//============================================================
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index 4200b4a3faf..8256421c4ad 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -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();
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index dec0110157a..aaf47eb344e 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -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);
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index 83aab350052..122c8758f05 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -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();
diff --git a/src/osd/modules/render/drawd3d.h b/src/osd/modules/render/drawd3d.h
index 66e25b61b29..7420e5b9ecd 100644
--- a/src/osd/modules/render/drawd3d.h
+++ b/src/osd/modules/render/drawd3d.h
@@ -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;