[GRASS-SVN] r67971 - in grass/trunk: include/defs lib/gis lib/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Feb 27 14:36:35 PST 2016
Author: mmetz
Date: 2016-02-27 14:36:35 -0800 (Sat, 27 Feb 2016)
New Revision: 67971
Modified:
grass/trunk/include/defs/gis.h
grass/trunk/lib/gis/compress.h
grass/trunk/lib/raster/get_row.c
grass/trunk/lib/raster/put_row.c
Log:
generalize compression interface
Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h 2016-02-27 22:14:53 UTC (rev 67970)
+++ grass/trunk/include/defs/gis.h 2016-02-27 22:36:35 UTC (rev 67971)
@@ -164,6 +164,58 @@
int G_insert_commas(char *);
void G_remove_commas(char *);
+/* compress.c */
+int G_compressor_number(char *);
+char *G_compressor_name(int);
+int G_check_compressor(int);
+int G_write_compressed(int, unsigned char *, int, int);
+int G_write_unompressed(int, unsigned char *, int);
+int G_read_compressed(int, int, unsigned char *, int, int);
+int G_compress(unsigned char *, int, unsigned char *, int, int);
+int G_expand(unsigned char *, int, unsigned char *, int, int);
+
+/* compress.c : no compression */
+int
+G_no_compress(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+int
+G_no_expand(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+
+/* cmprrle.c : Run Length Encoding (RLE) */
+int
+G_rle_compress(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+int
+G_rle_expand(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+
+/* cmprzlib.c : ZLIB's DEFLATE */
+int
+G_zlib_compress(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+int
+G_zlib_expand(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+
+/* cmprlz4.c : LZ4, extremely fast */
+int
+G_lz4_compress(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+int
+G_lz4_expand(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+
+/* cmprbzip.c : BZIP2, high compression, faster than ZLIB's DEFLATE with level 9 */
+int
+G_bz2_compress(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+int
+G_bz2_expand(unsigned char *src, int src_sz, unsigned char *dst,
+ int dst_sz);
+
+/* add more compression methods here */
+
/* copy_dir.c */
int G_recursive_copy(const char *, const char *);
@@ -270,16 +322,6 @@
const char *G_find_vector(char *, const char *);
const char *G_find_vector2(const char *, const char *);
-/* compress.c */
-int G_compressor_number(char *);
-char *G_compressor_name(int);
-int G_check_compressor(int);
-int G_write_compressed(int, unsigned char *, int, int);
-int G_write_unompressed(int, unsigned char *, int);
-int G_read_compressed(int, int, unsigned char *, int, int);
-int G_compress(unsigned char *, int, unsigned char *, int, int);
-int G_expand(unsigned char *, int, unsigned char *, int, int);
-
/* geodesic.c */
int G_begin_geodesic_equation(double, double, double, double);
double G_geodesic_lat_from_lon(double);
Modified: grass/trunk/lib/gis/compress.h
===================================================================
--- grass/trunk/lib/gis/compress.h 2016-02-27 22:14:53 UTC (rev 67970)
+++ grass/trunk/lib/gis/compress.h 2016-02-27 22:36:35 UTC (rev 67971)
@@ -16,49 +16,6 @@
* modify G_compress(), G_expand()
*/
-
-/* compress.c : no compression */
-int
-G_no_compress(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-int
-G_no_expand(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-
-/* cmprrle.c : Run Length Encoding (RLE) */
-int
-G_rle_compress(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-int
-G_rle_expand(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-
-/* cmprzlib.c : ZLIB's DEFLATE */
-int
-G_zlib_compress(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-int
-G_zlib_expand(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-
-/* cmprlz4.c : LZ4, extremely fast */
-int
-G_lz4_compress(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-int
-G_lz4_expand(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-
-/* cmprbzip.c : BZIP2, high compression, faster than ZLIB's DEFLATE with level 9 */
-int
-G_bz2_compress(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-int
-G_bz2_expand(unsigned char *src, int src_sz, unsigned char *dst,
- int dst_sz);
-
-/* add more here */
-
typedef int compress_fn(unsigned char *src, int src_sz, unsigned char *dst,
int dst_sz);
typedef int expand_fn(unsigned char *src, int src_sz, unsigned char *dst,
Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c 2016-02-27 22:14:53 UTC (rev 67970)
+++ grass/trunk/lib/raster/get_row.c 2016-02-27 22:36:35 UTC (rev 67971)
@@ -844,7 +844,7 @@
}
/* null bits file compressed with LZ4, see lib/gis/compress.h */
- if (G_expand(compressed_buf, readamount, flags, size, 3) < 1) {
+ if (G_lz4_expand(compressed_buf, readamount, flags, size) < 1) {
G_fatal_error(_("Error uncompressing null data for row %d of <%s>"),
row, fcb->name);
}
Modified: grass/trunk/lib/raster/put_row.c
===================================================================
--- grass/trunk/lib/raster/put_row.c 2016-02-27 22:14:53 UTC (rev 67970)
+++ grass/trunk/lib/raster/put_row.c 2016-02-27 22:36:35 UTC (rev 67971)
@@ -506,7 +506,7 @@
compressed_buf = G_alloca(size + 1);
/* compress null bits file with LZ4, see lib/gis/compress.h */
- nwrite = G_compress(flags, size, compressed_buf, size, 3);
+ nwrite = G_lz4_compress(flags, size, compressed_buf, size);
if (nwrite > 0 && nwrite < size) {
if (write(fcb->null_fd, compressed_buf, nwrite) != nwrite)
More information about the grass-commit
mailing list