Changeset 1131:bca464362519 in roaraudio


Ignore:
Timestamp:
01/20/09 17:57:30 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to reset a filter(chain) :), works only for dcblock at the moment :(

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/libroardsp.h

    r1105 r1131  
    5858#define ROARDSP_FCTL_MODE             9 
    5959 
     60// consts for filter(chain) reset: 
     61#define ROARDSP_RESET_NONE            0 
     62#define ROARDSP_RESET_FULL            1 
     63#define ROARDSP_RESET_STATE           2 
     64 
    6065// filter specific constants: 
    6166#define ROARDSP_DOWNMIX_LEFT          1 
     
    7681 int (*uninit)(struct roardsp_filter * filter); 
    7782 int (*ctl   )(struct roardsp_filter * filter, int cmd, void * data); 
     83 int (*reset )(struct roardsp_filter * filter, int what); 
    7884}; 
    7985 
     
    115121int    roardsp_filter_calc  (struct roardsp_filter * filter, void * data, size_t len); 
    116122int    roardsp_filter_ctl   (struct roardsp_filter * filter, int cmd, void * data); 
     123int    roardsp_filter_reset (struct roardsp_filter * filter, int what); 
    117124 
    118125int roardsp_fchain_init  (struct roardsp_filterchain * chain); 
     
    120127int roardsp_fchain_add   (struct roardsp_filterchain * chain, struct roardsp_filter * filter); 
    121128int roardsp_fchain_calc  (struct roardsp_filterchain * chain, void * data, size_t len); 
     129int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what); 
    122130int roardsp_fchain_num   (struct roardsp_filterchain * chain); 
    123131 
     
    161169int roardsp_dcblock_uninit (struct roardsp_filter * filter); 
    162170int roardsp_dcblock_calc16 (struct roardsp_filter * filter, void * data, size_t samples); 
     171int roardsp_dcblock_reset  (struct roardsp_filter * filter, int what); 
    163172 
    164173// codecs: 
  • libroardsp/filter.c

    r1104 r1131  
    3131 int (*uninit      )(struct roardsp_filter * filter); 
    3232 int (*ctl         )(struct roardsp_filter * filter, int cmd, void * data); 
     33 int (*reset       )(struct roardsp_filter * filter, int what); 
    3334 int (*calc  [5][3])(struct roardsp_filter * filter, void * data, size_t samples); 
    3435} _roardsp_filterlist[] = { 
    35  {ROARDSP_FILTER_AMP, "AMP", roardsp_amp_init, roardsp_amp_uninit, roardsp_amp_ctl, { 
     36 {ROARDSP_FILTER_AMP, "AMP", roardsp_amp_init, roardsp_amp_uninit, roardsp_amp_ctl, NULL, { 
    3637           {NULL, NULL, NULL},{roardsp_amp_calc8, NULL, NULL},{roardsp_amp_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    37  {ROARDSP_FILTER_ADD, "Add", roardsp_add_init, roardsp_amp_uninit, roardsp_amp_ctl, { 
     38 {ROARDSP_FILTER_ADD, "Add", roardsp_add_init, roardsp_amp_uninit, roardsp_amp_ctl, NULL, { 
    3839           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_add_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    3940#ifdef ROAR_HAVE_LIBM 
    40  {ROARDSP_FILTER_LOWP, "Lowpass", roardsp_lowp_init, roardsp_lowp_uninit, roardsp_lowp_ctl, { 
     41 {ROARDSP_FILTER_LOWP, "Lowpass", roardsp_lowp_init, roardsp_lowp_uninit, roardsp_lowp_ctl, NULL, { 
    4142           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_lowp_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    42  {ROARDSP_FILTER_HIGHP, "Highpass", roardsp_highp_init, roardsp_highp_uninit, roardsp_highp_ctl, { 
     43 {ROARDSP_FILTER_HIGHP, "Highpass", roardsp_highp_init, roardsp_highp_uninit, roardsp_highp_ctl, NULL, { 
    4344           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_highp_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    4445#endif 
    45  {ROARDSP_FILTER_QUANTIFY, "Quantifier", roardsp_quantify_init, NULL, roardsp_quantify_ctl, { 
     46 {ROARDSP_FILTER_QUANTIFY, "Quantifier", roardsp_quantify_init, NULL, roardsp_quantify_ctl, NULL, { 
    4647           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_quantify_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    47  {ROARDSP_FILTER_CLIP, "Clip", roardsp_clip_init, NULL, roardsp_clip_ctl, { 
     48 {ROARDSP_FILTER_CLIP, "Clip", roardsp_clip_init, NULL, roardsp_clip_ctl, NULL, { 
    4849           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_clip_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    49  {ROARDSP_FILTER_DOWNMIX, "downmix", roardsp_downmix_init, NULL, roardsp_downmix_ctl, { 
     50 {ROARDSP_FILTER_DOWNMIX, "downmix", roardsp_downmix_init, NULL, roardsp_downmix_ctl, NULL, { 
    5051           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, roardsp_downmix_calc162},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    51  {ROARDSP_FILTER_DCBLOCK, "DCBlock", roardsp_dcblock_init, NULL, NULL, { 
     52 {ROARDSP_FILTER_DCBLOCK, "DCBlock", roardsp_dcblock_init, NULL, NULL, roardsp_dcblock_reset, { 
    5253           {NULL, NULL, NULL},{NULL, NULL, NULL},{roardsp_dcblock_calc16, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    53  {-1, NULL, NULL, NULL, NULL, { 
     54 {-1, NULL, NULL, NULL, NULL, NULL, { 
    5455      // ?                  8Bit               16Bit              24Bit              32Bit 
    5556      // 0B:n     1     2   1B:n     1     2   2B:n     1     2   3B:n     1    2    4B:n     1     2 
     
    168169} 
    169170 
     171int    roardsp_filter_reset (struct roardsp_filter * filter, int what) { 
     172 if ( filter == NULL ) 
     173  return -1; 
     174 
     175 if ( filter->reset ) 
     176  return filter->reset(filter, what); 
     177 
     178 return -1; 
     179} 
     180 
    170181//ll 
  • libroardsp/filter_dcblock.c

    r1100 r1131  
    5454} 
    5555 
     56int roardsp_dcblock_reset  (struct roardsp_filter * filter, int what) { 
     57 if ( filter == NULL ) 
     58  return -1; 
     59 
     60 if ( filter->inst == NULL ) 
     61  return -1; 
     62 
     63 switch (what) { 
     64  case ROARDSP_RESET_NONE: 
     65    return  0; 
     66   break; 
     67  case ROARDSP_RESET_FULL: 
     68    memset(filter->inst, 0, sizeof(struct roardsp_dcblock)); 
     69    return  0; 
     70   break; 
     71  case ROARDSP_RESET_STATE: 
     72    memset(((struct roardsp_dcblock*)filter->inst)->dc, 0, sizeof(int32_t)*ROARDSP_DCBLOCK_NUMBLOCKS); 
     73    return  0; 
     74   break; 
     75  default: 
     76    return -1; 
     77 } 
     78 
     79 return -1; 
     80} 
     81 
    5682int roardsp_dcblock_calc16  (struct roardsp_filter * filter, void * data, size_t samples) { 
    5783 struct roardsp_dcblock * inst = filter->inst; 
  • libroardsp/filterchain.c

    r679 r1131  
    7878} 
    7979 
     80int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what) { 
     81 int i; 
     82 int ret = 0; 
     83/* 
     84 struct roardsp_filterchain backup[1]; 
     85*/ 
     86 
     87 if ( chain == NULL ) 
     88  return -1; 
     89 
     90/* 
     91 if ( what == ROARDSP_RESET_FULL ) { 
     92  if ( roardsp_fchain_init(backup) == -1 ) 
     93   return -1; 
     94 
     95  if ( roardsp_fchain_uninit(chain) == -1 ) 
     96   return -1; 
     97 
     98  if ( roardsp_fchain_init(chain) == -1 ) 
     99   return -1; 
     100 } else { 
     101*/ 
     102  for (i = 0; i < chain->filters; i++) { 
     103   if ( roardsp_filter_reset(chain->filter[i], what) == -1 ) 
     104    ret = -1; 
     105  } 
     106/* 
     107 } 
     108*/ 
     109 
     110 return ret; 
     111} 
     112 
    80113int roardsp_fchain_num   (struct roardsp_filterchain * chain) { 
    81114 if ( chain == NULL ) 
Note: See TracChangeset for help on using the changeset viewer.