diff options
author | 2020-09-27 14:00:42 +1000 | |
---|---|---|
committer | 2020-09-27 14:00:42 +1000 | |
commit | a1d35e5abf431e03e06d55b96379a3b14753ed4d (patch) | |
tree | 506ffe906e707f50eca2306da80b1657644e0507 /src/lib/util/avhuff.cpp | |
parent | d294948a3bb8c6e8fdbc96841ceae30ec6687870 (diff) |
Cleaned up bitmap API.
Made const-qualified pixel accessors (pix, pixt, raw_pixptr) return
const-qualified references/pointers to pixesl, and added non-const
versions. This makes bitmap more like standard library containers where
const protects the content as well as the dimensions.
Made the templated pixt accessor protected - having it public makes it
too easy to inadvertently get a pointer to the wrong location.
Removed the pix(8|16|32|64) accessors from the specific bitmaps. You
could only use the "correct" one anyway, and having the "incorrect" ones
available prevented explicit instantiations of the class template
because the static assertions would fail. You can still see the pixel
type in the bitmap class names, and you can't assign the result of
&pix(y, x) to the wrong kind of pointer without a cast.
Added fill member functions to the specific bitmap template, and added
a explicit instantiations. This allows the bitmap size check to be
skipped on most bitmap fills, although the clipping check is still
there. Also fixed a couple of places that were trying to fill an
indexed 16-bit bitmap with rgb_t::black() exposed by this (replaced with
zero to get the same net effect). The explicit template instantiations
in the .cpp file mean the compiler can inline the function if necessary,
but don't need to generate a local out-of-line body if it chooses not
to.
Extended the size of the fill value parameter in the base bitmap class
to 64 bits so it works correctly for 64-bit bitmaps.
Fixed places where IE15 and VGM visualiser weren't accounting for row
bytes potentially being larger than width.
Fixed an off-by-one in an HP-DIO card where it was treating the Topcat
cursor right edge as exclusive.
Updated everything to work with the API changes, reduced the scope of
many variables, added more const, and replaced a few fill/copy loops
with stuff from <algorithm>.
Diffstat (limited to 'src/lib/util/avhuff.cpp')
-rw-r--r-- | src/lib/util/avhuff.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/lib/util/avhuff.cpp b/src/lib/util/avhuff.cpp index 50eea9f24dc..ac5cea71526 100644 --- a/src/lib/util/avhuff.cpp +++ b/src/lib/util/avhuff.cpp @@ -691,24 +691,19 @@ avhuff_decoder::avhuff_decoder() } /** - * @fn void avhuff_decoder::configure(const avhuff_decompress_config &config) + * @fn void avhuff_decoder::configure(const config &cfg) * * @brief ------------------------------------------------- * configure - configure decompression parameters * -------------------------------------------------. * - * @param config The configuration. + * @param cfg The configuration. */ -void avhuff_decoder::configure(const avhuff_decompress_config &config) +void avhuff_decoder::configure(const config &cfg) { - m_config.video.wrap(config.video, config.video.cliprect()); - m_config.maxsamples = config.maxsamples; - m_config.actsamples = config.actsamples; - memcpy(m_config.audio, config.audio, sizeof(m_config.audio)); - m_config.maxmetalength = config.maxmetalength; - m_config.actmetalength = config.actmetalength; - m_config.metadata = config.metadata; + m_video.wrap(*cfg.video, cfg.video->cliprect()); + m_config = cfg; } /** @@ -792,9 +787,9 @@ avhuff_error avhuff_decoder::decode_data(const uint8_t *source, uint32_t complen // determine the start of each piece of data metastart = m_config.metadata; for (int chnum = 0; chnum < channels; chnum++) - audiostart[chnum] = (uint8_t *)m_config.audio[chnum]; - videostart = (m_config.video.valid()) ? reinterpret_cast<uint8_t *>(&m_config.video.pix(0)) : nullptr; - videostride = (m_config.video.valid()) ? m_config.video.rowpixels() * 2 : 0; + audiostart[chnum] = reinterpret_cast<uint8_t *>(m_config.audio[chnum]); + videostart = m_video.valid() ? reinterpret_cast<uint8_t *>(&m_video.pix(0)) : nullptr; + videostride = m_video.valid() ? m_video.rowpixels() * 2 : 0; // data is assumed to be native-endian uint16_t betest = 0; @@ -802,7 +797,7 @@ avhuff_error avhuff_decoder::decode_data(const uint8_t *source, uint32_t complen audioxor = videoxor = (betest == 1) ? 1 : 0; // verify against sizes - if (m_config.video.valid() && (m_config.video.width() < width || m_config.video.height() < height)) + if (m_video.valid() && (m_video.width() < width || m_video.height() < height)) return AVHERR_VIDEO_TOO_LARGE; for (int chnum = 0; chnum < channels; chnum++) if (m_config.audio[chnum] != nullptr && m_config.maxsamples < samples) |