ReactOS  0.4.15-dev-985-gd905dd5
swap_bytes_impl.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SWAP(a, b)   tmp = p[a]; p[a] = p[b]; p[b] = tmp;
 

Functions

static void swap_bytes (void *buf, size_t samplesize, size_t samplecount)
 

Macro Definition Documentation

◆ SWAP

#define SWAP (   a,
  b 
)    tmp = p[a]; p[a] = p[b]; p[b] = tmp;

Definition at line 25 of file swap_bytes_impl.h.

Function Documentation

◆ swap_bytes()

static void swap_bytes ( void buf,
size_t  samplesize,
size_t  samplecount 
)
static

Definition at line 28 of file swap_bytes_impl.h.

29 {
30  unsigned char *p = buf;
31  unsigned char *pend = (unsigned char*)buf+samplesize*samplecount;
32  unsigned char tmp;
33 
34  if(samplesize < 2)
35  return;
36  switch(samplesize)
37  {
38  case 2: /* AB -> BA */
39 #ifdef HAVE_BYTESWAP_H
40  {
41  uint16_t* pp = (uint16_t*)p;
42  for(; pp<(uint16_t*)pend; ++pp)
43  *pp = bswap_16(*pp);
44  }
45 #else
46  for(; p<pend; p+=2)
47  {
48  SWAP(0,1)
49  }
50 #endif
51  break;
52  case 3: /* ABC -> CBA */
53  for(; p<pend; p+=3)
54  {
55  SWAP(0,2)
56  }
57  break;
58  case 4: /* ABCD -> DCBA */
59 #ifdef HAVE_BYTESWAP_H
60  {
61  uint32_t* pp = (uint32_t*)p;
62  for(; pp<(uint32_t*)pend; ++pp)
63  *pp = bswap_32(*pp);
64  }
65 #else
66  for(; p<pend; p+=4)
67  {
68  SWAP(0,3)
69  SWAP(1,2)
70  }
71 #endif
72  break;
73  case 8: /* ABCDEFGH -> HGFEDCBA */
74 #ifdef HAVE_BYTESWAP_H
75  {
76  uint64_t* pp = (uint64_t*)p;
77  for(; pp<(uint64_t*)pend; ++pp)
78  *pp = bswap_64(*pp);
79  }
80 #else
81  for(; p<pend; p+=8)
82  {
83  SWAP(0,7)
84  SWAP(1,6)
85  SWAP(2,5)
86  SWAP(3,4)
87  }
88 #endif
89  break;
90  /* All the weird choices with the full nested loop. */
91  default:
92  for(; p<pend; p+=samplesize)
93  {
94  size_t j;
95  for(j=0; j<samplesize/2; ++j)
96  {
97  SWAP(j, samplesize-j-1)
98  }
99  }
100  }
101 }
static UInt64_t bswap_64(x) UInt64_t x
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned short int uint16_t
Definition: acefiex.h:54
#define pp
Definition: hlsl.yy.c:1208
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
UINT64 uint64_t
Definition: types.h:77
#define bswap_16(x)
Definition: byteswap.h:31
UINT32 uint32_t
Definition: types.h:75
#define bswap_32(x)
Definition: byteswap.h:34
#define SWAP(a, b)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by swap_endian().