sws_scale (
scale_context,
- data(), line_size(),
+ data(), stride(),
0, size().height,
- scaled->data (), scaled->line_size ()
+ scaled->data(), scaled->stride()
);
sws_freeContext (scale_context);
/* Scale and convert to RGB from whatever its currently in (which may be RGB) */
sws_scale (
scale_context,
- data(), line_size(),
+ data(), stride(),
0, size().height,
- rgb->data (), rgb->line_size ()
+ rgb->data(), rgb->stride()
);
/* Put the image in the right place in a black frame if are padding; this is
uint8_t* q = rgb->data()[0];
for (int j = 0; j < rgb->lines(0); ++j) {
memcpy (p, q, rgb->line_size()[0]);
- p += padded_rgb->line_size()[0];
- q += rgb->line_size()[0];
+ p += padded_rgb->stride()[0];
+ q += rgb->stride()[0];
}
rgb = padded_rgb;
pp_context* context = pp_get_context (size().width, size().height, PP_FORMAT_420 | PP_CPU_CAPS_MMX2);
pp_postprocess (
- (const uint8_t **) data(), line_size(),
- out->data(), out->line_size(),
+ (const uint8_t **) data(), stride(),
+ out->data(), out->stride(),
size().width, size().height,
0, 0, mode, context, 0
);
{
switch (_pixel_format) {
case PIX_FMT_YUV420P:
- memset (data()[0], 0, lines(0) * line_size()[0]);
- memset (data()[1], 0x80, lines(1) * line_size()[1]);
- memset (data()[2], 0x80, lines(2) * line_size()[2]);
+ memset (data()[0], 0, lines(0) * stride()[0]);
+ memset (data()[1], 0x80, lines(1) * stride()[1]);
+ memset (data()[2], 0x80, lines(2) * stride()[2]);
break;
case PIX_FMT_RGB24:
- memset (data()[0], 0, lines(0) * line_size()[0]);
+ memset (data()[0], 0, lines(0) * stride()[0]);
break;
default:
}
for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) {
- uint8_t* tp = data()[0] + ty * line_size()[0] + position.x * 3;
- uint8_t* op = other->data()[0] + oy * other->line_size()[0];
+ uint8_t* tp = data()[0] + ty * stride()[0] + position.x * 3;
+ uint8_t* op = other->data()[0] + oy * other->stride()[0];
for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) {
float const alpha = float (op[3]) / 255;
tp[0] = (tp[0] * (1 - alpha)) + op[0] * alpha;
_data[0] = _data[1] = _data[2] = _data[3] = 0;
_line_size = (int *) av_malloc (4);
_line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0;
+ _stride = (int *) av_malloc (4);
+ _stride[0] = _stride[1] = _stride[2] = _stride[3] = 0;
switch (p) {
case PIX_FMT_RGB24:
- _line_size[0] = round_up (s.width * 3, 32);
+ _line_size[0] = s.width * 3;
break;
case PIX_FMT_RGBA:
- _line_size[0] = round_up (s.width * 4, 32);
+ _line_size[0] = s.width * 4;
break;
case PIX_FMT_YUV420P:
- _line_size[0] = round_up (s.width, 32);
- _line_size[1] = round_up (s.width / 2, 32);
- _line_size[2] = round_up (s.width / 2, 32);
+ _line_size[0] = s.width;
+ _line_size[1] = s.width / 2;
+ _line_size[2] = s.width / 2;
break;
default:
assert (false);
}
-
+
for (int i = 0; i < components(); ++i) {
- _data[i] = (uint8_t *) av_malloc (_line_size[i] * lines (i));
+ _stride[i] = round_up (_line_size[i], 32);
+ _data[i] = (uint8_t *) av_malloc (_stride[i] * lines (i));
}
}
av_free (_data);
av_free (_line_size);
+ av_free (_stride);
}
uint8_t **
return _line_size;
}
+int *
+SimpleImage::stride () const
+{
+ return _stride;
+}
+
Size
SimpleImage::size () const
{
return _buffer->linesize;
}
+int *
+FilterBufferImage::stride () const
+{
+ /* XXX? */
+ return _buffer->linesize;
+}
+
Size
FilterBufferImage::size () const
{
return _frame->linesize;
}
+int *
+RGBFrameImage::stride () const
+{
+ /* XXX? */
+ return line_size ();
+}
+
Size
RGBFrameImage::size () const
{
/** @return Array of pointers to arrays of the component data */
virtual uint8_t ** data () const = 0;
- /** @return Array of sizes of each line, in pixels */
+ /** @return Array of sizes of the data in each line, in bytes (without any alignment padding bytes) */
virtual int * line_size () const = 0;
+ /** @return Array of strides for each line (including any alignment padding bytes) */
+ virtual int * stride () const = 0;
+
/** @return Size of the image, in pixels */
virtual Size size () const = 0;
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
private:
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
private:
Size _size; ///< size in pixels
uint8_t** _data; ///< array of pointers to components
- int* _line_size; ///< array of widths of each line, in bytes
+ int* _line_size; ///< array of sizes of the data in each line, in pixels (without any alignment padding bytes)
+ int* _stride; ///< array of strides for each line (including any alignment padding bytes)
+
};
/** @class RGBFrameImage
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
AVFrame * frame () const {
return _frame;