From 7a847adfb41352466475428c61e85807ca4d25b8 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 15 Aug 2011 15:56:57 +0200 Subject: Add temporal weave de-interlacer --- deinterlace.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/deinterlace.c b/deinterlace.c index a7a81aa..07009dc 100644 --- a/deinterlace.c +++ b/deinterlace.c @@ -17,7 +17,7 @@ char *strdup(const char *str) return dup; } -int process_simple_frame(uint16_t *frame_in, uint16_t *frame_out, int width, int height) +int process_simple_frame(const uint16_t *frame_in, uint16_t *frame_out, int width, int height) { const size_t row_size_bytes = width * sizeof(uint16_t); @@ -38,6 +38,19 @@ int process_simple_frame(uint16_t *frame_in, uint16_t *frame_out, int width, int return 0; } +int weave(const uint16_t *frames_in, uint16_t *frame_out, int width, int height) +{ + const size_t row_size_bytes = width * sizeof(uint16_t); + const size_t frame_offset = width * height; + for (int row = 0; row < height; row++) { + memcpy(frame_out, frames_in + row*width, row_size_bytes); + frame_out += width; + memcpy(frame_out, frames_in + frame_offset + row*width, row_size_bytes); + frame_out += width; + } + return 0; +} + int process_file(const char *filename, int width, int height, int num_lines_skipped) { FILE *fp = fopen(filename, "rb"); @@ -69,12 +82,19 @@ int process_file(const char *filename, int width, int height, int num_lines_skip const int num_frames = file_size / (width * height * sizeof(uint16_t)); printf("de-interlacing %i frames...\n", num_frames); + /* for (int frame = 0; frame < num_frames; frame++) { process_simple_frame( frame_in_buffer + frame * (width * height), frame_out_buffer + frame * (width * height * 2), width, height); } + */ + for (int frame = 0; frame < num_frames-1; frame++) { + weave(frame_in_buffer + frame * (width * height), + frame_out_buffer + frame * (width * height * 2), + width, height); + } fp = fopen("result.raw", "wb"); fwrite(frame_out_buffer, 1, file_size * 2, fp); @@ -133,3 +153,4 @@ int main(int argc, char const* argv[]) free(file_name); return 0; } + -- cgit v1.2.3