aboutsummaryrefslogtreecommitdiffstats
path: root/dvb-c/ch-Video2000
blob: 865c90ece46df64b60eb4891b2d5c4d78032022a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# Cable Video2000
# Canton of Neuchatel, Switzerland

# freq sr fec mod
[CHANNEL]
	DELIVERY_SYSTEM = DVBC/ANNEX_A
	FREQUENCY = 306000000
	SYMBOL_RATE = 6900000
	INNER_FEC = NONE
	MODULATION = QAM/64
	INVERSION = AUTO
#ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* $Id: filter.c,v 1.8 2003/10/05 17:58:50 reinelt Exp $
 *
 *  smooth and damp functions
 *
 * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux 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, or (at your option)
 * any later version.
 *
 * LCD4Linux 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: filter.c,v $
 * Revision 1.8  2003/10/05 17:58:50  reinelt
 * libtool junk; copyright messages cleaned up
 *
 * Revision 1.7  2003/09/09 06:54:43  reinelt
 * new function 'cfg_number()'
 *
 * Revision 1.6  2003/02/22 07:53:10  reinelt
 * cfg_get(key,defval)
 *
 * Revision 1.5  2001/08/05 17:13:29  reinelt
 *
 * cleaned up inlude of sys/time.h and time.h
 *
 * Revision 1.4  2000/03/23 07:24:48  reinelt
 *
 * PPM driver up and running (but slow!)
 *
 * Revision 1.3  2000/03/22 07:33:50  reinelt
 *
 * FAQ added
 * new modules 'processor.c' contains all data processing
 *
 * Revision 1.2  2000/03/06 06:04:06  reinelt
 *
 * minor cleanups
 *
 */

/* 
 *
 * exported fuctions:
 *
 * smooth (name, period, value)
 *   returns an average value over a given period
 *   uses global variable "tick"
 *
 * damp (name, value)
 *   damps a value with exp(-t/tau) 
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>

#include "cfg.h"
#include "filter.h"

extern int tick;

#define SLOTS 64
#define SECONDS(x) (x.tv_sec+x.tv_usec/1000000.0)

typedef struct {
  char *name;
  int slots;
  struct timeval *time;
  double *value;
} FILTER;


double smooth(char *name, int period, double value)
{
  static FILTER *Filter=NULL;
  static int nFilter=0;
  struct timeval now;
  double t, v;
  int i, j;
  
  gettimeofday (&now, NULL);
  
  for (i=0; i<nFilter; i++) {
    if (strcmp(name, Filter[i].name)==0) 
      break;
  }
  
  if (i==nFilter) {
    int slots=(period+tick-1)/tick;
    if (slots<2) 
      slots=2;
    else if (slots>SLOTS)
      slots=SLOTS;

    nFilter++;
    Filter=realloc(Filter, nFilter*sizeof(FILTER));
    Filter[i].name=strdup(name);
    Filter[i].slots=slots;
    Filter[i].time=malloc(slots*sizeof(Filter[i].time[0]));
    Filter[i].value=malloc(slots*sizeof(Filter[i].value[0]));
    for (j=0; j<slots; j++) {
      Filter[i].time[j]=now;
      Filter[i].value[j]=value;
    }
  }
  
  for (j=Filter[i].slots-1; j>0; j--) {
    Filter[i].time[j]=Filter[i].time[j-1];
    Filter[i].value[j]=Filter[i].value[j-1];
  }
  Filter[i].time[0]=now;
  Filter[i].value[0]=value;
  
  t = SECONDS(Filter[i].time[0]) - SECONDS(Filter[i].time[Filter[i].slots-1]);
  v = Filter[i].value[0]-Filter[i].value[Filter[i].slots-1];

  if (t==0.0 || v<0.0)
    return 0;
  else
    return v/t;
}


double damp(char *name, double value)
{
  static int tau=-1;
  static FILTER *Filter=NULL;
  static int nFilter=0;
  struct timeval now;
  double max;
  int i, j;
  
  if (tau==-1) 
    if (cfg_number("tau", 500, 0, 1000000, &tau)<0) tau=0.0;
  
  if (tau==0.0)
    return value;
  
  gettimeofday (&now, NULL);
  
  for (i=0; i<nFilter; i++) {
    if (strcmp(name, Filter[i].name)==0) 
      break;
  }
  
  if (i==nFilter) {
    int slots=log(100)*tau/tick;
    if (slots<1) 
      slots=1;
    else if (slots>SLOTS)
      slots=SLOTS;

    nFilter++;
    Filter=realloc(Filter, nFilter*sizeof(FILTER));
    Filter[i].name=strdup(name);
    Filter[i].slots=slots;
    Filter[i].time=malloc(slots*sizeof(Filter[i].time));
    Filter[i].value=malloc(slots*sizeof(Filter[i].value));
    for (j=0; j<slots; j++) {
      Filter[i].time[j]=now;
      Filter[i].value[j]=0;
    }
  }
  
  max=value;
  for (j=Filter[i].slots-1; j>0; j--) {
    double t = SECONDS(Filter[i].time[j]) - SECONDS(Filter[i].time[j-1]);
    Filter[i].time[j]=Filter[i].time[j-1];
    Filter[i].value[j]=Filter[i].value[j-1]*exp(-t/tau);
    if (Filter[i].value[j]>max) max=Filter[i].value[j];
  }

  Filter[i].time[0]=now;
  Filter[i].value[0]=value;
  
  return max;
}