Warning: session_start(): open(/var/lib/php/sessions/sess_g4joedtf8mdu63cg81o38frtob, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
srecord noeq GridCodec1(BufferedImage stage0_image) is JavaCodec {
settable int rows = 20;
static GridCodec1 demo() { ret GridCodec1(defaultScreenshot()); }
// interim data & searches
Matrix stage1_matrix;
long dataBytes, dataChars;
Matrix> stage2_grid;
JE_CompressEachElementIndividually strat;
JECompressionSearch search;
JECompressionSearch forward() {
// go from stage 0 (image) to stage 3 (list of list of ints)
assertNotNull(stage0_image);
var m = stage1_matrix = imageToMatrix(stage0_image);
dataBytes = m.nCells()*4+2;
dataChars = dataBytes*2 + l("lInt(\"\")");
print("Matrix ~ " + shorten_str(60, m));
print("Trivial comp ~ " + (m.nCells()*8));
stage2_grid = matrixToMNGrid_rows(m, rows);
// list of lists
LL stage3_cells = matrixOfMatricesToListOfLists(stage2_grid);
search = jeCompressionSearch(stage3_cells, dataChars);
strat = new JE_CompressEachElementIndividually()
.elementCompressionStrategy(-> new JE_RepElement)
.onCompressionFail(ints -> javaObjectToIJavaExpr(ints);
search.addStrategy(strat);
ret search;
}
S stats() { ret strat?.stats(); }
JECompressionSearch.Submission winner() {
ret search?.bestSubmission();
}
IJavaExpr> winnerCodeWithoutPostProcessing() {
ret winner()?.decompressor();
}
IJavaExpr winnerCode() {
var innerWinner = winnerCodeWithoutPostProcessing();
if (innerWinner == null) null;
ret addPostProcessing(innerWinner);
}
// post processing goes from stage 3 back to stage 0 (see function "forward")
IJavaExpr addPostProcessing(IJavaExpr> inner) {
L cellWidths = lambdaMapMethod getWidth(rowToList(stage2_grid, 0));
L cellHeights = lambdaMapMethod getHeight(colToList(stage2_grid, 0));
ret new AbstractJavaXExpr {
public FunctionCall javaConstruct() {
ret functionCall gridLOLToImage(toJava(cellWidths), toJava(cellHeights), inner);
}
toString { ret str(javaConstruct()); }
public BufferedImage quickEval() {
ret gridLOLToImage(cellWidths, cellHeights, inner.quickEval());
}
};
}
BufferedImage renderCellsLinearly() {
ret mergeBufferedImagesHorizontally(
map intMatrixToImage(matrixToList(stage2_grid)));
}
}