Exemplo n.º 1
0
	bool code (PrologElement * parameters, PrologResolution * resolution) {
		PrologElement * atom = 0;
		PrologElement * integers [] = {0, 0, 0, 0}; int integers_pointer = 0;
		PrologElement * doubles [] = {0, 0, 0, 0}; int doubles_pointer = 0;
		for (int ind = 0; ind < 4; ind++) {integers [ind] = doubles [ind] = 0;}
		bool earth_present = false;
		while (parameters -> isPair ()) {
			PrologElement * left = parameters -> getLeft ();
			if (left -> isAtom ()) atom = left;
			if (left -> isVar ()) atom = left;
			if (left -> isInteger () && integers_pointer < 4) integers [integers_pointer++] = left;
			if (left -> isDouble () && doubles_pointer < 4) doubles [doubles_pointer++] = left;
			if (left -> isEarth ()) earth_present = true;
			parameters = parameters -> getRight ();
		}
		if (atom != 0) {
			if (atom -> isVar ()) atom -> setAtom (new PrologAtom ());
			if (! atom -> isAtom ()) return false;
			PrologAtom * machine = atom -> getAtom ();
			if (machine -> getMachine () != 0) return false;
			generic_distributal_code * code = coder (machine, integers, doubles);
			if (code == 0) return false;
			if (earth_present) code -> seeder ();
			else seed_code (code, integers_pointer, integers, doubles_pointer);
			if (machine -> setMachine (code)) return true;
			delete code;
			return false;
		}
		return false;
	}
Exemplo n.º 2
0
 bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) override {
     if (srcRanges->numPlanes() > 4) return false; // something wrong we already have FRA when loading
     SimpleSymbolCoder<SimpleBitChance, RacIn<IO>, 18> coder(rac);
     max_lookback = coder.read_int2(1, nb_frames-1);
     v_printf(5,"[%i]",max_lookback);
     return true;
 }
