void p_xvid_debug_write_mp4u_file(guchar *buff, gint32 len) { #define LONG_PACK(a,b,c,d) ((long) (((long)(a))<<24) | (((long)(b))<<16) | \ (((long)(c))<<8) |((long)(d))) #define SWAP(a) ( (((a)&0x000000ff)<<24) | (((a)&0x0000ff00)<<8) | \ (((a)&0x00ff0000)>>8) | (((a)&0xff000000)>>24) ) FILE *fp; gchar *fname; struct stat l_stat_buf; int bigendian; long totalsize; fname = "/home/hof/tmpvid/out.mp4u"; totalsize = LONG_PACK('M','P','4','U'); if(*((char *)(&totalsize)) == 'M') { bigendian = 1; } else { bigendian = 0; } /* get legth of file */ if (0 != g_stat(fname, &l_stat_buf)) { long hdr; hdr = LONG_PACK('M','P','4','U'); /* (file does not exist) create it */ fp = g_fopen(fname, "wb"); hdr = (!bigendian)?SWAP(hdr):hdr; fwrite(&hdr, sizeof(hdr), 1, fp); } else { /* (file exists) open append */ fp = g_fopen(fname, "ab"); } if(fp) { long size; size = len; size = (!bigendian)?SWAP(size):size; fwrite(&size, sizeof(size), 1, fp); fwrite(buff, len, 1, fp); fclose (fp); } } /* end p_xvid_debug_write_mp4u_file */
bool Utility::IsBigEndian() { long test = LONG_PACK('M','P','4','U'); char* pTest = (char*)&test; if(*pTest == 'M') return true; else return false; }