From 77f4586f2191fffa20ccd42d9f8564d10ac018f1 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 3 Jul 2014 17:52:16 -0500 Subject: [PATCH] Fixed a bug with bitshifting float color values. ImageMagick can be built with different types of Quantum color values, and Im trying to make libopenshot work seemlessl with them. --- .cproject | 2 +- src/DecklinkOutput.cpp | 6 +++--- src/FFmpegWriter.cpp | 8 ++++---- src/RendererBase.cpp | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.cproject b/.cproject index 0128a803..83b23738 100644 --- a/.cproject +++ b/.cproject @@ -338,7 +338,7 @@ cmake - -G "Unix Makefiles" ../ -D"ENABLE_TESTS=1" -D"ENABLE_BLACKMAGIC=0" -D"CMAKE_BUILD_TYPE:STRING=Debug" + -G "Unix Makefiles" ../ -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -D"ENABLE_BLACKMAGIC=0" -D"CMAKE_BUILD_TYPE:STRING=Debug" true false diff --git a/src/DecklinkOutput.cpp b/src/DecklinkOutput.cpp index 988ed0d5..895c882b 100644 --- a/src/DecklinkOutput.cpp +++ b/src/DecklinkOutput.cpp @@ -265,9 +265,9 @@ void DeckLinkOutputDelegate::WriteFrame(tr1::shared_ptr frame) { // Update buffer (which is already linked to the AVFrame: pFrameRGB) castBytes[row] = 0; // alpha - castBytes[row+1] = pixel_packets[packet].red >> bit_shift; - castBytes[row+2] = pixel_packets[packet].green >> bit_shift; - castBytes[row+3] = pixel_packets[packet].blue >> bit_shift; + castBytes[row+1] = (int) pixel_packets[packet].red >> bit_shift; + castBytes[row+2] = (int) pixel_packets[packet].green >> bit_shift; + castBytes[row+3] = (int) pixel_packets[packet].blue >> bit_shift; } #pragma omp critical (blackmagic_output_queue) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index d41ee7e3..862e22c4 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -1231,13 +1231,13 @@ void FFmpegWriter::process_video_packet(tr1::shared_ptr frame) { // Update buffer (which is already linked to the AVFrame: pFrameRGB) // Each color needs to be 8 bit (so I'm bit shifting the 16 bit ints) - frame_source->data[0][row] = pixel_packets[packet].red >> bit_shift; - frame_source->data[0][row+1] = pixel_packets[packet].green >> bit_shift; - frame_source->data[0][row+2] = pixel_packets[packet].blue >> bit_shift; + frame_source->data[0][row] = (int) pixel_packets[packet].red >> bit_shift; + frame_source->data[0][row+1] = (int) pixel_packets[packet].green >> bit_shift; + frame_source->data[0][row+2] = (int) pixel_packets[packet].blue >> bit_shift; // Copy alpha channel (if needed) if (step == 4) - frame_source->data[0][row+3] = pixel_packets[packet].opacity >> bit_shift; + frame_source->data[0][row+3] = (int) pixel_packets[packet].opacity >> bit_shift; } // Resize & convert pixel format diff --git a/src/RendererBase.cpp b/src/RendererBase.cpp index 5f7c7e4a..ddf7dffe 100644 --- a/src/RendererBase.cpp +++ b/src/RendererBase.cpp @@ -75,9 +75,9 @@ void RendererBase::paint(const std::tr1::shared_ptr & frame) // Iterate through the pixel packets, and load our own buffer const Magick::PixelPacket *pixels = frame->GetPixels(); for (int n = 0, i = 0; n < width * height; n += 1, i += 3) { - buffer[i+0] = pixels[n].red >> bit_shift; - buffer[i+1] = pixels[n].green >> bit_shift; - buffer[i+2] = pixels[n].blue >> bit_shift; + buffer[i+0] = (int) pixels[n].red >> bit_shift; + buffer[i+1] = (int) pixels[n].green >> bit_shift; + buffer[i+2] = (int) pixels[n].blue >> bit_shift; } #endif