Esempio n. 1
0
static inline size_t lz4hc_commonlength(const u8 *p1, const u8 *p2,
		const u8 *const matchlimit)
{
	const u8 *p1t = p1;

	while (p1t < matchlimit - (STEPSIZE - 1)) {
#if LZ4_ARCH64
		u64 diff = A64(p2) ^ A64(p1t);
#else
		u32 diff = A32(p2) ^ A32(p1t);
#endif
		if (!diff) {
			p1t += STEPSIZE;
			p2 += STEPSIZE;
			continue;
		}
		p1t += LZ4_NBCOMMONBYTES(diff);
		return p1t - p1;
	}
#if LZ4_ARCH64
	if ((p1t < (matchlimit-3)) && (A32(p2) == A32(p1t))) {
		p1t += 4;
		p2 += 4;
	}
#endif

	if ((p1t < (matchlimit - 1)) && (A16(p2) == A16(p1t))) {
		p1t += 2;
		p2 += 2;
	}
	if ((p1t < matchlimit) && (*p2 == *p1t))
		p1t++;
	return p1t - p1;
}
Esempio n. 2
0
		std::string makeFormattedString(
		const char* aFormat,
		const A1& a1 = A1(),
		const A2& a2 = A2(),
		const A3& a3 = A3(),
		const A4& a4 = A4(),
		const A5& a5 = A5(),
		const A6& a6 = A6(),
		const A7& a7 = A7(),
		const A8& a8 = A8(),
		const A9& a9 = A9(),
		const A10& a10 = A10(),
		const A11& a11 = A11(),
		const A12& a12 = A12(),
		const A13& a13 = A13(),
		const A14& a14 = A14(),
		const A15& a15 = A15(),
		const A16& a16 = A16(),
		const A17& a17 = A17(),
		const A18& a18 = A18(),
		const A19& a19 = A19(),
		const A20& a20 = A20()
		)
		{
			return makeStringByPrintf(aFormat,
				a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
				a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
				);
		}
