summaryrefslogtreecommitdiff
path: root/src/lib/image.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-01-09 16:29:21 +0100
committerCarl Hetherington <cth@carlh.net>2022-01-09 16:29:21 +0100
commit92b7d1cffbd0d457f8b4b23cc72937bcf8e5ed5e (patch)
treeb175db682422765468991702e8563bcd89713b70 /src/lib/image.cc
parent7392cb8383c9b857edad5f99eaf917ed70da237d (diff)
Tidying.
Diffstat (limited to 'src/lib/image.cc')
-rw-r--r--src/lib/image.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index c6d2345a8..17bab64c7 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -106,6 +106,7 @@ Image::horizontal_factor (int n) const
return lrintf(powf(2.0f, d->log2_chroma_w));
}
+
/** @param n Component index.
* @return Number of samples (i.e. pixels, unless sub-sampled) in each direction for this component.
*/
@@ -118,6 +119,7 @@ Image::sample_size (int n) const
);
}
+
/** @return Number of planes */
int
Image::planes () const
@@ -308,12 +310,14 @@ Image::crop_scale_window (
return out;
}
+
shared_ptr<Image>
Image::convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, Alignment out_alignment, bool fast) const
{
return scale(size(), yuv_to_rgb, out_format, out_alignment, fast);
}
+
/** @param out_size Size to scale to.
* @param yuv_to_rgb YUVToRGB transform transform to use, if required.
* @param out_format Output pixel format.
@@ -372,6 +376,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo
return scaled;
}
+
/** Blacken a YUV image whose bits per pixel is rounded up to 16 */
void
Image::yuv_16_black (uint16_t v, bool alpha)
@@ -394,12 +399,14 @@ Image::yuv_16_black (uint16_t v, bool alpha)
}
}
+
uint16_t
Image::swap_16 (uint16_t v)
{
return ((v >> 8) & 0xff) | ((v & 0xff) << 8);
}
+
void
Image::make_part_black (int const start, int const width)
{
@@ -470,6 +477,7 @@ Image::make_part_black (int const start, int const width)
}
}
+
void
Image::make_black ()
{
@@ -585,6 +593,7 @@ Image::make_black ()
}
}
+
void
Image::make_transparent ()
{
@@ -595,6 +604,7 @@ Image::make_transparent ()
memset (data()[0], 0, sample_size(0).height * stride()[0]);
}
+
void
Image::alpha_blend (shared_ptr<const Image> other, Position<int> position)
{
@@ -841,6 +851,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position)
}
}
+
void
Image::copy (shared_ptr<const Image> other, Position<int> position)
{
@@ -856,6 +867,7 @@ Image::copy (shared_ptr<const Image> other, Position<int> position)
}
}
+
void
Image::read_from_socket (shared_ptr<Socket> socket)
{
@@ -869,6 +881,7 @@ Image::read_from_socket (shared_ptr<Socket> socket)
}
}
+
void
Image::write_to_socket (shared_ptr<Socket> socket) const
{
@@ -882,6 +895,7 @@ Image::write_to_socket (shared_ptr<Socket> socket) const
}
}
+
float
Image::bytes_per_pixel (int c) const
{
@@ -928,6 +942,7 @@ Image::bytes_per_pixel (int c) const
return bpp[c];
}
+
/** Construct a Image of a given size and format, allocating memory
* as required.
*
@@ -1007,6 +1022,7 @@ Image::allocate ()
}
}
+
Image::Image (Image const & other)
: std::enable_shared_from_this<Image>(other)
, _size (other._size)
@@ -1027,6 +1043,7 @@ Image::Image (Image const & other)
}
}
+
Image::Image (AVFrame const * frame, Alignment alignment)
: _size (frame->width, frame->height)
, _pixel_format (static_cast<AVPixelFormat>(frame->format))
@@ -1049,6 +1066,7 @@ Image::Image (AVFrame const * frame, Alignment alignment)
}
}
+
Image::Image (shared_ptr<const Image> other, Alignment alignment)
: _size (other->_size)
, _pixel_format (other->_pixel_format)
@@ -1069,6 +1087,7 @@ Image::Image (shared_ptr<const Image> other, Alignment alignment)
}
}
+
Image&
Image::operator= (Image const & other)
{
@@ -1081,6 +1100,7 @@ Image::operator= (Image const & other)
return *this;
}
+
void
Image::swap (Image & other)
{
@@ -1096,6 +1116,7 @@ Image::swap (Image & other)
std::swap (_alignment, other._alignment);
}
+
Image::~Image ()
{
for (int i = 0; i < planes(); ++i) {
@@ -1107,30 +1128,35 @@ Image::~Image ()
av_free (_stride);
}
+
uint8_t * const *
Image::data () const
{
return _data;
}
+
int const *
Image::line_size () const
{
return _line_size;
}
+
int const *
Image::stride () const
{
return _stride;
}
+
dcp::Size
Image::size () const
{
return _size;
}
+
Image::Alignment
Image::alignment () const
{
@@ -1193,6 +1219,7 @@ operator== (Image const & a, Image const & b)
return true;
}
+
/** Fade the image.
* @param f Amount to fade by; 0 is black, 1 is no fade.
*/