Skip to content

Commit

Permalink
Add FIR function to filter discrete blocks, for SECAM
Browse files Browse the repository at this point in the history
  • Loading branch information
fsphil committed Aug 29, 2021
1 parent 7305cbe commit b934ae5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions fir.c
Expand Up @@ -275,6 +275,25 @@ size_t fir_int16_process(fir_int16_t *s, int16_t *out, const int16_t *in, size_t
return(x);
}

size_t fir_int16_process_block(fir_int16_t *s, int16_t *out, const int16_t *in, size_t samples)
{
int x;

/* Pre-fill buffer */
memset(s->win, 0, (s->lwin + s->ataps) * sizeof(int16_t));
s->owin = 0;

for(s->owin = 0; s->owin < s->ataps / 2; s->owin++, in += 2)
{
s->win[s->owin] = *in;
if(s->owin < s->ataps) s->win[s->owin + s->lwin] = *in;
}

x = fir_int16_process(s, out, in, samples);

return(x);
}

void fir_int16_free(fir_int16_t *s)
{
free(s->win);
Expand Down
1 change: 1 addition & 0 deletions fir.h
Expand Up @@ -62,6 +62,7 @@ extern void fir_complex_band_pass(double *taps, size_t ntaps, double sample_rate

extern int fir_int16_init(fir_int16_t *s, const double *taps, unsigned int ntaps, int interpolation, int decimation, int delay);
extern size_t fir_int16_process(fir_int16_t *s, int16_t *out, const int16_t *in, size_t samples);
extern size_t fir_int16_process_block(fir_int16_t *s, int16_t *out, const int16_t *in, size_t samples);
extern void fir_int16_free(fir_int16_t *s);

extern int fir_int16_resampler_init(fir_int16_t *s, int interpolation, int decimation);
Expand Down
5 changes: 2 additions & 3 deletions video.c
Expand Up @@ -2787,9 +2787,8 @@ static int _vid_next_line_raster(vid_t *s, void *arg, int nlines, vid_line_t **l
}
}

x = s->fm_secam_fir.ntaps / 2;
fir_int16_process(&s->secam_l_fir, l->output + (s->active_left - x) * 2, l->output + (s->active_left) * 2, s->active_width - x);
fir_int16_process(&s->fm_secam_fir, l->output + 1, l->output + 1 + x * 2, s->width - x);
fir_int16_process_block(&s->secam_l_fir, l->output + s->active_left * 2, l->output + s->active_left * 2, s->active_width);
fir_int16_process_block(&s->fm_secam_fir, l->output + 1, l->output + 1, s->width);
iir_int16_process(&s->fm_secam_iir, l->output + 1, l->output + 1, s->width, 2);

/* Limit the FM deviation */
Expand Down

0 comments on commit b934ae5

Please sign in to comment.