summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-08 15:41:39 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-08 15:41:39 +0100
commite9c88f5652a79b25adafc65fce6282a1d824ed16 (patch)
tree60d6b3a214bb42d88b02b21c5d09ef7d98f92bd5 /src/lib/ffmpeg_decoder.cc
parent5f02ea34590cd6b796a6eaa55211abf5b36fd329 (diff)
Do alpha blending maybe right.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 5167ce488..8feb36623 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -275,26 +275,24 @@ FFmpegDecoder::do_pass ()
for (int sub_x = 0; sub_x < rect->w; ++sub_x) {
uint32_t const val = palette[*sub_line_p++];
- int const red = (val & 0xff);
- int const green = (val & 0xff00) >> 8;
- int const blue = (val & 0xff0000) >> 16;
- int const alpha = (val & 0xff000000) >> 24;
+
+ int const red = (val & 0xff);
+ int const green = (val & 0xff00) >> 8;
+ int const blue = (val & 0xff0000) >> 16;
+ float const alpha = ((val & 0xff000000) >> 24) / 255.0;
- if (alpha) {
- *frame_line_y_p = RGB_TO_Y_CCIR (red, green, blue);
- }
- frame_line_y_p++;
+ int const cy = *frame_line_y_p;
+
+ *frame_line_y_p++ = int (cy * (1 - alpha)) + int (RGB_TO_Y_CCIR (red, green, blue) * alpha);
current_u |= ((RGB_TO_U_CCIR (red, green, blue, 0) & 0xf0) >> 4) << (4 * subsample_step);
current_v |= ((RGB_TO_V_CCIR (red, green, blue, 0) & 0xf0) >> 4) << (4 * subsample_step);
if (subsample_step == 1 && (sub_y % 2) == 0) {
- if (alpha) {
- *frame_line_u_p = current_u;
- *frame_line_v_p = current_v;
- }
- frame_line_u_p++;
- frame_line_v_p++;
+ int const cu = *frame_line_u_p;
+ int const cv = *frame_line_v_p;
+ *frame_line_u_p++ = int (cu * (1 - alpha)) + int (current_u * alpha);
+ *frame_line_v_p++ = int (cv * (1 - alpha)) + int (current_v * alpha);
current_u = current_v = 0;
}