Esempio n. 3
0
void code2(int mode, LPSYMBOL s1, LPSYMBOL s2)
{
	switch (mode) {
	case AM_R8:
		R8(s1->instr, s2->val8);
		break;
	case AM_R16:
		R16(s1->instr, s2->val8);
		break;
	case AM_M8:
		M8(s1->instr, s2->val8);
		break;
	case AM_M16:
		M16(s1->instr, s2->val8);
		break;
	case AM_A8:
		A8(s1->instr, s2->val16);
		break;
	case AM_A16:
		A16(s1->instr, s2->val16);
		break;
	case AM_I16:
		I16(s1->instr, s2->val16);
		break;
	case AM_I8:
		I8(s1->instr, s2->val8);
		break;
	default:
		break;
	}
}
Esempio n. 4
0
static inline int lz4hc_insertandgetwidermatch(struct lz4hc_data *hc4,
	const u8 *ip, const u8 *startlimit, const u8 *matchlimit, int longest,
	const u8 **matchpos, const u8 **startpos)
{
	u16 *const chaintable = hc4->chaintable;
	HTYPE *const hashtable = hc4->hashtable;
#if LZ4_ARCH64
	const BYTE * const base = hc4->base;
#else
	const int base = 0;
#endif
	const u8 *ref;
	int nbattempts = MAX_NB_ATTEMPTS;
	int delta = (int)(ip - startlimit);

	/* First Match */
	lz4hc_insert(hc4, ip);
	ref = hashtable[HASH_VALUE(ip)] + base;

	while ((ref >= ip - MAX_DISTANCE) && (ref >= hc4->base)
		&& (nbattempts)) {
		nbattempts--;
		if (*(startlimit + longest) == *(ref - delta + longest)) {
			if (A32(ref) == A32(ip)) {
				const u8 *reft = ref + MINMATCH;
				const u8 *ipt = ip + MINMATCH;
				const u8 *startt = ip;

				while (ipt < matchlimit-(STEPSIZE - 1)) {
					#if LZ4_ARCH64
					u64 diff = A64(reft) ^ A64(ipt);
					#else
					u32 diff = A32(reft) ^ A32(ipt);
					#endif

					if (!diff) {
						ipt += STEPSIZE;
						reft += STEPSIZE;
						continue;
					}
					ipt += LZ4_NBCOMMONBYTES(diff);
					goto _endcount;
				}
				#if LZ4_ARCH64
				if ((ipt < (matchlimit - 3))
					&& (A32(reft) == A32(ipt))) {
					ipt += 4;
					reft += 4;
				}
				ipt += 2;
				#endif
				if ((ipt < (matchlimit - 1))
					&& (A16(reft) == A16(ipt))) {
					reft += 2;
				}
				if ((ipt < matchlimit) && (*reft == *ipt))
					ipt++;
_endcount:
				reft = ref;

				while ((startt > startlimit)
					&& (reft > hc4->base)
					&& (startt[-1] == reft[-1])) {
					startt--;
					reft--;
				}

				if ((ipt - startt) > longest) {
					longest = (int)(ipt - startt);
					*matchpos = reft;
					*startpos = startt;
				}
			}
		}
		ref -= (size_t)chaintable[(size_t)(ref) & MAXD_MASK];
	}
	return longest;
}
Esempio n. 5
0
TextureFormat const *
TextureFormat::fromCode(Code code)
{
  switch (code)
  {
    case Code::L8:
      return L8();

    case Code::L16:
      return L16();

    case Code::L16F:
      return L16F();

    case Code::L32F:
      return L32F();

    case Code::A8:
      return A8();

    case Code::A16:
      return A16();

    case Code::A16F:
      return A16F();

    case Code::A32F:
      return A32F();

    case Code::LA4:
      return LA4();

    case Code::LA8:
      return LA8();

    case Code::LA16:
      return LA16();

    case Code::LA16F:
      return LA16F();
      break;

    case Code::LA32F:
      return LA32F();

    case Code::RGB5:
      return RGB5();

    case Code::RGB5A1:
      return RGB5A1();

    case Code::RGB8:
      return RGB8();

    case Code::RGB10:
      return RGB10();

    case Code::RGB10A2:
      return RGB10A2();

    case Code::RGB16:
      return RGB16();

    case Code::RGB32F:
      return RGB32F();

    case Code::R11G11B10F:
      return R11G11B10F();

    case Code::RGB9E5F:
      return RGB9E5F();

    case Code::RGB8I:
      return RGB8I();

    case Code::RGB8UI:
      return RGB8UI();

    case Code::ARGB8:
      return NULL;

    case Code::BGR8:
      return BGR8();

    case Code::BGRA8:
      return BGRA8();

    case Code::BGR16:
      return BGR16();

    case Code::BGRA16:
      return BGRA16();

    case Code::BGR32F:
      return BGR32F();

    case Code::BGRA32F:
      return BGRA32F();

    case Code::R8:
      return R8();

    case Code::RG8:
      return RG8();

    case Code::RG8I:
      return RG8I();

    case Code::RG8UI:
      return RG8UI();

    case Code::RG16F:
      return RG16F();

    case Code::RGBA8:
      return RGBA8();

    case Code::RGBA16:
      return RGBA16();

    case Code::RGBA16F:
      return RGBA16F();

    case Code::RGBA32F:
      return RGBA32F();

    case Code::RGBA32UI:
      return RGBA32UI();

    case Code::BAYER_RGGB8:

      // TODO
    case Code::BAYER_GRBG8:

      // TODO
    case Code::BAYER_GBRG8:

      // TODO
    case Code::BAYER_BGGR8:

      // TODO
    case Code::BAYER_RGGB32F:

      // TODO
    case Code::BAYER_GRBG32F:

      // TODO
    case Code::BAYER_GBRG32F:

      // TODO
    case Code::BAYER_BGGR32F:

      // TODO
    case Code::HSV8:

      // TODO
    case Code::HSV32F:
      // TODO
      return NULL;
      break;

    case Code::RGB_DXT1:
      return RGB_DXT1();
      break;

    case Code::RGBA_DXT1:
      return RGBA_DXT1();
      break;

    case Code::RGBA_DXT3:
      return RGBA_DXT3();
      break;

    case Code::RGBA_DXT5:
      return RGBA_DXT5();
      break;

    case Code::SRGB8:
      return SRGB8();
      break;

    case Code::SRGBA8:
      return SRGBA8();
      break;

    case Code::SL8:
      return SL8();
      break;

    case Code::SLA8:
      return SLA8();
      break;

    case Code::SRGB_DXT1:
      return SRGB_DXT1();
      break;

    case Code::SRGBA_DXT1:
      return SRGBA_DXT1();
      break;

    case Code::SRGBA_DXT3:
      return SRGBA_DXT3();
      break;

    case Code::SRGBA_DXT5:
      return SRGBA_DXT5();
      break;

    case Code::DEPTH16:
      return DEPTH16();
      break;

    case Code::DEPTH24:
      return DEPTH24();
      break;

    case Code::DEPTH32:
      return DEPTH32();
      break;

    case Code::DEPTH32F:
      return DEPTH32F();
      break;

    case Code::STENCIL1:
      return STENCIL1();
      break;

    case Code::STENCIL4:
      return STENCIL4();
      break;

    case Code::STENCIL8:
      return STENCIL8();
      break;

    case Code::STENCIL16:
      return STENCIL16();
      break;

    case Code::DEPTH24_STENCIL8:
      return DEPTH24_STENCIL8();
      break;

    case Code::YUV420_PLANAR:
      return YUV420_PLANAR();
      break;

    case Code::YUV422:
      return YUV422();
      break;

    case Code::YUV444:
      return YUV444();
      break;

    default:
      return NULL;
  }
}
SolidesP	ConstruireNormale (FacesP Face)
// Construit un solide symbolisant la normale à la face.
// Le solide est placé sur le barycentre de la face et peut donc
// être hors de la face.
// Sa longueur est égale à 5% de la dimension du solide à laquelle la
// face appartient s'il existe. Sinon, c'est 10 % de la dimension de la face.
{
	SolidesP	Sol = Face.Solide () ;

	double	HauteurTot ;

	Englobants3D	EnglobantFace = Face.Englobant () ;

	if (Sol.EstInitialise ()) {
		Englobants3D	E = Sol.Englobant () ;
		Vecteurs3D		V (E.BasGauche (),E.HautDroit ()) ;
		HauteurTot = 0.05*V.Norme () ; ;
	}
	else {
		Vecteurs3D		V (EnglobantFace.BasGauche (),EnglobantFace.HautDroit ()) ;
		HauteurTot = 0.1*V.Norme () ; ;
	}

	double	LargeurPied = HauteurTot / 24,
            LargeurTete = HauteurTot / 4,
            HauteurPied = (7./8.)*HauteurTot ;

	// Construction d'un repère centré sur le "barycentre" de la face, dont
	// le (xOy) correspond au plan de la face et dont le z est la normale à
	// la face.
	Points3D	Origine = 0.5*(EnglobantFace.BasGauche ()+EnglobantFace.HautDroit ()) ;

	Vecteurs3D	K = Face.VecteurNormal ().VecteurNorme (),
				U (Face.ContourExterieur ().IemeAreteOrientee (0).Origine ().Point3D (),
				Face.ContourExterieur ().IemeAreteOrientee (0).Extremite ().Point3D ()),
				I = (K & U).VecteurNorme (),
				J = (K & I).VecteurNorme () ;

	SommetsP	S1 (Origine-LargeurPied/2*I - LargeurPied/2*J) ;
	SommetsP	S2 (Origine-LargeurPied/2*I + LargeurPied/2*J) ;
	SommetsP	S3 (Origine+LargeurPied/2*I + LargeurPied/2*J) ;
	SommetsP	S4 (Origine+LargeurPied/2*I - LargeurPied/2*J) ;
	SommetsP	S5 (Origine-LargeurPied/2*I - LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S6 (Origine-LargeurPied/2*I + LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S7 (Origine+LargeurPied/2*I + LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S8 (Origine+LargeurPied/2*I - LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S9 (Origine-LargeurTete/2*I - LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S10 (Origine-LargeurTete/2*I + LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S11 (Origine+LargeurTete/2*I + LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S12 (Origine+LargeurTete/2*I - LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S13 (Origine+HauteurTot*K) ;

	AretesP	A1 (S1,S2) ;
	AretesP	A2 (S2,S3) ;
	AretesP	A3 (S3,S4) ;
	AretesP	A4 (S4,S1) ;
	AretesP	A5 (S5,S6) ;
	AretesP	A6 (S6,S7) ;
	AretesP	A7 (S7,S8) ;
	AretesP	A8 (S8,S5) ;
	AretesP	A9 (S9,S10) ;
	AretesP	A10 (S10,S11) ;
	AretesP	A11 (S11,S12) ;
	AretesP	A12 (S12,S9) ;
	AretesP	A13 (S1,S5) ;
	AretesP	A14 (S2,S6) ;
	AretesP	A15 (S3,S7) ;
	AretesP	A16 (S4,S8) ;
	AretesP	A17 (S9,S13) ;
	AretesP	A18 (S10,S13) ;
	AretesP	A19 (S11,S13) ;
	AretesP	A20 (S12,S13) ;

	Listes <AretesP>	L1 ;
	L1.InsertionEnQueue (A1) ;
	L1.InsertionEnQueue (A2) ;
	L1.InsertionEnQueue (A3) ;
	L1.InsertionEnQueue (A4) ;

	Listes <AretesP>	L2 ;
	L2.InsertionEnQueue (A1) ;
	L2.InsertionEnQueue (A13) ;
	L2.InsertionEnQueue (A5) ;
	L2.InsertionEnQueue (A14) ;

	Listes <AretesP>	L3 ;
	L3.InsertionEnQueue (A2) ;
	L3.InsertionEnQueue (A14) ;
	L3.InsertionEnQueue (A6) ;
	L3.InsertionEnQueue (A15) ;

	Listes <AretesP>	L4 ;
	L4.InsertionEnQueue (A3) ;
	L4.InsertionEnQueue (A15) ;
	L4.InsertionEnQueue (A7) ;
	L4.InsertionEnQueue (A16) ;

	Listes <AretesP>	L5 ;
	L5.InsertionEnQueue (A4) ;
	L5.InsertionEnQueue (A16) ;
	L5.InsertionEnQueue (A8) ;
	L5.InsertionEnQueue (A13) ;

	Listes <AretesP>	L6 ;
	L6.InsertionEnQueue (A9) ;
	L6.InsertionEnQueue (A10) ;
	L6.InsertionEnQueue (A11) ;
	L6.InsertionEnQueue (A12) ;

	Listes <AretesP>	L7 ;
	L7.InsertionEnQueue (A8) ;
	L7.InsertionEnQueue (A7) ;
	L7.InsertionEnQueue (A6) ;
	L7.InsertionEnQueue (A5) ;

	Listes <AretesP>	L8 ;
	L8.InsertionEnQueue (A9) ;
	L8.InsertionEnQueue (A17) ;
	L8.InsertionEnQueue (A18) ;

	Listes <AretesP>	L9 ;
	L9.InsertionEnQueue (A10) ;
	L9.InsertionEnQueue (A18) ;
	L9.InsertionEnQueue (A19) ;

	Listes <AretesP>	L10 ;
	L10.InsertionEnQueue (A11) ;
	L10.InsertionEnQueue (A19) ;
	L10.InsertionEnQueue (A20) ;

	Listes <AretesP>	L11 ;
	L11.InsertionEnQueue (A12) ;
	L11.InsertionEnQueue (A20) ;
	L11.InsertionEnQueue (A17) ;

	Listes <FacesP>	ListeFaces ;
	AttributsFaces	*PAF = new AttributsFaces (PMateriauRouge) ;
	FacesP F1 (ContoursP (L1),PAF) ;
	ListeFaces.InsertionEnQueue (F1) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L2),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L3),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L4),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L5),PAF)) ;
	ContoursP C (L6) ;
	FacesP	F (C,PAF) ;
	F.AjouterContourInterieur (ContoursP (L7)) ;
	ListeFaces.InsertionEnQueue (F) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L8),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L9),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L10),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L11),PAF)) ;

	return SolidesP (ListeFaces) ;
}