summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-14 20:29:20 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-14 20:29:20 +0100
commit129afab72bfc026b5704c41a6bfc0f4b3a2c4033 (patch)
treecb24e2c035f9ac8e21f307e76defcc88bf343145 /src
parent49f9cb10018bf4ec07a60d1599cbe62d735baa23 (diff)
Round image line sizes up to 32. Seems to help with LHS image corruption with both crop and a post-processing filter.
Diffstat (limited to 'src')
-rw-r--r--src/lib/dcp_video_frame.cc58
-rw-r--r--src/lib/filter.cc1
-rw-r--r--src/lib/image.cc10
-rw-r--r--src/lib/util.cc7
-rw-r--r--src/lib/util.h1
5 files changed, 49 insertions, 28 deletions
diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc
index ce660add5..3e5c4b3aa 100644
--- a/src/lib/dcp_video_frame.cc
+++ b/src/lib/dcp_video_frame.cc
@@ -176,8 +176,6 @@ DCPVideoFrame::encode_locally ()
create_openjpeg_container ();
- int const size = _out_size.width * _out_size.height;
-
struct {
double r, g, b;
} s;
@@ -188,27 +186,41 @@ DCPVideoFrame::encode_locally ()
/* Copy our RGB into the openjpeg container, converting to XYZ in the process */
- uint8_t* p = prepared->data()[0];
- for (int i = 0; i < size; ++i) {
- /* In gamma LUT (converting 8-bit input to 12-bit) */
- s.r = lut_in[_colour_lut_index][*p++ << 4];
- s.g = lut_in[_colour_lut_index][*p++ << 4];
- s.b = lut_in[_colour_lut_index][*p++ << 4];
-
- /* RGB to XYZ Matrix */
- d.x = ((s.r * color_matrix[_colour_lut_index][0][0]) + (s.g * color_matrix[_colour_lut_index][0][1]) + (s.b * color_matrix[_colour_lut_index][0][2]));
- d.y = ((s.r * color_matrix[_colour_lut_index][1][0]) + (s.g * color_matrix[_colour_lut_index][1][1]) + (s.b * color_matrix[_colour_lut_index][1][2]));
- d.z = ((s.r * color_matrix[_colour_lut_index][2][0]) + (s.g * color_matrix[_colour_lut_index][2][1]) + (s.b * color_matrix[_colour_lut_index][2][2]));
-
- /* DCI companding */
- d.x = d.x * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
- d.y = d.y * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
- d.z = d.z * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
-
- /* Out gamma LUT */
- _image->comps[0].data[i] = lut_out[LO_DCI][(int) d.x];
- _image->comps[1].data[i] = lut_out[LO_DCI][(int) d.y];
- _image->comps[2].data[i] = lut_out[LO_DCI][(int) d.z];
+ int jn = 0;
+ for (int y = 0; y < _out_size.height; ++y) {
+ uint8_t* p = prepared->data()[0] + y * prepared->line_size()[0];
+ for (int x = 0; x < _out_size.width; ++x) {
+
+ /* In gamma LUT (converting 8-bit input to 12-bit) */
+ s.r = lut_in[_colour_lut_index][*p++ << 4];
+ s.g = lut_in[_colour_lut_index][*p++ << 4];
+ s.b = lut_in[_colour_lut_index][*p++ << 4];
+
+ /* RGB to XYZ Matrix */
+ d.x = ((s.r * color_matrix[_colour_lut_index][0][0]) +
+ (s.g * color_matrix[_colour_lut_index][0][1]) +
+ (s.b * color_matrix[_colour_lut_index][0][2]));
+
+ d.y = ((s.r * color_matrix[_colour_lut_index][1][0]) +
+ (s.g * color_matrix[_colour_lut_index][1][1]) +
+ (s.b * color_matrix[_colour_lut_index][1][2]));
+
+ d.z = ((s.r * color_matrix[_colour_lut_index][2][0]) +
+ (s.g * color_matrix[_colour_lut_index][2][1]) +
+ (s.b * color_matrix[_colour_lut_index][2][2]));
+
+ /* DCI companding */
+ d.x = d.x * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
+ d.y = d.y * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
+ d.z = d.z * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
+
+ /* Out gamma LUT */
+ _image->comps[0].data[jn] = lut_out[LO_DCI][(int) d.x];
+ _image->comps[1].data[jn] = lut_out[LO_DCI][(int) d.y];
+ _image->comps[2].data[jn] = lut_out[LO_DCI][(int) d.z];
+
+ ++jn;
+ }
}
/* Set the max image and component sizes based on frame_rate */
diff --git a/src/lib/filter.cc b/src/lib/filter.cc
index ab5a6316f..446cc111d 100644
--- a/src/lib/filter.cc
+++ b/src/lib/filter.cc
@@ -72,6 +72,7 @@ Filter::setup_filters ()
_filters.push_back (new Filter ("ppl5", "FIR low-pass deinterlacer", "", "l5"));
_filters.push_back (new Filter ("mcdeint", "Motion compensating deinterlacer", "mcdeint", ""));
_filters.push_back (new Filter ("kerndeint", "Kernel deinterlacer", "kerndeint", ""));
+ _filters.push_back (new Filter ("yadif", "Yet Another Deinterlacing Filter", "yadif", ""));
_filters.push_back (new Filter ("pptn", "Temporal noise reducer", "", "tn"));
_filters.push_back (new Filter ("ppfq", "Force quantizer", "", "fq"));
_filters.push_back (new Filter ("gradfun", "Gradient debander", "gradfun", ""));
diff --git a/src/lib/image.cc b/src/lib/image.cc
index ce44ec95b..c8849303c 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -260,15 +260,15 @@ SimpleImage::SimpleImage (PixelFormat p, Size s)
switch (p) {
case PIX_FMT_RGB24:
- _line_size[0] = s.width * 3;
+ _line_size[0] = round_up (s.width * 3, 32);
break;
case PIX_FMT_RGBA:
- _line_size[0] = s.width * 4;
+ _line_size[0] = round_up (s.width * 4, 32);
break;
case PIX_FMT_YUV420P:
- _line_size[0] = s.width;
- _line_size[1] = s.width / 2;
- _line_size[2] = s.width / 2;
+ _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);
break;
default:
assert (false);
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 82aaf8ff5..c3dd13d7c 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -613,3 +613,10 @@ Rectangle::intersection (Rectangle const & other) const
min (y + h, other.y + other.h) - ty
);
}
+
+int
+round_up (int a, int t)
+{
+ a += (t - 1);
+ return a - (a % t);
+}
diff --git a/src/lib/util.h b/src/lib/util.h
index 66c052c48..244c01855 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -149,6 +149,7 @@ struct Rectangle
extern std::string crop_string (Position, Size);
extern int dcp_audio_sample_rate (int);
extern std::string colour_lut_index_to_name (int index);
+extern int round_up (int, int);
/** @class Socket
* @brief A class to wrap a boost::asio::ip::tcp::socket with some things