Exemplo n.º 3
0
    void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coder(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderY(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderI(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderQ(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderA(rac);
        coder.write_int(1, MAX_PALETTE_SIZE, Palette_vector.size());
//        printf("Saving %lu colors: ", Palette_vector.size());
        prevPlanes pp(2);
        ColorVal min, max;
        for (Color c : Palette_vector) {
                ColorVal A=std::get<0>(c);
                coderA.write_int(srcRanges->min(3),srcRanges->max(3), A);
                if (std::get<0>(c) == 0) continue;
                srcRanges->minmax(0,pp,min,max);
                ColorVal Y=std::get<1>(c);
                coderY.write_int(min,max,Y);
                pp[0]=Y; srcRanges->minmax(1,pp,min,max);
                ColorVal I=std::get<2>(c);
                coderI.write_int(min, max, I);
                pp[1]=I; srcRanges->minmax(2,pp,min,max);
                coderQ.write_int(min, max, std::get<3>(c));
//                printf("YIQ(%i,%i,%i)\t", std::get<0>(c), std::get<1>(c), std::get<2>(c));
        }
//        printf("\nSaved palette of size: %lu\n",Palette_vector.size());
        v_printf(5,"[%lu]",Palette_vector.size());
    }
Exemplo n.º 4
0
    void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coder(rac);

//        printf("Saving Y Color Bucket: ");
        prevPlanes pixelL, pixelU;
        save_bucket(cb->bucket0, coder, srcRanges, 0, pixelL, pixelU);
//        printf("\nSaving I Color Buckets\n  ");
        pixelL.push_back(cb->min0);
        pixelU.push_back(cb->min0+CB0a-1);
        for (auto b : cb->bucket1) { save_bucket(b, coder, srcRanges, 1, pixelL, pixelU); pixelL[0] += CB0a; pixelU[0] += CB0a; }
//        printf("\nSaving Q Color Buckets\n  ");
        pixelL[0] = cb->min0;
        pixelU[0] = cb->min0+CB0b-1;
        pixelL.push_back(cb->min1);
        pixelU.push_back(cb->min1+CB1-1);
        for (auto bv : cb->bucket2) {
                pixelL[1] = cb->min1;
                pixelU[1] = cb->min1+CB1-1;
                for (auto b : bv) {
                        save_bucket(b, coder, srcRanges, 2, pixelL, pixelU);
                        pixelL[1] += CB1; pixelU[1] += CB1;
                }
                pixelL[0] += CB0b; pixelU[0] += CB0b;
        }
//        printf("\n");
        if (srcRanges->numPlanes() > 3) {
//          printf("Saving Alpha Color Bucket: ");
          save_bucket(cb->bucket3, coder, srcRanges, 3, pixelL, pixelU);
//          printf("\n");
        }
    }
Exemplo n.º 5
0
 bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 18> coder(rac);
     prevPlanes pixelL, pixelU;
     cb->bucket0 = load_bucket(coder, srcRanges, 0, pixelL, pixelU);
     pixelL.push_back(cb->min0);
     pixelU.push_back(cb->min0+CB0a-1);
     for (ColorBucket& b : cb->bucket1) {b=load_bucket(coder, srcRanges, 1, pixelL, pixelU); pixelL[0] += CB0a; pixelU[0] += CB0a; }
     if (srcRanges->min(2) < srcRanges->max(2)) {
       pixelL[0] = cb->min0;
       pixelU[0] = cb->min0+CB0b-1;
       pixelL.push_back(cb->min1);
       pixelU.push_back(cb->min1+CB1-1);
       for (auto& bv : cb->bucket2) {
             pixelL[1] = cb->min1;
             pixelU[1] = cb->min1+CB1-1;
             for (ColorBucket& b : bv) {
                     b=load_bucket(coder, srcRanges, 2, pixelL, pixelU);
                     pixelL[1] += CB1; pixelU[1] += CB1;
             }
             pixelL[0] += CB0b; pixelU[0] += CB0b;
       }
     }
     if (srcRanges->numPlanes() > 3) cb->bucket3 = load_bucket(coder, srcRanges, 3, pixelL, pixelU);
     return true;
 }
Exemplo n.º 6
0
void set_genotype(Population *population)
{
	for(int i = 0; i < POPULATION_SIZE; ++i)
	{
		coder(&population->individuals[i]);
	}
}
Exemplo n.º 7
0
	void LogService::on_message(Requestor* requestor, const PACKET& packet, void* body, const int64_t body_len){
		Super::on_message(requestor, packet, body, body_len);
		// prepare
		if(packet.command == SERVICE_LOG_NOTIFY){
			if(packet.option & OPT_BODY_IS_OBJECT_POINTER){
				WARN("fail to call %s, OPT_BODY_IS_OBJECT_POINTER is not support", __func__);
				return;
			}
			BinaryCoder<1024> coder(body, body_len);
			// decode param
			int64_t type =0;
			if(!coder.decodeInt64(type)){
				WARN("fail to call %s, decode type error", __func__);
				return;
			}
			int64_t flag =0;
			if(!coder.decodeInt64(flag)){
				WARN("fail to call %s, decode flag error", __func__);
				return;
			}
			String* content =coder.decodeString();
			if(!content){
				WARN("fail to call %s, decode content error", __func__);
				return;
			}

			// log
			_log(type, flag, content);
		}
		else{
			WARN("fail to call %s, command %lld is not support", __func__, (long long)packet.command);
		}
	}
Exemplo n.º 8
0
 void save(const ColorRanges *, RacOut<IO> &rac) const {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coder(rac);
     assert(nb == b.size());
     assert(nb == e.size());
     for (unsigned int i=0; i<nb; i+=1) { coder.write_int(0,cols,b[i]); }
     for (unsigned int i=0; i<nb; i+=1) { coder.write_int(0,cols-b[i],cols-e[i]); }
 }
Exemplo n.º 9
0
    bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coder(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderY(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderI(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderQ(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderA(rac);
        long unsigned size = coder.read_int(1, MAX_PALETTE_SIZE);
//        printf("Loading %lu colors: ", size);
        prevPlanes pp(2);
        ColorVal min, max;
        for (unsigned int p=0; p<size; p++) {
                ColorVal A=coderA.read_int(srcRanges->min(3),srcRanges->max(3));
                if (A == 0) { Palette_vector.push_back(Color(0,0,0,0)); continue; }
                srcRanges->minmax(0,pp,min,max);
                ColorVal Y=coderY.read_int(min,max);
                pp[0]=Y; srcRanges->minmax(1,pp,min,max);
                ColorVal I=coderI.read_int(min,max);
                pp[1]=I; srcRanges->minmax(2,pp,min,max);
                ColorVal Q=coderQ.read_int(min,max);
                Color c(A,Y,I,Q);
                Palette_vector.push_back(c);
//                printf("YIQ(%i,%i,%i)\t", std::get<0>(c), std::get<1>(c), std::get<2>(c));
        }
//        printf("\nLoaded palette of size: %lu\n",Palette_vector.size());
        v_printf(5,"[%lu]",Palette_vector.size());
        return true;
    }
Exemplo n.º 10
0
void OBJ33(void) {
  OBJ33_Employee coder("Joe Smith");
  OBJ33_Employee typist("Bill Jones");
  OBJ33_Manager designer("Jane Doe", typist);

  coder = designer;  // slices Jane Doe!
  coder.print();
}
Exemplo n.º 11
0
 bool load(const ColorRanges *, RacIn<IO> &rac) {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 18> coder(rac);
     seen_before.clear();
     seen_before.push_back(-1);
     for (unsigned int i=1; i<nb; i++) seen_before.push_back(coder.read_int(-1,i-1));
     int count=0; for(int i : seen_before) { if(i>=0) count++; } v_printf(5,"[%i]",count);
     return true;
 }
Exemplo n.º 12
0
 void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const override {
     SimpleSymbolCoder<SimpleBitChance, RacOut<IO>, 18> coder(rac);
     coder.write_int2(0, 1, subtract);
     if (subtract) v_printf(4,"Subtract");
     for (int p=0; p<srcRanges->numPlanes(); p++) {
         coder.write_int2(0, srcRanges->numPlanes()-1, permutation[p]);
         v_printf(5,"[%i->%i]",p,permutation[p]);
     }
 }
Exemplo n.º 13
0
static void encoding(const char* s)
{
	acl::mime_xxcode coder(false, false);
	acl::string out;

	coder.encode_update(s, strlen(s), &out);
	coder.encode_finish(&out);
	printf(">>>%s\n", out.c_str());
}
Exemplo n.º 14
0
void QAudioManager::addFileExtension(const QString coderName, const QString extension)
{
	setError(QCoder::NoError);
	QAbstractCoder *theCoder = coder(coderName, QAudioManager::Available);
	if(theCoder != NULL)
	{
		theCoder->addFileExtension(extension);
		testLibrary(theCoder);
	}
}
Exemplo n.º 15
0
void CTarArcFile_Lzma::close()
{
	if(m_opened){
		// 残ったバッファの分を処理する
		m_action = LZMA_FINISH;
		coder(NULL,0);
		lzma_end(&m_strm);
		m_demand_callback(this,NULL,0,DEMAND_CLOSE,m_callback_arg);
		m_opened=false;
	}
}
Exemplo n.º 16
0
    void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const {
        SimpleSymbolCoder<SimpleBitChance, RacOut<IO>, 24> coder(rac);
        for (int p=0; p<srcRanges->numPlanes(); p++) {
            ColorVal min = bounds[p].first;
            ColorVal max = bounds[p].second;
//            coder.write_int(0, srcRanges->max(p) - srcRanges->min(p), min - srcRanges->min(p));
//            coder.write_int(0, srcRanges->max(p) - min, max - min);
            coder.write_int(srcRanges->min(p), srcRanges->max(p), min);
            coder.write_int(min, srcRanges->max(p), max);
            v_printf(5,"[%i:%i..%i]",p,min,max);
        }
    }
Exemplo n.º 17
0
 bool load(const ColorRanges *, RacIn<IO> &rac) {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 18> coder(rac);
     for (unsigned int i=0; i<nb; i+=1) {b.push_back(coder.read_int(0,cols));}
     for (unsigned int i=0; i<nb; i+=1) {
         e.push_back(cols-coder.read_int(0,cols-b[i]));
         if (e[i] > cols || e[i] < b[i] || e[i] <= 0) {
             e_printf("\nError: FRS transform: invalid end column\n");
             return false;
         }
     }
     return true;
 }
Exemplo n.º 18
0
 void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const override {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coder(rac);
     for (int p=0; p<srcRanges->numPlanes(); p++) {
       coder.write_int(0, srcRanges->max(p)-srcRanges->min(p), CPalette_vector[p].size()-1);
       ColorVal min=srcRanges->min(p);
       int remaining=CPalette_vector[p].size()-1;
       for (unsigned int i=0; i<CPalette_vector[p].size(); i++) {
         coder.write_int(0, srcRanges->max(p)-min-remaining, CPalette_vector[p][i]-min);
         min = CPalette_vector[p][i]+1;
         remaining--;
       }
     }
 }
Exemplo n.º 19
0
 bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) override {
     SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 18> coder(rac);
     for (int p=0; p<srcRanges->numPlanes(); p++) {
       unsigned int nb = coder.read_int(0, srcRanges->max(p)-srcRanges->min(p)) + 1;
       ColorVal min=srcRanges->min(p);
       int remaining = nb-1;
       for (unsigned int i=0; i<nb; i++) {
         CPalette_vector[p].push_back(min + coder.read_int(0, srcRanges->max(p)-min-remaining));
         min = CPalette_vector[p][i]+1;
         remaining--;
       }
     }
     return true;
 }
Exemplo n.º 20
0
bool CTerrainMgr::LoadTexture(ITexture* pText)
{
	if (NULL == pText)
		return false;

	SafeRelease(m_Texture);
	m_Texture = pText;
	m_Texture->AddRef();
	CJPGDecoder coder(m_Texture, m_szTerrTexName.c_str());

	m_Param.m_RS.m_Texture_S0 =  m_Texture;
	m_Param.m_RS.m_Texture_S1 =  HasRenderFlag(TerrainFlag::Cliff)?NULL:m_Texture;
	return true;
}
Exemplo n.º 21
0
    void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coder(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderY(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderI(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderQ(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> coderA(rac);
        coder.write_int(1, MAX_PALETTE_SIZE, Palette_vector.size());
        prevPlanes pp(2);
        int sorted=1;
        coder.write_int(0, 1, sorted);
        if (sorted) {
            Color min(srcRanges->min(3), srcRanges->min(0), srcRanges->min(1), srcRanges->min(2));
            Color max(srcRanges->max(3), srcRanges->max(0), srcRanges->max(1), srcRanges->max(2));
            Color prev(-1,-1,-1,-1);
            for (Color c : Palette_vector) {
                ColorVal A=std::get<0>(c);
                coderA.write_int(std::get<0>(min), std::get<0>(max), A);
                if (alpha_zero_special && std::get<0>(c) == 0) continue;
                ColorVal Y=std::get<1>(c);
                coderY.write_int((std::get<0>(prev) == A ? std::get<1>(prev) : std::get<1>(min)), std::get<1>(max), Y);
                pp[0]=Y; srcRanges->minmax(1,pp,std::get<2>(min), std::get<2>(max));
                ColorVal I=std::get<2>(c);
                coderI.write_int(std::get<2>(min), std::get<2>(max), I);
                pp[1]=I; srcRanges->minmax(2,pp,std::get<3>(min), std::get<3>(max));
                coderQ.write_int(std::get<3>(min), std::get<3>(max), std::get<3>(c));

                std::get<0>(min) = std::get<0>(c);
                prev = c;
            }
        } else {
            ColorVal min, max;
            for (Color c : Palette_vector) {
                ColorVal A=std::get<0>(c);
                coderA.write_int(srcRanges->min(3),srcRanges->max(3), A);
                if (alpha_zero_special && std::get<0>(c) == 0) continue;
                srcRanges->minmax(0,pp,min,max);
                ColorVal Y=std::get<1>(c);
                coderY.write_int(min,max,Y);
                pp[0]=Y; srcRanges->minmax(1,pp,min,max);
                ColorVal I=std::get<2>(c);
                coderI.write_int(min, max, I);
                pp[1]=I; srcRanges->minmax(2,pp,min,max);
                coderQ.write_int(min, max, std::get<3>(c));
//                printf("YIQ(%i,%i,%i)\t", std::get<0>(c), std::get<1>(c), std::get<2>(c));
            }
        }
//        printf("\nSaved palette of size: %lu\n",Palette_vector.size());
        v_printf(5,"[%lu]",Palette_vector.size());
    }
Exemplo n.º 22
0
bool CTerrainMgr::LoadTexture(const char* filename)
{
	if (NULL==filename)
		return m_isInit = false;
	SafeRelease(m_Texture);

	m_szTerrTexName = filename;
	CTerrainMgr::st_TerrainTex->AddRef();
	m_Texture = CTerrainMgr::st_TerrainTex;
	CJPGDecoder coder(m_Texture, filename);

	m_Param.m_RS.m_Texture_S0 = m_Texture;
	m_Param.m_RS.m_Texture_S1 = HasRenderFlag(TerrainFlag::Cliff)?NULL:m_Texture;
	return true;
}
Exemplo n.º 23
0
size64 CTarArcFile_Lzma::write(void *buf, size64 size)
{
	if(m_error_status != ES_NO_ERROR){
		return 0;
	}
	if(m_mode==CM_NOTHING){
		m_mode=CM_ENCODE;
		if(!coder_initialize()){
			m_error_status = ES_FATAL_ERROR;
			return 0;
		}
	} else if(m_mode!=CM_ENCODE){
		return 0;
	}
	return coder(buf,size);
}
Exemplo n.º 24
0
    bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) {
        SimpleSymbolCoder<SimpleBitChance, RacIn<IO>, 24> coder(rac);
        bounds.clear();
        for (int p=0; p<srcRanges->numPlanes(); p++) {
//            ColorVal min = coder.read_int(0, srcRanges->max(p) - srcRanges->min(p)) + srcRanges->min(p);
//            ColorVal max = coder.read_int(0, srcRanges->max(p) - min) + min;
            ColorVal min = coder.read_int(srcRanges->min(p), srcRanges->max(p));
            ColorVal max = coder.read_int(min, srcRanges->max(p));
            if (min > max) return false;
            if (min < srcRanges->min(p)) return false;
            if (max > srcRanges->max(p)) return false;
            bounds.push_back(std::make_pair(min,max));
            v_printf(5,"[%i:%i..%i]",p,min,max);
        }
        return true;
    }
Exemplo n.º 25
0
Arquivo: palette.hpp Projeto: tml/FLIF
    void save(const ColorRanges *srcRanges, RacOut<IO> &rac) const override {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coder(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coderY(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coderI(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> coderQ(rac);
        coder.write_int2(1, MAX_PALETTE_SIZE, Palette_vector.size());
//        printf("Saving %lu colors: ", Palette_vector.size());
        prevPlanes pp(2);
        int sorted=(ordered_palette? 1 : 0);
        coder.write_int2(0, 1, sorted);
        if (sorted) {
            Color min(srcRanges->min(0), srcRanges->min(1), srcRanges->min(2));
            Color max(srcRanges->max(0), srcRanges->max(1), srcRanges->max(2));
            Color prev(-1,-1,-1);
            for (Color c : Palette_vector) {
                ColorVal Y=std::get<0>(c);
                coderY.write_int2(std::get<0>(min), std::get<0>(max), Y);
                pp[0]=Y;
                srcRanges->minmax(1,pp,std::get<1>(min), std::get<1>(max));
                ColorVal I=std::get<1>(c);
                coderI.write_int2((std::get<0>(prev) == Y ? std::get<1>(prev): std::get<1>(min)), std::get<1>(max), I);
                pp[1]=I;
                srcRanges->minmax(2,pp,std::get<2>(min), std::get<2>(max));
                coderQ.write_int2(std::get<2>(min), std::get<2>(max), std::get<2>(c));
                std::get<0>(min) = std::get<0>(c);
                prev = c;
            }
        } else {
            ColorVal min, max;
            for (Color c : Palette_vector) {
                ColorVal Y=std::get<0>(c);
                srcRanges->minmax(0,pp,min,max);
                coderY.write_int2(min,max,Y);
                pp[0]=Y;
                srcRanges->minmax(1,pp,min,max);
                ColorVal I=std::get<1>(c);
                coderI.write_int2(min, max, I);
                pp[1]=I;
                srcRanges->minmax(2,pp,min,max);
                coderQ.write_int2(min, max, std::get<2>(c));
//                printf("YIQ(%i,%i,%i)\t", std::get<0>(c), std::get<1>(c), std::get<2>(c));
            }
        }
//        printf("\nSaved palette of size: %lu\n",Palette_vector.size());
        v_printf(5,"[%lu]",Palette_vector.size());
        if (!ordered_palette) v_printf(5,"Unsorted");
    }
Exemplo n.º 26
0
    bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) {
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coder(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderY(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderI(rac);
        SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> coderQ(rac);
        long unsigned size = coder.read_int(1, MAX_PALETTE_SIZE);
//        printf("Loading %lu colors: ", size);
        prevPlanes pp(2);
        int sorted = coder.read_int(0,1);
        if (sorted) {
            Color min(srcRanges->min(0), srcRanges->min(1), srcRanges->min(2));
            Color max(srcRanges->max(0), srcRanges->max(1), srcRanges->max(2));
            Color prev(-1,-1,-1);
            for (unsigned int p=0; p<size; p++) {
                ColorVal Y=coderY.read_int(std::get<0>(min), std::get<0>(max));
                pp[0]=Y;
                srcRanges->minmax(1,pp,std::get<1>(min), std::get<1>(max));
                ColorVal I=coderI.read_int((std::get<0>(prev) == Y ? std::get<1>(prev): std::get<1>(min)), std::get<1>(max));
                pp[1]=I;
                srcRanges->minmax(2,pp,std::get<2>(min), std::get<2>(max));
                ColorVal Q=coderQ.read_int(std::get<2>(min), std::get<2>(max));
                Color c(Y,I,Q);
                Palette_vector.push_back(c);
                std::get<0>(min) = std::get<0>(c);
                prev = c;
            }
        } else {
            ColorVal min, max;
            for (unsigned int p=0; p<size; p++) {
                srcRanges->minmax(0,pp,min,max);
                ColorVal Y=coderY.read_int(min,max);
                pp[0]=Y;
                srcRanges->minmax(1,pp,min,max);
                ColorVal I=coderI.read_int(min,max);
                pp[1]=I;
                srcRanges->minmax(2,pp,min,max);
                ColorVal Q=coderQ.read_int(min,max);
                Color c(Y,I,Q);
                Palette_vector.push_back(c);
//                printf("YIQ(%i,%i,%i)\t", std::get<0>(c), std::get<1>(c), std::get<2>(c));
            }
        }
//        printf("\nLoaded palette of size: %lu\n",Palette_vector.size());
        v_printf(5,"[%lu]",Palette_vector.size());
        return true;
    }
Exemplo n.º 27
0
QAbstractCoder* QAudioManager::coder(const QAudioCodec *codec, const QAudioManager::Mode mode)
{
	setError(QCoder::NoError);
	if(codec != NULL)
	{
		if(mode == QAudioManager::Available)
		{
			for(int i = 0; i < mAvailableCoders.size(); ++i)
			{
				QList<QAudioCodec*> codecs = mAvailableCoders[i]->supportedCodecs();
				for(int j = 0; j < codecs.size(); ++j)
				{
					if((*codecs[j]) == (*codec))
					{
						return mAvailableCoders[i];
					}
				}
			}
			if(coder(codec, QAudioManager::Supported) != NULL)
			{
				setError(QCoder::UnavailableCodecError);
			}
		}
		else
		{
			for(int i = 0; i < mSupportedCoders.size(); ++i)
			{
				QList<QAudioCodec*> codecs = mSupportedCoders[i]->supportedCodecs();
				for(int j = 0; j < codecs.size(); ++j)
				{
					if((*codecs[j]) == (*codec))
					{
						return mSupportedCoders[i];
					}
				}
			}
			setError(QCoder::UnsupportedCodecError);
		}
	}
	else
	{
		setError(QCoder::UnsupportedCodecError);
	}
	return NULL;
}
Exemplo n.º 28
0
Arquivo: main.cpp Projeto: rudi-c/hifi
void testByteCountCodedStable(const T& value) {
    ByteCountCoded<T> coder((T)value);
    auto encoded = coder.encode();
    #ifndef QT_NO_DEBUG
    auto originalEncodedSize = encoded.size();
    #endif
    for (int i = 0; i < 10; ++i) {
        encoded.append(qrand());
    }
    ByteCountCoded<T> decoder;
    decoder.decode(encoded);
    Q_ASSERT(decoder.data == coder.data);
    #ifndef QT_NO_DEBUG
    auto consumed = decoder.decode(encoded.data(), encoded.size());
    #endif
    Q_ASSERT(consumed == (unsigned int)originalEncodedSize);

}
Exemplo n.º 29
0
int main(int argc, char **argv) {
	if (argc <= 1) {
		print_usage();
		return 1;
	}

	FILE* input_file = (strcmp(argv[1], "-") ? fopen(argv[1], "r") : stdin);
	FILE* output_file = (argc <= 2 ? fopen("23.txt", "w")
			: (strcmp(argv[2], "-") ? fopen(argv[2], "w") : stdout));

	entropycoding::HuffmanCoder coder(source::symbol_frequencies());
	for (char c; (c = getc(input_file)) != EOF && !isEndline(c); )
		fputs(coder.code(c).toString().c_str(), output_file);

	fclose(input_file);
	fclose(output_file);

	return 0;
}
Exemplo n.º 30
0
 bool load(const ColorRanges *srcRanges, RacIn<IO> &rac) override {
     SimpleSymbolCoder<SimpleBitChance, RacIn<IO>, 18> coder(rac);
     subtract = coder.read_int2(0, 1);
     if (subtract) v_printf(4,"Subtract");
     bool from[4] = {false, false, false, false}, to[4] = {false, false, false, false};
     for (int p=0; p<srcRanges->numPlanes(); p++) {
         permutation[p] = coder.read_int2(0, srcRanges->numPlanes()-1);
         v_printf(5,"[%i->%i]",p,permutation[p]);
         from[p] = true;
         to[permutation[p]] = true;
     }
     for (int p=0; p<srcRanges->numPlanes(); p++) {
         if (!from[p] || !to[p]) {
             e_printf("\nNot a valid permutation!\n");
             return false;
         }
     }
     return true;
 }