diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2018-09-29 01:21:59 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2018-09-29 01:21:59 +0300 |
commit | d52df7442209819eac6db995420aa32c82c06aeb (patch) | |
tree | 6cd3471ff552b95c79eec1582b1ca8bd45086f56 | |
parent | 1216b63c7b6864b0faeb2c6fd68a2a0ef5893f0e (diff) | |
download | analogcolor-d52df7442209819eac6db995420aa32c82c06aeb.tar.gz |
Simple comb filter added for chroma/luma separation
-rw-r--r-- | src/libanalog/ntsc.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libanalog/ntsc.c b/src/libanalog/ntsc.c index 2aaea49..2fe1b21 100644 --- a/src/libanalog/ntsc.c +++ b/src/libanalog/ntsc.c @@ -31,6 +31,8 @@ struct ntsc_ctx { } generator; uint16_t width; struct ntsc_iq* iq; + float* luma; + float* chroma; struct biquad_filter_ctx i_filter; struct biquad_filter_ctx q_filter; @@ -112,6 +114,8 @@ ntsc_ctx* ntsc_create_context(int width, int encode) p->width = width; ntsc_create_generator(p); p->iq = malloc(sizeof(struct ntsc_iq) * width); + p->luma = calloc(width, sizeof(float)); + p->chroma = calloc(width, sizeof(float)); ntsc_filter_init(&p->i_filter, 0.08); ntsc_filter_init(&p->q_filter, 0.05); @@ -124,6 +128,8 @@ void ntsc_free_context(ntsc_ctx* ctx) if (ctx->verbose) free(ctx->verbose); ntsc_free_generator(ctx); + free(ctx->luma); + free(ctx->chroma); free(ctx->iq); free(ctx); } @@ -237,11 +243,25 @@ void ntsc_process_decode(const float* input, float* output, ntsc_ctx* ctx) { int i; - ntsc_demodulate_line(input, ctx); + for (i = 0; i < ctx->width; i++) { + float* l = ctx->luma + i; + float* c = ctx->chroma + i; + *l = (input[i] + *l) / 2.0; + *c = (input[i] - *c) / 2.0; + } + + ntsc_demodulate_line(ctx->chroma, ctx); for (i = 0; i < ctx->width; i++) { struct ntsc_iq* iq = ctx->iq + i; - ntsc_iqy_to_rgb(iq, input[i], output + i * 3); + ntsc_iqy_to_rgb(iq, ctx->luma[i], output + i * 3); + } + + for (i = 0; i < ctx->width; i++) { + float* l = ctx->luma + i; + float* c = ctx->chroma + i; + *l = input[i]; + *c = input[i]; } ntsc_next_line(ctx); |