2012-12-03 18:15:41 +00:00
|
|
|
/*
|
|
|
|
* This file is a part of Pcompress, a chunked parallel multi-
|
|
|
|
* algorithm lossless compression and decompression program.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
|
2012-12-03 18:15:41 +00:00
|
|
|
* Use is subject to license terms.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2012-12-03 18:15:41 +00:00
|
|
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
2013-11-10 17:39:42 +00:00
|
|
|
*
|
2012-12-03 18:15:41 +00:00
|
|
|
*/
|
|
|
|
|
2013-11-10 17:39:42 +00:00
|
|
|
/*
|
|
|
|
*/
|
2012-12-03 18:15:41 +00:00
|
|
|
#include <sys/types.h>
|
2013-11-10 17:39:42 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <packjpglib.h>
|
2012-12-03 18:15:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-11-10 17:39:42 +00:00
|
|
|
typedef unsigned char uchar_t;
|
2012-12-03 18:15:41 +00:00
|
|
|
|
2013-11-13 17:58:01 +00:00
|
|
|
/* a short reminder about input/output stream types
|
|
|
|
for the pjglib_init_streams() function
|
|
|
|
|
|
|
|
if input is file
|
|
|
|
----------------
|
|
|
|
in_scr -> name of input file
|
|
|
|
in_type -> 0
|
|
|
|
in_size -> ignore
|
|
|
|
|
|
|
|
if input is memory
|
|
|
|
------------------
|
|
|
|
in_scr -> array containg data
|
|
|
|
in_type -> 1
|
|
|
|
in_size -> size of data array
|
|
|
|
|
|
|
|
if input is *FILE (f.e. stdin)
|
|
|
|
------------------------------
|
|
|
|
in_src -> stream pointer
|
|
|
|
in_type -> 2
|
|
|
|
in_size -> ignore
|
|
|
|
|
|
|
|
vice versa for output streams! */
|
|
|
|
|
2013-11-10 17:39:42 +00:00
|
|
|
size_t
|
|
|
|
packjpg_filter_process(uchar_t *in_buf, size_t len, uchar_t **out_buf)
|
|
|
|
{
|
|
|
|
unsigned int len1;
|
|
|
|
|
|
|
|
pjglib_init_streams(in_buf, 1, len, *out_buf, 1);
|
|
|
|
len1 = len;
|
|
|
|
if (!pjglib_convert_stream2mem(out_buf, &len1, NULL))
|
|
|
|
return (0);
|
|
|
|
if (len1 == len)
|
|
|
|
return (0);
|
|
|
|
return (len1);
|
|
|
|
}
|
2012-12-03 18:15:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|