summaryrefslogtreecommitdiff
path: root/src/lib/image.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-02-20 11:51:12 +0000
committerCarl Hetherington <cth@carlh.net>2013-02-20 11:51:12 +0000
commitdc08d2da6bf14fd469005ea3512992c66b041da9 (patch)
tree0bd7a60cfa4cfe21732f648ed25299db79e7920a /src/lib/image.cc
parent490af0bac5ec51120f6fed9c5b8b1a0c01427e45 (diff)
Fix servomatic build. Hopefully resolve confusion wrt linesize and
stride for FilterBufferImage; the linesize can apparently sometimes be (slightly) larger than the width for byte-per-pixel images (e.g. YUV420P). Remove grotty peek-style socket communication and use a hopefully more robust send of the length of data as a binary word before the data itself. Should fix #62.
Diffstat (limited to 'src/lib/image.cc')
-rw-r--r--src/lib/image.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 0ec6bd26c..73d499fe8 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -323,7 +323,7 @@ Image::read_from_socket (shared_ptr<Socket> socket)
for (int i = 0; i < components(); ++i) {
uint8_t* p = data()[i];
for (int y = 0; y < lines(i); ++y) {
- socket->read_definite_and_consume (p, line_size()[i], 30);
+ socket->read (p, line_size()[i]);
p += stride()[i];
}
}
@@ -335,7 +335,7 @@ Image::write_to_socket (shared_ptr<Socket> socket) const
for (int i = 0; i < components(); ++i) {
uint8_t* p = data()[i];
for (int y = 0; y < lines(i); ++y) {
- socket->write (p, line_size()[i], 30);
+ socket->write (p, line_size()[i]);
p += stride()[i];
}
}
@@ -503,12 +503,18 @@ FilterBufferImage::FilterBufferImage (AVPixelFormat p, AVFilterBufferRef* b)
: Image (p)
, _buffer (b)
{
-
+ _line_size = (int *) av_malloc (4 * sizeof (int));
+ _line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0;
+
+ for (int i = 0; i < components(); ++i) {
+ _line_size[i] = size().width * bytes_per_pixel(i);
+ }
}
FilterBufferImage::~FilterBufferImage ()
{
avfilter_unref_buffer (_buffer);
+ av_free (_line_size);
}
uint8_t **
@@ -520,13 +526,16 @@ FilterBufferImage::data () const
int *
FilterBufferImage::line_size () const
{
- return _buffer->linesize;
+ return _line_size;
}
int *
FilterBufferImage::stride () const
{
- /* XXX? */
+ /* I've seen images where the _buffer->linesize is larger than the width
+ (by a small amount), suggesting that _buffer->linesize is what we call
+ stride. But I'm not sure.
+ */
return _buffer->linesize;
}