本文整理汇总了C++中GUINT16_FROM_LE函数的典型用法代码示例。如果您正苦于以下问题:C++ GUINT16_FROM_LE函数的具体用法?C++ GUINT16_FROM_LE怎么用?C++ GUINT16_FROM_LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GUINT16_FROM_LE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: commview_read_header
static gboolean
commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err,
gchar **err_info)
{
wtap_file_read_expected_bytes(&cv_hdr->data_len, 2, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->source_data_len, 2, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->version, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->year, 2, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->month, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->day, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->hours, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->minutes, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->seconds, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->usecs, 4, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->flags, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->signal_level_percent, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->rate, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->band, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->channel, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->direction, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->signal_level_dbm, 1, fh, err, err_info);
wtap_file_read_expected_bytes(&cv_hdr->noise_level, 1, fh, err, err_info);
/* Convert multi-byte values from little endian to host endian format */
cv_hdr->data_len = GUINT16_FROM_LE(cv_hdr->data_len);
cv_hdr->source_data_len = GUINT16_FROM_LE(cv_hdr->source_data_len);
cv_hdr->year = GUINT16_FROM_LE(cv_hdr->year);
cv_hdr->usecs = GUINT32_FROM_LE(cv_hdr->usecs);
return TRUE;
}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:31,代码来源:commview.c
示例2: fwupd_guid_to_string
/**
* fwupd_guid_to_string:
* @guid: a #fwupd_guid_t to read
* @flags: some %FwupdGuidFlags, e.g. %FWUPD_GUID_FLAG_MIXED_ENDIAN
*
* Returns a text GUID of mixed or BE endian for a packed buffer.
*
* Returns: A new GUID
*
* Since: 1.2.5
**/
gchar *
fwupd_guid_to_string (const fwupd_guid_t *guid, FwupdGuidFlags flags)
{
fwupd_guid_native_t gnat;
g_return_val_if_fail (guid != NULL, NULL);
/* copy to avoid issues with aligning */
memcpy (&gnat, guid, sizeof(gnat));
/* mixed is bizaar, but specified as the DCE encoding */
if (flags & FWUPD_GUID_FLAG_MIXED_ENDIAN) {
return g_strdup_printf ("%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
GUINT32_FROM_LE(gnat.a),
GUINT16_FROM_LE(gnat.b),
GUINT16_FROM_LE(gnat.c),
GUINT16_FROM_BE(gnat.d),
gnat.e[0], gnat.e[1],
gnat.e[2], gnat.e[3],
gnat.e[4], gnat.e[5]);
}
return g_strdup_printf ("%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
GUINT32_FROM_BE(gnat.a),
GUINT16_FROM_BE(gnat.b),
GUINT16_FROM_BE(gnat.c),
GUINT16_FROM_BE(gnat.d),
gnat.e[0], gnat.e[1],
gnat.e[2], gnat.e[3],
gnat.e[4], gnat.e[5]);
}
开发者ID:vathpela,项目名称:fwupd,代码行数:41,代码来源:fwupd-common.c
示例3: ico_write_int16
static gint
ico_write_int16 (FILE *fp,
guint16 *data,
gint count)
{
gint total;
total = count;
if (count > 0)
{
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
gint i;
for (i = 0; i < count; i++)
data[i] = GUINT16_FROM_LE (data[i]);
#endif
ico_write_int8 (fp, (guint8 *) data, count * 2);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
/* Put it back like we found it */
for (i = 0; i < count; i++)
data[i] = GUINT16_FROM_LE (data[i]);
#endif
}
return total * 2;
}
开发者ID:Distrotech,项目名称:gimp,代码行数:28,代码来源:ico-save.c
示例4: wav_open
static gint wav_open(void)
{
memcpy(&header.main_chunk, "RIFF", 4);
header.length = GUINT32_TO_LE(0);
memcpy(&header.chunk_type, "WAVE", 4);
memcpy(&header.sub_chunk, "fmt ", 4);
header.sc_len = GUINT32_TO_LE(16);
header.format = GUINT16_TO_LE(1);
header.modus = GUINT16_TO_LE(input.channels);
header.sample_fq = GUINT32_TO_LE(input.frequency);
if (input.format == FMT_U8 || input.format == FMT_S8)
header.bit_p_spl = GUINT16_TO_LE(8);
else
header.bit_p_spl = GUINT16_TO_LE(16);
header.byte_p_sec = GUINT32_TO_LE(input.frequency * header.modus * (GUINT16_FROM_LE(header.bit_p_spl) / 8));
header.byte_p_spl = GUINT16_TO_LE((GUINT16_FROM_LE(header.bit_p_spl) / (8 / input.channels)));
memcpy(&header.data_chunk, "data", 4);
header.data_length = GUINT32_TO_LE(0);
if (vfs_fwrite (& header, 1, sizeof header, output_file) != sizeof header)
return 0;
written = 0;
return 1;
}
开发者ID:Falcon-peregrinus,项目名称:mlplayer,代码行数:26,代码来源:wav.c
示例5: gfire_read_attrib
int gfire_read_attrib(GList **values, guint8 *buffer, int packet_len, const char *name,
gboolean dynamic, gboolean binary, int bytes_to_first, int bytes_between, int vallen)
{
int index = 0; int i=0; int ali = 0; int alen = 0;
gchar tmp[100];
guint16 numitems = 0; guint16 attr_len = 0;
guint8 *str;
memset(tmp, 0x00, 100);
alen = strlen(name);
memcpy(tmp, buffer + index, alen);
index += strlen(name);
if ( 0 == g_ascii_strcasecmp(name, tmp)) {
index += 2;
memcpy(&numitems, buffer + index, 2);
numitems = GUINT16_FROM_LE(numitems);
index += 2;
purple_debug(PURPLE_DEBUG_MISC, "gfire", "Looking for %d %s's in packet.\n", numitems, NN(name));
} else {
purple_debug(PURPLE_DEBUG_MISC, "gfire", "ERROR: %s signature isn't in the correct position.\n", NN(name));
return -1;
}
/* if we are copying a string make sure we have a space for the trailing \0 */
if (binary) ali = 0;
else ali = 1;
for (i = 0; i < numitems; i++) {
if (dynamic) {
memcpy(&attr_len, buffer + index, 2);
attr_len = GUINT16_FROM_LE(attr_len); index+=2;
} else attr_len = vallen;
if (dynamic && (attr_len == 0)) str = NULL;
else {
str = g_malloc0(sizeof(char) * (attr_len+ali));
memcpy(str, buffer + index, attr_len);
if (!binary) str[attr_len] = 0x00;
}
index += attr_len;
*values = g_list_append(*values,(gpointer *)str);
if ( index > packet_len ) {
purple_debug(PURPLE_DEBUG_MISC, "gfire", "ERROR: pkt 131: more friends then packet length.\n");
return -1;
}
}
return index;
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:49,代码来源:gf_packet.c
示例6: hcidump_process_packet
static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
{
struct dump_hdr dh;
int packet_size;
if (!wtap_read_bytes_or_eof(fh, &dh, DUMP_HDR_SIZE, err, err_info))
return FALSE;
packet_size = GUINT16_FROM_LE(dh.len);
if (packet_size > WTAP_MAX_PACKET_SIZE) {
/*
* Probably a corrupt capture file; don't blow up trying
* to allocate space for an immensely-large packet.
*/
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
packet_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
phdr->rec_type = REC_TYPE_PACKET;
phdr->presence_flags = WTAP_HAS_TS;
phdr->ts.secs = GUINT32_FROM_LE(dh.ts_sec);
phdr->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000;
phdr->caplen = packet_size;
phdr->len = packet_size;
phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
开发者ID:ARK1988,项目名称:wireshark,代码行数:32,代码来源:hcidump.c
示例7: deserialize_buffer
static gboolean
deserialize_buffer (SBlbDeserializer *deserializer, FlowPacketQueue *packet_queue, FlowPad *output_pad)
{
SBlbDeserializerPrivate *priv = deserializer->priv;
union
{
guint16 u16;
guchar c [2];
}
u;
guchar *buf;
if (priv->buffer_size < 0)
{
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, u.c, 2))
return TRUE;
u.u16 = GUINT16_FROM_LE (u.u16);
priv->buffer_size = u.u16;
}
buf = alloca (priv->buffer_size);
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, buf, priv->buffer_size))
return TRUE;
flow_pad_push (output_pad, flow_packet_new (FLOW_PACKET_FORMAT_BUFFER, buf, priv->buffer_size));
return FALSE;
}
开发者ID:hpjansson,项目名称:stasis-blb,代码行数:29,代码来源:sblb-deserializer.c
示例8: deserialize_begin
static gboolean
deserialize_begin (SBlbDeserializer *deserializer, FlowPacketQueue *packet_queue, FlowPad *output_pad)
{
SBlbDeserializerPrivate *priv = deserializer->priv;
union
{
guint16 id;
guchar c [2];
}
u;
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, u.c, 2))
return FALSE;
u.id = GUINT16_FROM_LE (u.id);
if (u.id == 65535)
{
priv->current_type = BUFFER_TYPE;
priv->buffer_size = -1;
}
else
{
priv->current_type = sblb_type_id_to_gtype (u.id);
if (priv->current_type == G_TYPE_INVALID)
{
g_warning ("Error deserializing: Invalid message type %d.", u.id);
return TRUE;
}
priv->current_context = flow_serializable_deserialize_begin (priv->current_type);
}
return TRUE;
}
开发者ID:hpjansson,项目名称:stasis-blb,代码行数:34,代码来源:sblb-deserializer.c
示例9: msn_read16le
guint16
msn_read16le(const char *buf)
{
guint16 val;
memcpy(&val, buf, sizeof(val));
return GUINT16_FROM_LE(val);
}
开发者ID:N8Fear,项目名称:purple-facebook,代码行数:7,代码来源:msnutils.c
示例10: microprof_read_data_field
static GwyDataField*
microprof_read_data_field(const MicroProfFile *mfile,
const guchar *buffer)
{
const guint16 *d16 = (const guint16*)buffer;
GwyDataField *dfield;
GwySIUnit *siunit;
gdouble *d;
guint xres, yres, i, j;
xres = mfile->xres;
yres = mfile->yres;
dfield = gwy_data_field_new(xres, yres,
mfile->xrange, mfile->yrange, FALSE);
d = gwy_data_field_get_data(dfield);
for (i = 0; i < yres; i++) {
for (j = 0; j < xres; j++) {
d[(yres-1 - i)*xres + j] = mfile->zscale*GUINT16_FROM_LE(*d16);
d16++;
}
}
siunit = gwy_data_field_get_si_unit_xy(dfield);
gwy_si_unit_set_from_string(siunit, "m");
siunit = gwy_data_field_get_si_unit_z(dfield);
gwy_si_unit_set_from_string(siunit, "m");
return dfield;
}
开发者ID:cbuehler,项目名称:gwyddion,代码行数:31,代码来源:microprof.c
示例11: convert_stereo_to_mono_u16le
static int convert_stereo_to_mono_u16le(struct xmms_convert_buffers* buf, void **data, int length)
{
guint16 *output = *data, *input = *data;
int i;
for (i = 0; i < length / 4; i++)
{
guint32 tmp;
guint16 stmp;
tmp = GUINT16_FROM_LE(*input);
input++;
tmp += GUINT16_FROM_LE(*input);
input++;
stmp = tmp / 2;
*output++ = GUINT16_TO_LE(stmp);
}
return length / 2;
}
开发者ID:sedwards,项目名称:xmms3,代码行数:17,代码来源:xconvert.c
示例12: vfs_fget_le16
/**
* Reads an unsigned 16-bit Little Endian value from the stream
* into native endian format.
*
* @param value Pointer to the variable to read the value into.
* @param stream A #VFSFile object representing the stream.
* @return TRUE if read was succesful, FALSE if there was an error.
*/
EXPORT bool_t vfs_fget_le16(uint16_t *value, VFSFile *stream)
{
uint16_t tmp;
if (vfs_fread(&tmp, sizeof(tmp), 1, stream) != 1)
return FALSE;
*value = GUINT16_FROM_LE(tmp);
return TRUE;
}
开发者ID:umurkontaci,项目名称:audacious,代码行数:16,代码来源:vfs_common.c
示例13: __attribute__
/**
* unzip_file:
* @zip_file: pointer to start of compressed data
* @unzip_size: the size of the compressed data block
*
* Returns a pointer to uncompressed data (maybe NULL)
*/
void *unzip_file(gchar *zip_file, gulong *unzip_size)
{
void *unzip_data = NULL;
#ifndef HAVE_LIBZ
goto end;
#else
gchar *zip_data;
struct _lfh {
guint32 sig;
guint16 extract_version;
guint16 flags;
guint16 comp_method;
guint16 time;
guint16 date;
guint32 crc_32;
guint32 compressed_size;
guint32 uncompressed_size;
guint16 filename_len;
guint16 extra_field_len;
} __attribute__ ((__packed__)) *local_file_header = NULL;
local_file_header = (struct _lfh *) zip_file;
if (GUINT32_FROM_LE(local_file_header->sig) != 0x04034b50) {
g_warning("%s(): wrong format", __PRETTY_FUNCTION__);
g_free(unzip_data);
goto end;
}
zip_data = zip_file + sizeof(struct _lfh)
+ GUINT16_FROM_LE(local_file_header->filename_len)
+ GUINT16_FROM_LE(local_file_header->extra_field_len);
gulong uncompressed_size = GUINT32_FROM_LE(local_file_header->uncompressed_size);
unzip_data = g_malloc(uncompressed_size);
if (!(*unzip_size = uncompress_data(unzip_data, uncompressed_size, zip_data, GUINT32_FROM_LE(local_file_header->compressed_size)))) {
g_free(unzip_data);
unzip_data = NULL;
goto end;
}
#endif
end:
return(unzip_data);
}
开发者ID:gdt,项目名称:viking,代码行数:52,代码来源:compression.c
示例14: koneplus_rmp_macro_key_info_new
KoneplusRmpMacroKeyInfo *koneplus_rmp_macro_key_info_v1_to_koneplus_rmp_macro_key_info(KoneplusRmpMacroKeyInfoV1 const *v1) {
KoneplusRmpMacroKeyInfo *result;
result = koneplus_rmp_macro_key_info_new();
result->button_number = v1->button_number;
result->type = v1->type;
koneplus_rmp_macro_key_info_set_talk_device(result, GUINT16_FROM_LE(v1->talk_device));
koneplus_rmp_macro_key_info_set_macroset_name(result, (gchar const *)v1->macroset_name);
koneplus_rmp_macro_key_info_set_macro_name(result, (gchar const *)v1->macro_name);
koneplus_rmp_macro_key_info_set_loop(result, GUINT32_FROM_LE(v1->loop));
koneplus_rmp_macro_key_info_set_count(result, GUINT16_FROM_LE(v1->count));
memcpy(&result->keystrokes[0], &v1->keystrokes[0], sizeof(result->keystrokes));
koneplus_rmp_macro_key_info_set_timer_length(result, GUINT32_FROM_LE(v1->timer_length));
koneplus_rmp_macro_key_info_set_timer_name(result, (gchar const *)v1->timer_name);
koneplus_rmp_macro_key_info_set_filename(result, (gchar const *)v1->filename);
return result;
}
开发者ID:ngg,项目名称:roccat-tools,代码行数:18,代码来源:koneplus_rmp_macro_key_info.c
示例15: GetWORD
static WORD
GetWORD (int position, BYTE *data)
{
WORD *value = (WORD*)(data + position);
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
return GUINT16_FROM_LE (*value);
#else
return *value;
#endif
}
开发者ID:mono,项目名称:libgdiplus,代码行数:10,代码来源:wmfcodec.c
示例16: print_obj
static void print_obj(struct db_obj_ent *obj)
{
uint32_t n_str = GUINT32_FROM_LE(obj->n_str);
int i;
void *p;
uint16_t *slenp;
char *dbstr;
if (GUINT32_FROM_LE(obj->flags) & DB_OBJ_INLINE) {
printf("%s\t%s\t%s\t[%u]\t%u\n",
obj->bucket,
obj->owner,
obj->md5,
(unsigned) GUINT64_FROM_LE(obj->size),
n_str);
} else {
printf("%s\t%s\t%s\t%llX",
obj->bucket,
obj->owner,
obj->md5,
(long long) GUINT64_FROM_LE(obj->d.a.oid));
for (i = 0; i < MAXWAY; i++) {
if (i == 0) {
printf("\t");
} else {
printf(",");
}
printf("%d", GUINT32_FROM_LE(obj->d.a.nidv[i]));
}
printf(" %u\n", n_str);
}
p = obj;
p += sizeof(*obj);
slenp = p;
p += n_str * sizeof(uint16_t);
for (i = 0; i < n_str; i++) {
char pfx[16];
dbstr = p;
p += GUINT16_FROM_LE(*slenp);
slenp++;
if (i == 0)
strcpy(pfx, "key: ");
else
sprintf(pfx, "str%d: ", i);
printf("%s%s\n", pfx, dbstr);
}
printf("====\n");
}
开发者ID:jgarzik,项目名称:tabled,代码行数:55,代码来源:tdbadm.c
示例17: purple_pn_xfer_got_invite
void
purple_pn_xfer_got_invite(struct pn_peer_call *call,
const char *branch,
const char *context)
{
PurpleAccount *account;
PurpleXfer *xfer;
char *bin;
gsize bin_len;
guint32 file_size;
char *file_name;
gunichar2 *uni_name;
account = msn_session_get_user_data (pn_peer_link_get_session (call->link));
call->cb = xfer_completed_cb;
call->end_cb = xfer_end_cb;
call->progress_cb = xfer_progress_cb;
call->branch = g_strdup(branch);
call->pending = TRUE;
xfer = purple_xfer_new(account, PURPLE_XFER_RECEIVE,
pn_peer_link_get_passport (call->link));
if (xfer)
{
bin = (char *)purple_base64_decode(context, &bin_len);
file_size = GUINT32_FROM_LE(*(gsize *)(bin + 8));
uni_name = (gunichar2 *)(bin + 20);
while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) {
*uni_name = GUINT16_FROM_LE(*uni_name);
uni_name++;
}
file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1,
NULL, NULL, NULL);
g_free(bin);
purple_xfer_set_filename(xfer, file_name);
purple_xfer_set_size(xfer, file_size);
purple_xfer_set_init_fnc(xfer, xfer_init);
purple_xfer_set_request_denied_fnc(xfer, xfer_cancel);
purple_xfer_set_cancel_recv_fnc(xfer, xfer_cancel);
call->xfer = xfer;
purple_xfer_ref(call->xfer);
xfer->data = call;
purple_xfer_request(xfer);
}
}
开发者ID:allanfreitas,项目名称:msn-pecan,代码行数:54,代码来源:xfer.c
示例18: fu_smbios_parse_ep32
static gboolean
fu_smbios_parse_ep32 (FuSmbios *self, const gchar *buf, gsize sz, GError **error)
{
FuSmbiosStructureEntryPoint32 *ep;
guint8 csum = 0;
/* verify size */
if (sz != sizeof(FuSmbiosStructureEntryPoint32)) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"invalid smbios entry point got %" G_GSIZE_FORMAT
" bytes, expected %" G_GSIZE_FORMAT,
sz, sizeof(FuSmbiosStructureEntryPoint32));
return FALSE;
}
/* verify checksum */
for (guint i = 0; i < sz; i++)
csum += buf[i];
if (csum != 0x00) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"entry point checksum invalid");
return FALSE;
}
/* verify intermediate section */
ep = (FuSmbiosStructureEntryPoint32 *) buf;
if (memcmp (ep->intermediate_anchor_str, "_DMI_", 5) != 0) {
g_autofree gchar *tmp = g_strndup (ep->intermediate_anchor_str, 5);
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"intermediate anchor signature invalid, got %s", tmp);
return FALSE;
}
for (guint i = 10; i < sz; i++)
csum += buf[i];
if (csum != 0x00) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"intermediate checksum invalid");
return FALSE;
}
self->structure_table_len = GUINT16_FROM_LE (ep->structure_table_len);
self->smbios_ver = g_strdup_printf ("%u.%u",
ep->smbios_major_ver,
ep->smbios_minor_ver);
return TRUE;
}
开发者ID:vathpela,项目名称:fwupd,代码行数:53,代码来源:fu-smbios.c
示例19: convert_buffer
static void convert_buffer(gpointer buffer, gint length)
{
gint i;
if (afmt == FMT_S8)
{
guint8 *ptr1 = buffer;
gint8 *ptr2 = buffer;
for (i = 0; i < length; i++)
*(ptr1++) = *(ptr2++) ^ 128;
}
if (afmt == FMT_S16_BE)
{
gint16 *ptr = buffer;
for (i = 0; i < length >> 1; i++, ptr++)
*ptr = GUINT16_SWAP_LE_BE(*ptr);
}
if (afmt == FMT_S16_NE)
{
gint16 *ptr = buffer;
for (i = 0; i < length >> 1; i++, ptr++)
*ptr = GINT16_TO_LE(*ptr);
}
if (afmt == FMT_U16_BE)
{
gint16 *ptr1 = buffer;
guint16 *ptr2 = buffer;
for (i = 0; i < length >> 1; i++, ptr2++)
*(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768);
}
if (afmt == FMT_U16_LE)
{
gint16 *ptr1 = buffer;
guint16 *ptr2 = buffer;
for (i = 0; i < length >> 1; i++, ptr2++)
*(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768);
}
if (afmt == FMT_U16_NE)
{
gint16 *ptr1 = buffer;
guint16 *ptr2 = buffer;
for (i = 0; i < length >> 1; i++, ptr2++)
*(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768);
}
}
开发者ID:brunoellll,项目名称:player-git-svn,代码行数:51,代码来源:playerxmms.c
示例20: init
static int init(struct sr_input *in, const char *filename)
{
struct sr_probe *probe;
struct context *ctx;
char buf[40], probename[8];
int i;
if (get_wav_header(filename, buf) != SR_OK)
return SR_ERR;
if (!(ctx = g_try_malloc0(sizeof(struct context))))
return SR_ERR_MALLOC;
/* Create a virtual device. */
in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
in->sdi->priv = ctx;
ctx->samplerate = GUINT32_FROM_LE(*(uint32_t *)(buf + 24));
ctx->samplesize = GUINT16_FROM_LE(*(uint16_t *)(buf + 34)) / 8;
if (ctx->samplesize != 1 && ctx->samplesize != 2 && ctx->samplesize != 4) {
sr_err("only 8, 16 or 32 bits per sample supported.");
return SR_ERR;
}
if ((ctx->num_channels = GUINT16_FROM_LE(*(uint16_t *)(buf + 22))) > 20) {
sr_err("%d channels seems crazy.", ctx->num_channels);
return SR_ERR;
}
for (i = 0; i < ctx->num_channels; i++) {
snprintf(probename, 8, "CH%d", i + 1);
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, probename)))
return SR_ERR;
in->sdi->probes = g_slist_append(in->sdi->probes, probe);
}
return SR_OK;
}
开发者ID:adlerweb,项目名称:libsigrok,代码行数:38,代码来源:wav.c
注:本文中的GUINT16_FROM_LE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论