-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed2b74d
commit 247572e
Showing
22 changed files
with
2,246 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
print([Glob("src/*.c")]) | ||
Program("bin/output", [Glob("src/*.c")]) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "ops.h" | ||
#include "utils.h" | ||
#include "model.h" | ||
|
||
#ifndef _GLOBAL_H_ | ||
#define _GLOBAL_H_ | ||
|
||
int main(int,char **); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma ONCE | ||
#pragma once | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#define WEIGHT1 "../pretrained/weights_layer1.txt" | ||
#define WEIGHT2 "../pretrained/weights_layer2.txt" | ||
#define WEIGHT3 "../pretrained/weights_layer3.txt" | ||
#define WEIGHT4 "../pretrained/weights_layer4.txt" | ||
#define WEIGHT5 "../pretrained/weights_layer5.txt" | ||
#define WEIGHT6 "../pretrained/weights_layer6.txt" | ||
#define WEIGHT7 "../pretrained/weights_layer7.txt" | ||
#define WEIGHT8 "../pretrained/weights_layer8.txt" | ||
|
||
#define BIAS1 "../pretrained/biases_layer1.txt" | ||
#define BIAS2 "../pretrained/biases_layer2.txt" | ||
#define BIAS3 "../pretrained/biases_layer3.txt" | ||
#define BIAS4 "../pretrained/biases_layer4.txt" | ||
#define BIAS5 "../pretrained/biases_layer5.txt" | ||
#define BIAS6 "../pretrained/biases_layer6.txt" | ||
#define BIAS7 "../pretrained/biases_layer7.txt" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "../includes/global.h" | ||
|
||
int main(int argc, char *argv[]){ | ||
char *inFile = argv[1]; | ||
char *outFile = argv[2]; | ||
|
||
//Upsampler parameters | ||
int scale = 2; | ||
|
||
//Compressed Assault Cube | ||
int num = 300; //Number of frames to interpolate | ||
int inCols = 176; //Width of input (downsampled) video | ||
int inRows = 144; //Height of input (downsampled) video | ||
|
||
int outCols = inCols*scale; | ||
int outRows = inRows*scale; | ||
|
||
FILE *inFp, *outFp; | ||
|
||
inFp = fopen(inFile, "rb"); | ||
if (inFp == NULL) | ||
{ | ||
printf("\n We have null pointer \n"); | ||
} | ||
outFp = fopen(outFile, "wb"); | ||
if (outFp == NULL) | ||
{ | ||
printf("\n We have null pointer \n"); | ||
} | ||
|
||
// To read and write each frame in an unsigned character format | ||
unsigned char *inBuf = (unsigned char *)malloc(inCols*inRows*sizeof(unsigned char)); | ||
unsigned char *outBuf = (unsigned char *)malloc(outCols*outRows*sizeof(unsigned char)); | ||
// To work with each pixel in the range of 0~1 | ||
double *inBuf_tmp = (double *)malloc(inCols*inRows*sizeof(double)); | ||
double *outBuf_tmp = (double *)malloc(outCols*outRows*sizeof(double)); | ||
|
||
for (int fcnt = 0; fcnt < num; fcnt++) | ||
{ | ||
//////// Interpolate each frame using FSRCNN for Y component and simple repitition for U and V components | ||
// Pointer to obtain value of each tpixel of input frame | ||
unsigned char *inP = inBuf; | ||
double *inP_tmp = inBuf_tmp; | ||
// Pointer to obtain value of each pixel of output frame | ||
unsigned char *outP = outBuf; | ||
double *outP_tmp = outBuf_tmp; | ||
|
||
//Y Component | ||
fread(inBuf, sizeof(unsigned char), inCols*inRows, inFp); | ||
int i, j; | ||
|
||
for (i = 0; i<inRows; i++) | ||
for (j = 0; j<inCols; j++) | ||
{ | ||
int cnt = i*inCols + j; | ||
int x = *inP++; | ||
*(inP_tmp + cnt) = (double)(x / 255.0); | ||
} | ||
|
||
FSRCNN(outP_tmp, inP_tmp, inRows, inCols, scale); | ||
|
||
outP_tmp = outBuf_tmp; | ||
|
||
for (i = 0; i<inRows*scale; i++) | ||
for (j = 0; j<inCols*scale; j++) | ||
{ | ||
int cnt = i*inCols*scale + j; | ||
*(outP_tmp + cnt) = *(outP_tmp + cnt) * 255; | ||
} | ||
|
||
|
||
double_to_uint8( outP_tmp, outP, outCols, outRows); | ||
|
||
fwrite(outBuf, sizeof(unsigned char), outCols*outRows, outFp); | ||
|
||
//U Component | ||
fread(inBuf, sizeof(unsigned char), inCols*inRows / 4, inFp); | ||
|
||
inP = inBuf; | ||
outP = outBuf; | ||
|
||
for (i = 0; i < inRows / 2; i++) | ||
for (j = 0; j < inCols / 2; j++) { | ||
|
||
int cnt = 2 * (i * outCols / 2 + j); | ||
|
||
unsigned char x = *inP++; | ||
|
||
*(outP + cnt) = x; | ||
*(outP + cnt + 1) = x; | ||
*(outP + cnt + outCols / 2) = x; | ||
*(outP + cnt + outCols / 2 + 1) = x; | ||
|
||
} | ||
|
||
fwrite(outBuf, sizeof(unsigned char), outCols*outRows / 4, outFp); | ||
|
||
// V COmponent | ||
fread(inBuf, sizeof(unsigned char), inCols*inRows / 4, inFp); | ||
inP = inBuf; | ||
outP= outBuf; | ||
|
||
for (i = 0; i < inRows / 2; i++) | ||
for (j = 0; j < inCols / 2; j++) { | ||
|
||
int cnt = 2 * (i*outCols / 2 + j); | ||
|
||
unsigned char x = *inP++; | ||
|
||
*(outP + cnt) = x; | ||
*(outP + cnt + 1) = x; | ||
*(outP + cnt + outCols / 2) = x; | ||
*(outP + cnt + outCols / 2 + 1) = x; | ||
|
||
} | ||
|
||
fwrite(outBuf, sizeof(unsigned char), outCols*outRows / 4, outFp); | ||
|
||
} | ||
free(inBuf); | ||
inBuf = NULL; | ||
free(inBuf_tmp); | ||
inBuf_tmp = NULL; | ||
free(outBuf); | ||
outBuf = NULL; | ||
free(outBuf_tmp); | ||
outBuf_tmp = NULL; | ||
} |
Binary file not shown.
Oops, something went wrong.