summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ryan Holtz <ryan.holtz@arrowheadgs.com>2020-06-26 10:30:06 +0200
committer Ryan Holtz <ryan.holtz@arrowheadgs.com>2020-06-26 10:30:06 +0200
commit6443f8257cf727bbb6ff020fe9b1383db324823e (patch)
tree77fe1ce3644cf69f73a51a8b6d731a4066093943
parentd55b3eb19653ef519c706bc97a54f4ca3903d2b9 (diff)
-render, aviio: Added basic uncompressed Y42B support. [Ryan Holtz]
-rw-r--r--src/emu/render.cpp2
-rw-r--r--src/emu/render.h10
-rw-r--r--src/emu/rendlay.cpp78
-rw-r--r--src/emu/rendutil.cpp10
-rw-r--r--src/emu/rendutil.h2
-rw-r--r--src/lib/util/aviio.cpp53
-rw-r--r--src/lib/util/aviio.h1
7 files changed, 102 insertions, 54 deletions
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index 2ab6b3f5e4c..b6afedd8870 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -2088,7 +2088,7 @@ bool render_target::load_layout_file(device_t &device, const char *dirname, util
}
catch (emu_fatalerror &err)
{
- printf("HELL ASS PISS BITCH FUCK SHIT DAMN\n\n"); fflush(stdout);
+ printf("HELL ASS PISS BITCH FUCK SHIT DAMN %s\n", err.what()); fflush(stdout);
return false;
}
diff --git a/src/emu/render.h b/src/emu/render.h
index 97c7e53ccbe..b87d59f5bfa 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -586,7 +586,7 @@ private:
typedef std::unique_ptr<component> ptr;
// construction/destruction
- component(environment &env, util::xml::data_node const &compnode, const char *dirname);
+ component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
virtual ~component() = default;
// setup
@@ -597,6 +597,7 @@ private:
virtual int maxstate() const { return m_state; }
const render_bounds &bounds() const { return m_bounds; }
const render_color &color() const { return m_color; }
+ const char* artname() const { return m_artname; }
// operations
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) = 0;
@@ -619,6 +620,7 @@ private:
int m_state; // state where this component is visible (-1 means all states)
render_bounds m_bounds; // bounds of the element
render_color m_color; // color of the element
+ const char* m_artname; // path to our artwork directory
};
// component implementations
@@ -655,13 +657,13 @@ private:
int m_state; // associated state number
};
- typedef component::ptr (*make_component_func)(environment &env, util::xml::data_node const &compnode, const char *dirname);
+ typedef component::ptr (*make_component_func)(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
typedef std::map<std::string, make_component_func> make_component_map;
// internal helpers
static void element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
- template <typename T> static component::ptr make_component(environment &env, util::xml::data_node const &compnode, const char *dirname);
- template <int D> static component::ptr make_dotmatrix_component(environment &env, util::xml::data_node const &compnode, const char *dirname);
+ template <typename T> static component::ptr make_component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
+ template <int D> static component::ptr make_dotmatrix_component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
static make_component_map const s_make_component; // maps component XML names to creator functions
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index b94ef95dd95..87b84b8c7f0 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -889,7 +889,7 @@ layout_element::layout_element(environment &env, util::xml::data_node const &ele
}
// insert the new component into the list
- component const &newcomp(**m_complist.emplace(m_complist.end(), make_func->second(env, *compnode, dirname)));
+ component const &newcomp(**m_complist.emplace(m_complist.end(), make_func->second(env, *compnode, machine().options().art_path(), dirname)));
// accumulate bounds
if (first)
@@ -1233,8 +1233,8 @@ class layout_element::image_component : public component
{
public:
// construction/destruction
- image_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ image_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
, m_hasalpha(false)
{
if (dirname != nullptr)
@@ -1315,11 +1315,12 @@ class layout_element::video_component : public component
{
public:
// construction/destruction
- video_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ video_component(environment &env, util::xml::data_node const& compnode, const char *artname, const char* dirname)
+ : component(env, compnode, artname, dirname)
+ , m_environment(env)
, m_frame(0)
, m_max_frames(0)
- , m_playing(false)
+ , m_playing(true)
{
if (dirname != nullptr)
m_dirname = dirname;
@@ -1358,7 +1359,7 @@ private:
{
assert(m_file != nullptr);
- bool success = render_detect_and_open_video(*m_file, m_dirname.c_str(), m_videofile.c_str(), m_video);
+ bool success = render_detect_and_open_video(*m_file, artname(), m_dirname.c_str(), m_videofile.c_str(), m_video);
if (!success)
{
m_playing = false;
@@ -1386,9 +1387,11 @@ private:
}
// internal state
+ environment& m_environment;
std::unique_ptr<avi_file> m_video; // source video
bitmap_argb32 m_bitmap; // source bitmap for blitting
- std::string m_dirname; // directory name of image file (for lazy loading)
+ std::string m_dirname; // directory name of image file
+ std::string m_artname; // directory name of artwork files
std::unique_ptr<emu_file> m_file; // file object for reading image/alpha files
std::string m_videofile; // name of the image file (for lazy loading)
uint64_t m_frame; // current frame number
@@ -1401,8 +1404,8 @@ class layout_element::rect_component : public component
{
public:
// construction/destruction
- rect_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ rect_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1447,8 +1450,8 @@ class layout_element::disk_component : public component
{
public:
// construction/destruction
- disk_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ disk_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1508,8 +1511,8 @@ class layout_element::text_component : public component
{
public:
// construction/destruction
- text_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ text_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
m_string = env.get_attribute_string(compnode, "string", "");
m_textalign = env.get_attribute_int(compnode, "align", 0);
@@ -1536,8 +1539,8 @@ class layout_element::led7seg_component : public component
{
public:
// construction/destruction
- led7seg_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led7seg_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1598,8 +1601,8 @@ class layout_element::led8seg_gts1_component : public component
{
public:
// construction/destruction
- led8seg_gts1_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led8seg_gts1_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1666,8 +1669,8 @@ class layout_element::led14seg_component : public component
{
public:
// construction/destruction
- led14seg_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led14seg_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1778,8 +1781,8 @@ class layout_element::led16seg_component : public component
{
public:
// construction/destruction
- led16seg_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led16seg_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -1900,8 +1903,8 @@ class layout_element::led14segsc_component : public component
{
public:
// construction/destruction
- led14segsc_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led14segsc_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -2021,8 +2024,8 @@ class layout_element::led16segsc_component : public component
{
public:
// construction/destruction
- led16segsc_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ led16segsc_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
}
@@ -2152,8 +2155,8 @@ class layout_element::dotmatrix_component : public component
{
public:
// construction/destruction
- dotmatrix_component(int dots, environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ dotmatrix_component(int dots, environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
, m_dots(dots)
{
}
@@ -2193,8 +2196,8 @@ class layout_element::simplecounter_component : public component
{
public:
// construction/destruction
- simplecounter_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ simplecounter_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
, m_digits(env.get_attribute_int(compnode, "digits", 2))
, m_textalign(env.get_attribute_int(compnode, "align", 0))
, m_maxstate(env.get_attribute_int(compnode, "maxstate", 999))
@@ -2228,8 +2231,8 @@ class layout_element::reel_component : public component
public:
// construction/destruction
- reel_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
- : component(env, compnode, dirname)
+ reel_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
+ : component(env, compnode, artname, dirname)
{
for (auto & elem : m_hasalpha)
elem = false;
@@ -2651,9 +2654,9 @@ private:
//-------------------------------------------------
template <typename T>
-layout_element::component::ptr layout_element::make_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
+layout_element::component::ptr layout_element::make_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
{
- return std::make_unique<T>(env, compnode, dirname);
+ return std::make_unique<T>(env, compnode, artname, dirname);
}
@@ -2663,9 +2666,9 @@ layout_element::component::ptr layout_element::make_component(environment &env,
//-------------------------------------------------
template <int D>
-layout_element::component::ptr layout_element::make_dotmatrix_component(environment &env, util::xml::data_node const &compnode, const char *dirname)
+layout_element::component::ptr layout_element::make_dotmatrix_component(environment &env, util::xml::data_node const &compnode, const char* artname, const char *dirname)
{
- return std::make_unique<dotmatrix_component>(D, env, compnode, dirname);
+ return std::make_unique<dotmatrix_component>(D, env, compnode, artname, dirname);
}
@@ -2726,9 +2729,10 @@ layout_element::texture &layout_element::texture::operator=(texture &&that)
// component - constructor
//-------------------------------------------------
-layout_element::component::component(environment &env, util::xml::data_node const &compnode, const char *dirname)
+layout_element::component::component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname)
: m_state(env.get_attribute_int(compnode, "state", -1))
, m_color(env.parse_color(compnode.get_child("color")))
+ , m_artname(artname)
{
env.parse_bounds(compnode.get_child("bounds"), m_bounds);
}
diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp
index 9850e157b69..99a9abf6ed9 100644
--- a/src/emu/rendutil.cpp
+++ b/src/emu/rendutil.cpp
@@ -830,7 +830,7 @@ ru_imgformat render_detect_image(emu_file &file, const char *dirname, const char
return RENDUTIL_IMGFORMAT_UNKNOWN;
}
-bool render_detect_and_open_video(emu_file &file, const char *dirname, const char *filename, std::unique_ptr<avi_file> &video)
+bool render_detect_and_open_video(emu_file &file, const char *artpath, const char *dirname, const char *filename, std::unique_ptr<avi_file> &video)
{
if (video)
return false;
@@ -845,7 +845,13 @@ bool render_detect_and_open_video(emu_file &file, const char *dirname, const cha
if (filerr != osd_file::error::NONE)
return false;
- avi_file::error err = avi_file::open(fname, video);
+ std::string fullname;
+ if (artpath)
+ fullname.assign(artpath).append(PATH_SEPARATOR).append(dirname).append(PATH_SEPARATOR).append(filename);
+ else
+ fullname.assign(fname);
+
+ avi_file::error err = avi_file::open(fullname, video);
if (!video)
return false;
diff --git a/src/emu/rendutil.h b/src/emu/rendutil.h
index ea5543e561c..79809345e70 100644
--- a/src/emu/rendutil.h
+++ b/src/emu/rendutil.h
@@ -43,7 +43,7 @@ void render_line_to_quad(const render_bounds *bounds, float width, float length_
void render_load_jpeg(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename);
bool render_load_png(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename, bool load_as_alpha_to_existing = false);
ru_imgformat render_detect_image(emu_file &file, const char *dirname, const char *filename);
-bool render_detect_and_open_video(emu_file &file, const char *dirname, const char *filename, std::unique_ptr<avi_file> &video);
+bool render_detect_and_open_video(emu_file &file, const char *artpath, const char *dirname, const char *filename, std::unique_ptr<avi_file> &video);
diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp
index 8722017d3e8..7cc7595f46b 100644
--- a/src/lib/util/aviio.cpp
+++ b/src/lib/util/aviio.cpp
@@ -367,7 +367,7 @@ public:
// Uncompressed helpers
avi_file::error uncompressed_rgb24_to_argb32(const std::uint8_t *data, std::uint32_t numbytes, bitmap_argb32 &bitmap) const;
- avi_file::error uncompressed_yuv420p_to_argb32(const std::uint8_t *data, std::uint32_t numbytes, bitmap_argb32 &bitmap) const;
+ avi_file::error uncompressed_yuv420p_to_argb32(const std::uint8_t* data, std::uint32_t numbytes, bitmap_argb32& bitmap) const;
private:
struct huffyuv_table
@@ -1056,31 +1056,55 @@ avi_file::error avi_stream::rgb32_compress_to_rgb(const bitmap_rgb32 &bitmap, st
avi_file::error avi_stream::yuv_decompress_to_yuy16(const std::uint8_t *data, std::uint32_t numbytes, bitmap_yuy16 &bitmap) const
{
auto const *const dataend = reinterpret_cast<const std::uint16_t *>(data + numbytes);
- int x, y;
/* compressed video */
- for (y = 0; y < m_height; y++)
+ for (int y = 0; y < m_height; y++)
{
- const std::uint16_t *source = reinterpret_cast<const std::uint16_t *>(data) + y * m_width;
std::uint16_t *dest = &bitmap.pix16(y);
/* switch off the compression */
switch (m_format)
{
case FORMAT_UYVY:
- for (x = 0; x < m_width && source < dataend; x++)
+ {
+ const std::uint16_t* source = reinterpret_cast<const std::uint16_t*>(data) + y * m_width;
+ for (int x = 0; x < m_width && source < dataend; x++)
*dest++ = *source++;
break;
+ }
+
+ case FORMAT_Y42B:
+ {
+ const uint32_t y_size = m_width * m_height;
+ const uint32_t y_start = m_width * y;
+ const uint32_t uv_size = (m_width >> 1) * (m_height >> 1);
+ const uint32_t uv_start = (m_width >> 1) * y;
+ const uint32_t u_start = y_size + uv_start;
+ const uint32_t v_start = y_size + uv_size + uv_start;
+ for (int x = 0; x < m_width; x += 2)
+ {
+ const uint8_t y0 = data[y_start + x];
+ const uint8_t y1 = data[y_start + x + 1];
+ const uint8_t u = data[u_start + (x >> 1)];
+ const uint8_t v = data[v_start + (x >> 1)];
+ *dest++ = ((uint16_t)y0 << 8) | u;
+ *dest++ = ((uint16_t)y1 << 8) | v;
+ }
+ break;
+ }
case FORMAT_VYUY:
case FORMAT_YUY2:
- for (x = 0; x < m_width && source < dataend; x++)
+ {
+ const std::uint16_t* source = reinterpret_cast<const std::uint16_t*>(data) + y * m_width;
+ for (int x = 0; x < m_width && source < dataend; x++)
{
std::uint16_t pix = *source++;
*dest++ = (pix >> 8) | (pix << 8);
}
break;
}
+ }
}
return avi_file::error::NONE;
@@ -1686,7 +1710,12 @@ avi_file::error avi_file_impl::read_uncompressed_video_frame(std::uint32_t frame
if (!stream)
return error::INVALID_STREAM;
- if (stream->format() != FORMAT_UNCOMPRESSED && stream->format() != FORMAT_DIB && stream->format() != FORMAT_RGB && stream->format() != FORMAT_RAW && stream->format() != FORMAT_I420)
+ if (stream->format() != FORMAT_UNCOMPRESSED &&
+ stream->format() != FORMAT_DIB &&
+ stream->format() != FORMAT_RGB &&
+ stream->format() != FORMAT_RAW &&
+ stream->format() != FORMAT_I420 &&
+ stream->format() != FORMAT_Y42B)
return error::UNSUPPORTED_VIDEO_FORMAT;
if (bitmap.width() < stream->width() || bitmap.height() < stream->height())
@@ -1717,10 +1746,16 @@ avi_file::error avi_file_impl::read_uncompressed_video_frame(std::uint32_t frame
if (chunkid == get_chunkid_for_stream(stream))
{
/* uncompressed YUV420p */
- if (stream->format() == FORMAT_I420)
+ switch (stream->format())
+ {
+ case FORMAT_I420:
+ case FORMAT_Y42B:
avierr = stream->uncompressed_yuv420p_to_argb32(&m_tempbuffer[8], stream->chunk(framenum).length - 8, bitmap);
- else
+ break;
+ default:
avierr = stream->uncompressed_rgb24_to_argb32(&m_tempbuffer[8], stream->chunk(framenum).length - 8, bitmap);
+ break;
+ }
}
else
{
diff --git a/src/lib/util/aviio.h b/src/lib/util/aviio.h
index c951f71b22f..969e6df0872 100644
--- a/src/lib/util/aviio.h
+++ b/src/lib/util/aviio.h
@@ -28,6 +28,7 @@
#define FORMAT_UYVY AVI_FOURCC('U','Y','V','Y')
#define FORMAT_VYUY AVI_FOURCC('V','Y','U','Y')
#define FORMAT_YUY2 AVI_FOURCC('Y','U','Y','2')
+#define FORMAT_Y42B AVI_FOURCC('Y','4','2','B')
#define FORMAT_HFYU AVI_FOURCC('H','F','Y','U')
#define FORMAT_I420 AVI_FOURCC('I','4','2','0')
#define FORMAT_DIB AVI_FOURCC('D','I','B',' ')