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.
*/
);
}
+
/** @return Number of planes */
int
Image::planes () const
{
+ if (_pixel_format == AV_PIX_FMT_PAL8) {
+ return 2;
+ }
+
auto d = av_pix_fmt_desc_get(_pixel_format);
if (!d) {
throw PixelFormatError ("planes()", _pixel_format);
}
- if (_pixel_format == AV_PIX_FMT_PAL8) {
- return 2;
- }
-
if ((d->flags & AV_PIX_FMT_FLAG_PLANAR) == 0) {
return 1;
}
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.
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)
}
}
+
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)
{
}
}
+
void
Image::make_black ()
{
}
}
+
void
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)
{
}
}
+
void
Image::copy (shared_ptr<const Image> other, Position<int> position)
{
}
}
+
void
Image::read_from_socket (shared_ptr<Socket> socket)
{
}
}
+
void
Image::write_to_socket (shared_ptr<Socket> socket) const
{
}
}
+
float
Image::bytes_per_pixel (int c) const
{
return bpp[c];
}
+
/** Construct a Image of a given size and format, allocating memory
* as required.
*
}
}
+
Image::Image (Image const & other)
: std::enable_shared_from_this<Image>(other)
, _size (other._size)
}
}
+
Image::Image (AVFrame const * frame, Alignment alignment)
: _size (frame->width, frame->height)
, _pixel_format (static_cast<AVPixelFormat>(frame->format))
}
}
+
Image::Image (shared_ptr<const Image> other, Alignment alignment)
: _size (other->_size)
, _pixel_format (other->_pixel_format)
}
}
+
Image&
Image::operator= (Image const & other)
{
return *this;
}
+
void
Image::swap (Image & other)
{
std::swap (_alignment, other._alignment);
}
+
Image::~Image ()
{
for (int i = 0; i < planes(); ++i) {
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
{
return true;
}
+
/** Fade the image.
* @param f Amount to fade by; 0 is black, 1 is no fade.
*/
return m;
}
+
class Memory
{
public:
size_t size;
};
+
static void
png_write_data (png_structp png_ptr, png_bytep data, png_size_t length)
{
mem->size += length;
}
+
static void
png_flush (png_structp)
{
}
+
static void
png_error_fn (png_structp png_ptr, char const * message)
{
reinterpret_cast<Image*>(png_get_error_ptr(png_ptr))->png_error (message);
}
+
void
Image::png_error (char const * message)
{
throw EncodeError (String::compose ("Error during PNG write: %1", message));
}
+
dcp::ArrayData
Image::as_png () const
{