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
f8b6669
commit a7c8af4
Showing
33 changed files
with
5,237 additions
and
4 deletions.
There are no files selected for viewing
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,65 @@ | ||
# | ||
# Makefile.in -- a part of libdecodeqr | ||
# | ||
# Copyright(C) 2007 NISHI Takao <zophos@koka-in.org> | ||
# JMA (Japan Medical Association) | ||
# NaCl (Network Applied Communication Laboratory Ltd.) | ||
# | ||
# This is free software with ABSOLUTELY NO WARRANTY. | ||
# You can redistribute and/or modify it under the terms of LGPL. | ||
# | ||
# $Id: Makefile 20 2006-11-20 03:26:52Z zophos $ | ||
# | ||
prefix = @prefix@ | ||
exec_prefix = @exec_prefix@ | ||
libdir = @libdir@ | ||
includedir = @includedir@ | ||
|
||
MAJOR=@MAJOR@ | ||
MINOR=@MINOR@ | ||
TEENY=@TEENY@ | ||
|
||
BASENAME=libdecodeqr | ||
LIBNAME_A=$(BASENAME).a | ||
SONAME=$(BASENAME).so.$(MAJOR) | ||
LIBNAME_SO=$(BASENAME).so.$(MAJOR).$(MINOR).$(TEENY) | ||
|
||
CXX=@CXX@ | ||
CPPFLAGS=@CPPFLAGS@ @CXXFLAGS@ -fPIC -c | ||
|
||
AR=@AR@ | ||
ARFLAGS=rcs | ||
|
||
LD=@LD@ | ||
LDFLAGS=@LDFLAGS@ -shared -soname $(SONAME) | ||
LIBCV=@LIBCV@ | ||
LIBS=$(LIBCV) | ||
|
||
INSTALL=@INSTALL@ | ||
LDCONFIG=/sbin/ldconfig | ||
LN=@LN@ | ||
|
||
.SUFFIXES: .cpp .o | ||
.cpp.o: | ||
$(CXX) $(CPPFLAGS) $< | ||
|
||
sources:=$(wildcard *.cpp) | ||
objs:=$(patsubst %.cpp,%.o,$(wildcard *.cpp)) | ||
dsts:=$(LIBNAME_A) $(LIBNAME_SO) decodeqr.h | ||
|
||
all: $(dsts) | ||
|
||
$(LIBNAME_A): $(objs) | ||
$(AR) $(ARFLAGS) $@ $(objs) | ||
|
||
$(LIBNAME_SO): $(objs) | ||
$(LD) -o $@ $(objs) $(LDFLAGS) $(LIBS) | ||
|
||
install: $(dsts) | ||
$(INSTALL) -m 0755 $(LIBNAME_A) $(LIBNAME_SO) $(libdir) | ||
$(LDCONFIG) -n $(libdir) | ||
$(LN) -sf $(libdir)/$(LIBNAME_SO) $(libdir)/$(BASENAME).so | ||
$(INSTALL) -m 0644 decodeqr.h qrerror.h qrtypes.h $(includedir) | ||
|
||
clean: | ||
-rm *.a *.o *.so.* |
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,147 @@ | ||
///////////////////////////////////////////////////////////////////////// | ||
// | ||
// bitstream.cpp --a part of libdecodeqr | ||
// | ||
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org> | ||
// JMA (Japan Medical Association) | ||
// NaCl (Network Applied Communication Laboratory Ltd.) | ||
// | ||
// This is free software with ABSOLUTELY NO WARRANTY. | ||
// You can redistribute and/or modify it under the terms of LGPL. | ||
// | ||
// $Id: bitstream.cpp 36 2007-02-21 23:22:03Z zophos $ | ||
// | ||
#include "bitstream.h" | ||
|
||
namespace Qr{ | ||
BitStream::BitStream() | ||
{ | ||
this->data=NULL; | ||
this->byte_size=0; | ||
this->bit_size=0; | ||
this->_pos=0; | ||
} | ||
BitStream::BitStream(void *src,int size) | ||
{ | ||
this->byte_size=size; | ||
this->bit_size=size<<3; | ||
this->data=new unsigned char[size]; | ||
memcpy(this->data,src,size); | ||
this->_pos=0; | ||
} | ||
BitStream::~BitStream() | ||
{ | ||
if(this->data) | ||
delete this->data; | ||
} | ||
|
||
bool BitStream::is_eod() | ||
{ | ||
return(this->_pos>=this->bit_size); | ||
} | ||
int BitStream::position() | ||
{ | ||
return(this->_pos); | ||
} | ||
int BitStream::seek(int pos) | ||
{ | ||
this->_pos+=pos; | ||
if(this->_pos<0) | ||
this->_pos=0; | ||
if(this->_pos>this->bit_size) | ||
this->_pos=this->bit_size; | ||
|
||
return(this->_pos); | ||
} | ||
void BitStream::rewind() | ||
{ | ||
this->_pos=0; | ||
} | ||
|
||
unsigned char *BitStream::read(int read_bits) | ||
{ | ||
int byte_size=(read_bits>>3)+(read_bits&0x07?1:0); | ||
unsigned char *buf=new unsigned char[byte_size]; | ||
memset(buf,0,byte_size); | ||
|
||
this->read(buf,byte_size,read_bits); | ||
|
||
return(buf); | ||
} | ||
int BitStream::read(void *dst,int buf_size,int read_bits) | ||
{ | ||
memset(dst,0,buf_size); | ||
|
||
if(read_bits>(buf_size<<3)) | ||
read_bits=buf_size<<3; | ||
|
||
int end_bit=this->_pos+read_bits-1; | ||
if(end_bit>=this->bit_size){ | ||
end_bit=this->bit_size-1; | ||
read_bits=this->bit_size-this->_pos; | ||
} | ||
int remain_bits=(end_bit+1)&0x07; | ||
int offset=this->_pos>>3; | ||
int read_bytes=(read_bits>>3)+(read_bits&0x07?1:0); | ||
|
||
if(read_bytes<buf_size){ | ||
int diff=buf_size-read_bytes; | ||
unsigned char *tmp=(unsigned char *)dst; | ||
tmp+=diff; | ||
dst=tmp; | ||
} | ||
|
||
if(remain_bits){ | ||
unsigned char *src=data+offset; | ||
unsigned char *tmp=(unsigned char *)dst; | ||
|
||
int i=0; | ||
if(read_bytes==(end_bit>>3)-offset+1){ | ||
tmp++; | ||
i++; | ||
} | ||
for(;i<read_bytes;i++,src++,tmp++){ | ||
*tmp=*src<<remain_bits; | ||
} | ||
remain_bits=8-remain_bits; | ||
src=data+(end_bit>>3); | ||
tmp--; | ||
for(i=0;i<read_bytes;i++,src--,tmp--){ | ||
*tmp|=*src>>remain_bits; | ||
} | ||
} | ||
else{ | ||
memcpy(dst,this->data+offset,read_bytes); | ||
} | ||
|
||
unsigned char mask=0xff; | ||
switch(8-(read_bits&0x07)){ | ||
case 1: | ||
mask=0x7f; | ||
break; | ||
case 2: | ||
mask=0x3f; | ||
break; | ||
case 3: | ||
mask=0x1f; | ||
break; | ||
case 4: | ||
mask=0x0f; | ||
break; | ||
case 5: | ||
mask=0x07; | ||
break; | ||
case 6: | ||
mask=0x03; | ||
break; | ||
case 7: | ||
mask=0x01; | ||
break; | ||
} | ||
*((unsigned char *)dst)&=mask; | ||
this->_pos+=read_bits; | ||
|
||
return(read_bits); | ||
} | ||
|
||
} |
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,48 @@ | ||
///////////////////////////////////////////////////////////////////////// | ||
// | ||
// bitstream.h --a part of libdecodeqr | ||
// | ||
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org> | ||
// JMA (Japan Medical Association) | ||
// NaCl (Network Applied Communication Laboratory Ltd.) | ||
// | ||
// This is free software with ABSOLUTELY NO WARRANTY. | ||
// You can redistribute and/or modify it under the terms of LGPL. | ||
// | ||
// $Id: bitstream.h 36 2007-02-21 23:22:03Z zophos $ | ||
// | ||
#ifndef __QR_BITSTREAM__ | ||
#define __QR_BITSTREAM__ | ||
|
||
#include <memory.h> | ||
|
||
#ifndef NULL | ||
#define NULL 0 | ||
#endif | ||
|
||
namespace Qr{ | ||
class BitStream{ | ||
public: | ||
unsigned char *data; | ||
int byte_size; | ||
int bit_size; | ||
|
||
private: | ||
int _pos; | ||
|
||
public: | ||
BitStream(); | ||
BitStream(void *src,int size); | ||
~BitStream(); | ||
|
||
bool is_eod(); | ||
int position(); | ||
int seek(int pos); | ||
void rewind(); | ||
|
||
unsigned char *read(int read_bits); | ||
int read(void *dst,int buf_size,int bitsize); | ||
}; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.