projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
129afab
)
Try to clarify the difference between line size and stride.
author
Carl Hetherington
<cth@carlh.net>
Sun, 14 Oct 2012 19:51:43 +0000
(20:51 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Sun, 14 Oct 2012 19:51:43 +0000
(20:51 +0100)
src/lib/ab_transcoder.cc
patch
|
blob
|
history
src/lib/dcp_video_frame.cc
patch
|
blob
|
history
src/lib/image.cc
patch
|
blob
|
history
src/lib/image.h
patch
|
blob
|
history
src/lib/server.cc
patch
|
blob
|
history
diff --git
a/src/lib/ab_transcoder.cc
b/src/lib/ab_transcoder.cc
index a32d82c54bef9625c20c6383c35ec021d2cf9615..54153ec765f0304b1ac081c5010111627fce997d 100644
(file)
--- a/
src/lib/ab_transcoder.cc
+++ b/
src/lib/ab_transcoder.cc
@@
-80,14
+80,15
@@
ABTranscoder::process_video (shared_ptr<Image> yuv, int frame, shared_ptr<Subtit
for (int i = 0; i < yuv->components(); ++i) {
int const line_size = yuv->line_size()[i];
int const half_line_size = line_size / 2;
for (int i = 0; i < yuv->components(); ++i) {
int const line_size = yuv->line_size()[i];
int const half_line_size = line_size / 2;
+ int const stride = yuv->stride()[i];
uint8_t* p = _image->data()[i];
uint8_t* q = yuv->data()[i];
for (int j = 0; j < yuv->lines (i); ++j) {
memcpy (p + half_line_size, q + half_line_size, half_line_size);
uint8_t* p = _image->data()[i];
uint8_t* q = yuv->data()[i];
for (int j = 0; j < yuv->lines (i); ++j) {
memcpy (p + half_line_size, q + half_line_size, half_line_size);
- p +=
line_siz
e;
- q +=
line_siz
e;
+ p +=
strid
e;
+ q +=
strid
e;
}
}
}
}
diff --git
a/src/lib/dcp_video_frame.cc
b/src/lib/dcp_video_frame.cc
index 3e5c4b3aaa4cb5b7433712d8215ea14351a7b1a2..04735269cde58f68d5f35b1b50d1035d70484727 100644
(file)
--- a/
src/lib/dcp_video_frame.cc
+++ b/
src/lib/dcp_video_frame.cc
@@
-188,7
+188,7
@@
DCPVideoFrame::encode_locally ()
int jn = 0;
for (int y = 0; y < _out_size.height; ++y) {
int jn = 0;
for (int y = 0; y < _out_size.height; ++y) {
- uint8_t* p = prepared->data()[0] + y * prepared->
line_siz
e()[0];
+ uint8_t* p = prepared->data()[0] + y * prepared->
strid
e()[0];
for (int x = 0; x < _out_size.width; ++x) {
/* In gamma LUT (converting 8-bit input to 12-bit) */
for (int x = 0; x < _out_size.width; ++x) {
/* In gamma LUT (converting 8-bit input to 12-bit) */
@@
-332,7
+332,7
@@
DCPVideoFrame::encode_remotely (ServerDescription const * serv)
socket.write ((uint8_t *) s.str().c_str(), s.str().length() + 1, 30);
for (int i = 0; i < _input->components(); ++i) {
socket.write ((uint8_t *) s.str().c_str(), s.str().length() + 1, 30);
for (int i = 0; i < _input->components(); ++i) {
- socket.write (_input->data()[i], _input->
line_siz
e()[i] * _input->lines(i), 30);
+ socket.write (_input->data()[i], _input->
strid
e()[i] * _input->lines(i), 30);
}
char buffer[32];
}
char buffer[32];
diff --git
a/src/lib/image.cc
b/src/lib/image.cc
index c8849303cac99e8ed01c1e6f6d5e80bffade6706..2c0338b5357c8b0b7199a6c6ecf9ad68018b4481 100644
(file)
--- a/
src/lib/image.cc
+++ b/
src/lib/image.cc
@@
-98,9
+98,9
@@
Image::scale (Size out_size, Scaler const * scaler) const
sws_scale (
scale_context,
sws_scale (
scale_context,
- data(),
line_siz
e(),
+ data(),
strid
e(),
0, size().height,
0, size().height,
- scaled->data
(), scaled->line_size
()
+ scaled->data
(), scaled->stride
()
);
sws_freeContext (scale_context);
);
sws_freeContext (scale_context);
@@
-131,9
+131,9
@@
Image::scale_and_convert_to_rgb (Size out_size, int padding, Scaler const * scal
/* Scale and convert to RGB from whatever its currently in (which may be RGB) */
sws_scale (
scale_context,
/* Scale and convert to RGB from whatever its currently in (which may be RGB) */
sws_scale (
scale_context,
- data(),
line_siz
e(),
+ data(),
strid
e(),
0, size().height,
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
);
/* Put the image in the right place in a black frame if are padding; this is
@@
-151,8
+151,8
@@
Image::scale_and_convert_to_rgb (Size out_size, int padding, Scaler const * scal
uint8_t* q = rgb->data()[0];
for (int j = 0; j < rgb->lines(0); ++j) {
memcpy (p, q, rgb->line_size()[0]);
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_siz
e()[0];
- q += rgb->
line_siz
e()[0];
+ p += padded_rgb->
strid
e()[0];
+ q += rgb->
strid
e()[0];
}
rgb = padded_rgb;
}
rgb = padded_rgb;
@@
-176,8
+176,8
@@
Image::post_process (string pp) const
pp_context* context = pp_get_context (size().width, size().height, PP_FORMAT_420 | PP_CPU_CAPS_MMX2);
pp_postprocess (
pp_context* context = pp_get_context (size().width, size().height, PP_FORMAT_420 | PP_CPU_CAPS_MMX2);
pp_postprocess (
- (const uint8_t **) data(),
line_siz
e(),
- out->data(), out->
line_siz
e(),
+ (const uint8_t **) data(),
strid
e(),
+ out->data(), out->
strid
e(),
size().width, size().height,
0, 0, mode, context, 0
);
size().width, size().height,
0, 0, mode, context, 0
);
@@
-193,13
+193,13
@@
Image::make_black ()
{
switch (_pixel_format) {
case PIX_FMT_YUV420P:
{
switch (_pixel_format) {
case PIX_FMT_YUV420P:
- memset (data()[0], 0, lines(0) *
line_siz
e()[0]);
- memset (data()[1], 0x80, lines(1) *
line_siz
e()[1]);
- memset (data()[2], 0x80, lines(2) *
line_siz
e()[2]);
+ memset (data()[0], 0, lines(0) *
strid
e()[0]);
+ memset (data()[1], 0x80, lines(1) *
strid
e()[1]);
+ memset (data()[2], 0x80, lines(2) *
strid
e()[2]);
break;
case PIX_FMT_RGB24:
break;
case PIX_FMT_RGB24:
- memset (data()[0], 0, lines(0) *
line_siz
e()[0]);
+ memset (data()[0], 0, lines(0) *
strid
e()[0]);
break;
default:
break;
default:
@@
-230,8
+230,8
@@
Image::alpha_blend (shared_ptr<Image> other, Position position)
}
for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) {
}
for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) {
- uint8_t* tp = data()[0] + ty *
line_siz
e()[0] + position.x * 3;
- uint8_t* op = other->data()[0] + oy * other->
line_siz
e()[0];
+ uint8_t* tp = data()[0] + ty *
strid
e()[0] + position.x * 3;
+ uint8_t* op = other->data()[0] + oy * other->
strid
e()[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;
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;
@@
-257,25
+257,28
@@
SimpleImage::SimpleImage (PixelFormat p, Size s)
_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;
_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:
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:
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:
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);
}
break;
default:
assert (false);
}
-
+
for (int i = 0; i < components(); ++i) {
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));
}
}
}
}
@@
-288,6
+291,7
@@
SimpleImage::~SimpleImage ()
av_free (_data);
av_free (_line_size);
av_free (_data);
av_free (_line_size);
+ av_free (_stride);
}
uint8_t **
}
uint8_t **
@@
-302,6
+306,12
@@
SimpleImage::line_size () const
return _line_size;
}
return _line_size;
}
+int *
+SimpleImage::stride () const
+{
+ return _stride;
+}
+
Size
SimpleImage::size () const
{
Size
SimpleImage::size () const
{
@@
-333,6
+343,13
@@
FilterBufferImage::line_size () const
return _buffer->linesize;
}
return _buffer->linesize;
}
+int *
+FilterBufferImage::stride () const
+{
+ /* XXX? */
+ return _buffer->linesize;
+}
+
Size
FilterBufferImage::size () const
{
Size
FilterBufferImage::size () const
{
@@
-377,6
+394,13
@@
RGBFrameImage::line_size () const
return _frame->linesize;
}
return _frame->linesize;
}
+int *
+RGBFrameImage::stride () const
+{
+ /* XXX? */
+ return line_size ();
+}
+
Size
RGBFrameImage::size () const
{
Size
RGBFrameImage::size () const
{
diff --git
a/src/lib/image.h
b/src/lib/image.h
index ea35fa0b9aee6dfc1f482e069ba71b4dd223c850..3e16d43bfff220a4ceeb22a82b999976f35c054f 100644
(file)
--- a/
src/lib/image.h
+++ b/
src/lib/image.h
@@
-57,9
+57,12
@@
public:
/** @return Array of pointers to arrays of the component data */
virtual uint8_t ** data () const = 0;
/** @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;
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;
/** @return Size of the image, in pixels */
virtual Size size () const = 0;
@@
-91,6
+94,7
@@
public:
uint8_t ** data () const;
int * line_size () const;
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
private:
Size size () const;
private:
@@
-108,12
+112,15
@@
public:
uint8_t ** data () const;
int * line_size () const;
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
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
};
/** @class RGBFrameImage
@@
-127,6
+134,7
@@
public:
uint8_t ** data () const;
int * line_size () const;
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
AVFrame * frame () const {
return _frame;
Size size () const;
AVFrame * frame () const {
return _frame;
diff --git
a/src/lib/server.cc
b/src/lib/server.cc
index 26b2be7c7e7362a4dae54ad41fe24bb6a8033f7c..659418b8f9a60ddeacc75c110718a4da558e2139 100644
(file)
--- a/
src/lib/server.cc
+++ b/
src/lib/server.cc
@@
-119,7
+119,7
@@
Server::process (shared_ptr<Socket> socket)
shared_ptr<Image> image (new SimpleImage (pixel_format, in_size));
for (int i = 0; i < image->components(); ++i) {
shared_ptr<Image> image (new SimpleImage (pixel_format, in_size));
for (int i = 0; i < image->components(); ++i) {
- socket->read_definite_and_consume (image->data()[i], image->
line_siz
e()[i] * image->lines(i), 30);
+ socket->read_definite_and_consume (image->data()[i], image->
strid
e()[i] * image->lines(i), 30);
}
/* XXX: subtitle */
}
/* XXX: subtitle */