Commit 483a6bf8 authored by cclepper's avatar cclepper
Browse files

initial commit


git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@298 49b2a0ca-c541-4d49-a7ef-d785e4371512
parent 617bda6b
/*
* pix_scanline.cpp
* gem_darwin
*
* Created by chris clepper on Mon Oct 07 2002.
* Copyright (c) 2002 __MyCompanyName__. All rights reserved.
*
*/
#include "pix_scanline.h"
CPPEXTERN_NEW(pix_scanline)
/////////////////////////////////////////////////////////
//
// pix_scanline
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_scanline :: pix_scanline()
{
inletScanline = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("interlace"));
m_interlace = 0;
m_mode = 0;
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
pix_scanline :: ~pix_scanline()
{
delete saved;
}
/////////////////////////////////////////////////////////
// processImage
//
/////////////////////////////////////////////////////////
void pix_scanline :: processRGBAImage(imageStruct &image)
{
int h,w,i,length,width,cleanup;
long srcline,dstline;
long interlace;
interlace = m_interlace;
length = image.ysize /interlace;
width = image.xsize * image.csize;
cleanup = image.ysize % interlace;
//post("interlace %d cleanup %d ", interlace, cleanup);
srcline = 0;
dstline = 0;
if (m_mode == 0){
for (h =0; h<length;h++){
for (i = 0; i < interlace - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = image.data[srcline+w];
}
}
srcline+= width * interlace;
dstline += width;
}
if (cleanup) {
for (i = 0; i < cleanup - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = image.data[srcline+w];
}
}
}
}else{
for (h =0; h<length;h++){
for (i = 0; i < interlace - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = 0;
}
}
srcline+= width * interlace;
dstline += width;
}
if (cleanup) {
for (i = 0; i < cleanup - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = 0;
}
}
}
}
}
/////////////////////////////////////////////////////////
// do the YUV processing here
//
/////////////////////////////////////////////////////////
void pix_scanline :: processYUVImage(imageStruct &image)
{
int h,w,i,length,width,cleanup;
long srcline,dstline;
long interlace;
interlace = m_interlace;
if (interlace < 0){interlace = 0;}
length = image.ysize /interlace;
width = image.xsize * image.csize;
cleanup = image.ysize % interlace;
//post("interlace %d cleanup %d ", interlace, cleanup);
srcline = 0;
dstline = 0;
if (m_mode == 0){
for (h =0; h<length;h++){
for (i = 0; i < interlace - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = image.data[srcline+w];
}
}
srcline+= width * interlace;
dstline += width;
}
if (cleanup) {
for (i = 0; i < cleanup - 1; i++){
dstline += width;
for (w = 0; w < width;w++){
image.data[dstline+w] = image.data[srcline+w];
}
}
}
}else{
for (h =0; h<length;h++){
for (i = 0; i < interlace - 1; i++){
dstline += width;
for (w = 0; w < width;w+=2){
image.data[dstline+w] = 128;
image.data[dstline+w+1] = 0;
}
}
srcline+= width * interlace;
dstline += width;
}
if (cleanup) {
for (i = 0; i < cleanup - 1; i++){
dstline += width;
for (w = 0; w < width;w+=2){
image.data[dstline+w] = 128;
image.data[dstline+w+1] = 0;
}
}
}
}
}
/////////////////////////////////////////////////////////
// static member function
//
/////////////////////////////////////////////////////////
void pix_scanline :: obj_setupCallback(t_class *classPtr)
{
class_addmethod(classPtr, (t_method)&pix_scanline::rollCallback,
gensym("interlace"), A_DEFFLOAT, A_NULL);
class_addmethod(classPtr, (t_method)&pix_scanline::modeCallback,
gensym("mode"), A_DEFFLOAT, A_NULL);
}
void pix_scanline :: rollCallback(void *data, t_floatarg value)
{
GetMyClass(data)->m_interlace=((long)value);
}
void pix_scanline :: modeCallback(void *data, t_floatarg value)
{
GetMyClass(data)->m_mode=((long)value);
}
/*
* pix_scanline.h
* gem_darwin
*
* Created by chris clepper on Mon Oct 07 2002.
* Copyright (c) 2002 __MyCompanyName__. All rights reserved.
*
*/
#ifndef INCLUDE_pix_scanline_H_
#define INCLUDE_pix_scanline_H_
#include "Base/GemPixObj.h"
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
pix_scanline
KEYWORDS
pix
yuv
DESCRIPTION
template for yuv_ objects
-----------------------------------------------------------------*/
class GEM_EXTERN pix_scanline : public GemPixObj
{
CPPEXTERN_HEADER(pix_scanline, GemPixObj)
public:
//////////
// Constructor
pix_scanline();
protected:
//////////
// Destructor
virtual ~pix_scanline();
//////////
// Do the processing
virtual void processRGBAImage(imageStruct &image);
//////////
// Do the YUV processing
virtual void processYUVImage(imageStruct &image);
// virtual void processYUVAltivec(imageStruct &image);
unsigned char *saved;
int m_interlace,m_mode;
t_inlet *inletScanline;
private:
//////////
// Static member functions
static void rollCallback (void *data, t_floatarg value);
static void modeCallback (void *data, t_floatarg value);
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment