summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-08-15 15:56:57 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-08-15 15:56:57 +0200
commit7a847adfb41352466475428c61e85807ca4d25b8 (patch)
tree126e9486b9eef7b14e1ef57b9885a639d96583a6
parent6e1c9e9db78464ad49e2afdf7b81afa5c4396e74 (diff)
downloadlibufodecode-7a847adfb41352466475428c61e85807ca4d25b8.tar.gz
libufodecode-7a847adfb41352466475428c61e85807ca4d25b8.tar.bz2
libufodecode-7a847adfb41352466475428c61e85807ca4d25b8.tar.xz
libufodecode-7a847adfb41352466475428c61e85807ca4d25b8.zip
Add temporal weave de-interlacer
-rw-r--r--deinterlace.c23
1 files changed, 22 insertions, 1 deletions
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;
}
+