Logo Search packages:      
Sourcecode: camserv version File versions  Download package

deinterlace_filter.c

/*
 *  deinterlace_filter.c
 *
 *  Copyright (C) Zdenek Svoboda (zdenek.svoboda@centrum.cz) - March 2003
 *
 *  This file is part of camserv, an internet streaming picture application
 *   (Copyright (C) 1999-2002  Jon Travis (jtravis@p00p.org))
 *
 *  This plugin is based on source code of transcode, a linux video stream processing tool
 *   (Copyright (C) Thomas Ístreich)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include "camserv.h"
#include "camconfig.h"
#include "video.h"
#include "filter.h"
#include "log.h"

#define MODNAME "deinterlacefilter"

static int (*rgb_average) (char *row1, char *row2, char *out, int bytes);

inline int rgb_average_C(char *row1, char *row2, char *out, int bytes)
{
  
  //calculate the average of each color entry in two arrays and return
  //result in char *out
  
  unsigned int y=0;
  unsigned short tmp;
  
  for (y = 0; y<bytes; ++y) {
    tmp = ((unsigned char) row2[y] + (unsigned char) row1[y])>>1;
    out[y] = tmp & 0xff;
  }
  
  return(0);
}

inline void rgb_deinterlace_core(char *image, int width, int height)
{
    char *in, *out;
    
    unsigned int y, block; 
    
    block = width * 3;

    in  = image;
    out = image;
    
    // convert half frame to full frame by simple interpolation
      
    out +=block;
    
    for (y = 0; y < (height>>1)-1; y++) {
      
      rgb_average(in, in+(block<<1), out, block);
      
      in  += block<<1;
      out += block<<1;
    }
    
    return;
}

/*
 * filter_init:  Standard filter initialization routine.
 *
 * Filter variables:  randmod_perline = max # of random pixels per line
 *                    randmod_colordpix = Use colored pixels
 */

void *filter_init( CamConfig *ccfg, char *section_name ){
      return NULL;
}

/*
 * filter_deinit:  Standard filter deinit routine 
 */

void filter_deinit( void *filter_dat ){
      return;
}

void filter_func( char *in_data, char **out_data, void *cldat, 
              const Video_Info *vinfo_in, Video_Info *vinfo_out )
{
  *vinfo_out = *vinfo_in;
  *out_data = in_data;

  //default ia32 C mode:
  rgb_average =  rgb_average_C;
  
  rgb_deinterlace_core(in_data, vinfo_in->width, vinfo_in->height);

}

void filter_validation(){
  Filter_Init_Func init = filter_init;
  Filter_Deinit_Func deinit = filter_deinit;
  Filter_Func_Func func = filter_func;

  if( init != NULL && deinit != NULL && func != NULL ) return;
}



/*
 * modinfo_query:  Routine to return information about the variables
 *                 accessed by this particular module.
 *
 * Return values:  Returns a malloced ModInfo structure, for which
 *                 the caller must free, or NULL on failure.
 */

ModInfo *modinfo_query(){
  ModInfo *res;

  if( (res = modinfo_create( 0 )) == NULL )
    return NULL;

  return res;
}

Generated by  Doxygen 1.6.0   Back to index