summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2020-06-19 11:54:21 +0200
committer hap <happppp@users.noreply.github.com>2020-06-19 11:54:40 +0200
commit63a7bbb5f232e087c24d0a9cbf0f4fefe542af2d (patch)
tree275fc9ef1f5dc6cf143fad89e42fb87ed884eb62
parentc95ef9bcbd6091cc73589bbf3684f975177a55d8 (diff)
recording: fix frame sync regression (nw)
-rw-r--r--src/emu/machine.cpp2
-rw-r--r--src/emu/recording.cpp23
-rw-r--r--src/emu/recording.h3
-rw-r--r--src/lib/util/png.cpp6
-rw-r--r--src/lib/util/png.h2
5 files changed, 23 insertions, 13 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index 4e471a75007..ac9f324a626 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -276,7 +276,7 @@ void running_machine::start()
m_video->begin_recording(filename, movie_recording::format::MNG);
filename = options().avi_write();
- if (filename[0] != 0)
+ if (filename[0] != 0 && !m_video->is_recording())
m_video->begin_recording(filename, movie_recording::format::AVI);
// if we're coming in with a savegame request, process it now
diff --git a/src/emu/recording.cpp b/src/emu/recording.cpp
index e7cf3d88678..e4f1861fa9e 100644
--- a/src/emu/recording.cpp
+++ b/src/emu/recording.cpp
@@ -31,7 +31,7 @@ namespace
virtual bool append_single_video_frame(bitmap_rgb32 &bitmap, const rgb_t *palette, int palette_entries) override;
private:
- avi_file::ptr m_avi_file; // handle to the open movie file
+ avi_file::ptr m_avi_file; // handle to the open movie file
};
@@ -48,8 +48,8 @@ namespace
virtual bool append_single_video_frame(bitmap_rgb32 &bitmap, const rgb_t *palette, int palette_entries) override;
private:
- std::unique_ptr<emu_file> m_mng_file; // handle to the open movie file
- std::map<std::string, std::string> m_info_fields;
+ std::unique_ptr<emu_file> m_mng_file; // handle to the open movie file
+ std::map<std::string, std::string> m_info_fields;
};
};
@@ -64,9 +64,10 @@ namespace
movie_recording::movie_recording(screen_device *screen)
: m_screen(screen)
+ , m_frame_period(attotime::zero)
+ , m_next_frame_time(attotime::zero)
, m_frame(0)
{
- m_frame_period = m_screen ? m_screen->frame_period() : attotime::from_hz(screen_device::DEFAULT_FRAME_RATE);
}
@@ -174,7 +175,7 @@ bool avi_movie_recording::initialize(running_machine &machine, std::unique_ptr<e
// build up information about this new movie
avi_file::movie_info info;
info.video_format = 0;
- info.video_timescale = 1000 * frame_period().as_hz();
+ info.video_timescale = 1000 * (screen() ? screen()->frame_period().as_hz() : screen_device::DEFAULT_FRAME_RATE);
info.video_sampletime = 1000;
info.video_numsamples = 0;
info.video_width = width;
@@ -189,6 +190,9 @@ bool avi_movie_recording::initialize(running_machine &machine, std::unique_ptr<e
info.audio_samplebits = 16;
info.audio_samplerate = machine.sample_rate();
+ // compute the frame time
+ set_frame_period(attotime::from_seconds(1000) / info.video_timescale);
+
// create the file
avi_file::error avierr = avi_file::create(fullpath, info, m_avi_file);
if (avierr != avi_file::error::NONE)
@@ -212,7 +216,7 @@ bool avi_movie_recording::append_single_video_frame(bitmap_rgb32 &bitmap, const
// avi_movie_recording::append_video_frame
//-------------------------------------------------
- bool avi_movie_recording::add_sound_to_recording(const s16 *sound, int numsamples)
+bool avi_movie_recording::add_sound_to_recording(const s16 *sound, int numsamples)
{
g_profiler.start(PROFILER_MOVIE_REC);
@@ -254,8 +258,13 @@ mng_movie_recording::~mng_movie_recording()
bool mng_movie_recording::initialize(std::unique_ptr<emu_file> &&file, bitmap_t &snap_bitmap)
{
+ // compute the frame time (MNG rate is an unsigned integer)
+ attotime period = screen() ? screen()->frame_period() : attotime::from_hz(screen_device::DEFAULT_FRAME_RATE);
+ u32 rate = u32(period.as_hz());
+ set_frame_period(attotime::from_hz(rate));
+
m_mng_file = std::move(file);
- png_error pngerr = mng_capture_start(*m_mng_file, snap_bitmap, frame_period().as_hz());
+ png_error pngerr = mng_capture_start(*m_mng_file, snap_bitmap, rate);
if (pngerr != PNGERR_NONE)
osd_printf_error("Error capturing MNG, png_error=%d\n", pngerr);
return pngerr == PNGERR_NONE;
diff --git a/src/emu/recording.h b/src/emu/recording.h
index b805db27757..0a26c5c7db8 100644
--- a/src/emu/recording.h
+++ b/src/emu/recording.h
@@ -73,10 +73,11 @@ protected:
// accessors
int current_frame() const { return m_frame; }
+ void set_frame_period(attotime time) { m_frame_period = time; }
private:
screen_device * m_screen; // screen associated with this movie (can be nullptr)
- attotime m_frame_period; // time of frame period
+ attotime m_frame_period; // duration of movie frame
attotime m_next_frame_time; // time of next frame
int m_frame; // current movie frame number
};
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp
index 6eb5293da53..6b59436750c 100644
--- a/src/lib/util/png.cpp
+++ b/src/lib/util/png.cpp
@@ -1246,18 +1246,18 @@ png_error png_write_bitmap(util::core_file &fp, png_info *info, bitmap_t const &
********************************************************************************/
/**
- * @fn png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, double rate)
+ * @fn png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, unsigned rate)
*
* @brief Mng capture start.
*
* @param [in,out] fp If non-null, the fp.
* @param [in,out] bitmap The bitmap.
- * @param rate The rate.
+ * @param rate The framerate.
*
* @return A png_error.
*/
-png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, double rate)
+png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, unsigned rate)
{
uint8_t mhdr[28];
diff --git a/src/lib/util/png.h b/src/lib/util/png.h
index ff14ff5f674..5f852fd8c16 100644
--- a/src/lib/util/png.h
+++ b/src/lib/util/png.h
@@ -103,7 +103,7 @@ png_error png_read_bitmap(util::core_file &fp, bitmap_argb32 &bitmap);
png_error png_write_bitmap(util::core_file &fp, png_info *info, bitmap_t const &bitmap, int palette_length, const rgb_t *palette);
-png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, double rate);
+png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, unsigned rate);
png_error mng_capture_frame(util::core_file &fp, png_info &info, bitmap_t const &bitmap, int palette_length, const rgb_t *palette);
png_error mng_capture_stop(util::core_file &fp);