Cocoa Port:
- Make the video filters code more cross-platform friendly by adding #includes for Linux. - Do more parameter checks in RunFilterCustom() and also add more helpful comments.
This commit is contained in:
parent
c0181e741d
commit
2cac9d3be3
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2011 Roger Manuel
|
Copyright (C) 2011 Roger Manuel
|
||||||
Copyright (C) 2012 DeSmuME team
|
Copyright (C) 2013 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "videofilter.h"
|
#include "videofilter.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
// Parameters for Scanline filter
|
// Parameters for Scanline filter
|
||||||
int scanline_filter_a = 0;
|
int scanline_filter_a = 0;
|
||||||
|
@ -329,7 +330,9 @@ uint32_t* VideoFilter::RunFilter()
|
||||||
RunFilterCustom() - STATIC
|
RunFilterCustom() - STATIC
|
||||||
|
|
||||||
Runs the pixels from srcBuffer through the video filter, and then stores the
|
Runs the pixels from srcBuffer through the video filter, and then stores the
|
||||||
resulting pixels into dstBuffer.
|
resulting pixels into dstBuffer. This function is useful for when your source or
|
||||||
|
destination buffers are already established, or when you want to run a filter once
|
||||||
|
without having to instantiate a new filter object.
|
||||||
|
|
||||||
Takes:
|
Takes:
|
||||||
srcBuffer - A pointer to the source pixel buffer. The caller is responsible
|
srcBuffer - A pointer to the source pixel buffer. The caller is responsible
|
||||||
|
@ -355,16 +358,23 @@ void VideoFilter::RunFilterCustom(const uint32_t *__restrict__ srcBuffer, uint32
|
||||||
const unsigned int srcWidth, const unsigned int srcHeight,
|
const unsigned int srcWidth, const unsigned int srcHeight,
|
||||||
const VideoFilterTypeID typeID)
|
const VideoFilterTypeID typeID)
|
||||||
{
|
{
|
||||||
if (typeID >= VideoFilterTypeIDCount)
|
// Parameter check
|
||||||
|
if (srcBuffer == NULL ||
|
||||||
|
dstBuffer == NULL ||
|
||||||
|
srcWidth == 0 ||
|
||||||
|
srcHeight == 0 ||
|
||||||
|
typeID >= VideoFilterTypeIDCount)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the filter attributes
|
||||||
const VideoFilterAttributes *vfAttr = &VideoFilterAttributesList[typeID];
|
const VideoFilterAttributes *vfAttr = &VideoFilterAttributesList[typeID];
|
||||||
const unsigned int dstWidth = srcWidth * vfAttr->scaleMultiply / vfAttr->scaleDivide;
|
const unsigned int dstWidth = srcWidth * vfAttr->scaleMultiply / vfAttr->scaleDivide;
|
||||||
const unsigned int dstHeight = srcHeight * vfAttr->scaleMultiply / vfAttr->scaleDivide;
|
const unsigned int dstHeight = srcHeight * vfAttr->scaleMultiply / vfAttr->scaleDivide;
|
||||||
const VideoFilterFunc filterFunction = vfAttr->filterFunction;
|
const VideoFilterFunc filterFunction = vfAttr->filterFunction;
|
||||||
|
|
||||||
|
// Assign the surfaces and run the filter
|
||||||
SSurface srcSurface = {(unsigned char *)srcBuffer, srcWidth*2, srcWidth, srcHeight};
|
SSurface srcSurface = {(unsigned char *)srcBuffer, srcWidth*2, srcWidth, srcHeight};
|
||||||
SSurface dstSurface = {(unsigned char *)dstBuffer, dstWidth*2, dstWidth, dstHeight};
|
SSurface dstSurface = {(unsigned char *)dstBuffer, dstWidth*2, dstWidth, dstHeight};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#ifndef _VIDEOFILTER_
|
#ifndef _VIDEOFILTER_
|
||||||
#define _VIDEOFILTER_
|
#define _VIDEOFILTER_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
Loading…
Reference in New Issue