Skip to content

Commit

Permalink
fixed memory access error
Browse files Browse the repository at this point in the history
  • Loading branch information
lostjared committed Jul 26, 2018
1 parent a47489f commit 948cd86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Binary file not shown.
16 changes: 8 additions & 8 deletions Acid.Cam.v2.OSX/ac-filter6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ void ac::CycleShiftRGB(cv::Mat &frame) {
for(int j = 0; j < 3; ++j) {
for(int i = 0; i < offset[j]; ++i) {
if(i >= 0 && i < frame.cols) {
if(offset[j]-i >= 0) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i);
if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i-1);
cv::Vec3b pix_copy = frame_copy.at<cv::Vec3b>(z, i);
pixel[j] = pix_copy[j];
swapColors(frame, z, i);// swap colors
Expand Down Expand Up @@ -274,8 +274,8 @@ void ac::CycleShiftRandomRGB(cv::Mat &frame) {
for(int j = 0; j < 3; ++j) {
for(int i = 0; i < offset[j]; ++i) {
if(i >= 0 && i < frame.cols) {
if(offset[j]-i >= 0) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i);
if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i-1);
cv::Vec3b pix_copy = frame_copy.at<cv::Vec3b>(z, i);
pixel[j] = pix_copy[j];
}
Expand Down Expand Up @@ -330,8 +330,8 @@ void ac::CycleShiftRandomRGB_XorBlend(cv::Mat &frame) {
for(int j = 0; j < 3; ++j) {
for(int i = 0; i < offset[j]; ++i) {
if(i >= 0 && i < frame.cols) {
if(offset[j]-i >= 0) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i);
if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i-1);
cv::Vec3b pix_copy = frame_copy.at<cv::Vec3b>(z, i);
pixel[j] ^= pix_copy[j];
swapColors(frame, z, i);// swap colors
Expand Down Expand Up @@ -390,8 +390,8 @@ void ac::CycleShiftRandomAlphaBlend(cv::Mat &frame) {
for(int j = 0; j < 3; ++j) {
for(int i = 0; i < offset[j]; ++i) {
if(i >= 0 && i < frame.cols) {
if(offset[j]-i >= 0) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i);
if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) {
cv::Vec3b &pixel = frame.at<cv::Vec3b>(z, offset[j]-i-1);
cv::Vec3b pix_copy = frame_copy.at<cv::Vec3b>(z, i);
pixel[j] = static_cast<unsigned char>((pixel[j] * alpha[j]) + (pix_copy[j] * alpha[j]));
swapColors(frame, z, i);// swap colors
Expand Down

0 comments on commit 948cd86

Please sign in to comment.