guint64 part_table_entry_get_size (PartitionTable *p, int entry) { guint64 val; PartitionEntry *pe = g_slist_nth_data (p->entries, entry); val = G_MAXUINT64; if (p == NULL) goto out; switch (p->scheme) { case PART_TYPE_GPT: val = 0x200 * (((guint64) get_le64 (pe->data + 40)) - ((guint64) get_le64 (pe->data + 32)) + 1); break; case PART_TYPE_MSDOS: case PART_TYPE_MSDOS_EXTENDED: val = 0x200 * ((guint64) get_le32 (pe->data + 12)); break; case PART_TYPE_APPLE: val = 0x200 * ((guint64) get_be32 (pe->data + 2*2 + 2*4)); break; default: break; } out: return val; }
static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { NUVContext *ctx = (NUVContext *)s->priv_data; ByteIOContext *pb = &s->pb; char id_string[12], version_string[5]; double aspect, fps; int is_mythtv, width, height, v_packs, a_packs; int stream_nr = 0; AVStream *vst = NULL, *ast = NULL; get_buffer(pb, id_string, 12); is_mythtv = !memcmp(id_string, "MythTVVideo", 12); get_buffer(pb, version_string, 5); url_fskip(pb, 3); // padding width = get_le32(pb); height = get_le32(pb); get_le32(pb); // unused, "desiredwidth" get_le32(pb); // unused, "desiredheight" get_byte(pb); // 'P' == progressive, 'I' == interlaced url_fskip(pb, 3); // padding aspect = av_int2dbl(get_le64(pb)); fps = av_int2dbl(get_le64(pb)); // number of packets per stream type, -1 means unknown, e.g. streaming v_packs = get_le32(pb); a_packs = get_le32(pb); get_le32(pb); // text get_le32(pb); // keyframe distance (?) if (v_packs) { ctx->v_id = stream_nr++; vst = av_new_stream(s, ctx->v_id); vst->codec->codec_type = CODEC_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_NUV; vst->codec->codec_tag = MKTAG('R', 'J', 'P', 'G'); vst->codec->width = width; vst->codec->height = height; vst->codec->bits_per_sample = 10; vst->codec->sample_aspect_ratio = av_d2q(aspect, 10000); vst->r_frame_rate = av_d2q(1.0 / fps, 10000); av_set_pts_info(vst, 32, 1, 1000); } else ctx->v_id = -1; if (a_packs) { ctx->a_id = stream_nr++; ast = av_new_stream(s, ctx->a_id); ast->codec->codec_type = CODEC_TYPE_AUDIO; ast->codec->codec_id = CODEC_ID_PCM_S16LE; ast->codec->channels = 2; ast->codec->sample_rate = 44100; ast->codec->bit_rate = 2 * 2 * 44100 * 8; ast->codec->block_align = 2 * 2; ast->codec->bits_per_sample = 16; av_set_pts_info(ast, 32, 1, 1000); } else ctx->a_id = -1; get_codec_data(pb, vst, ast, is_mythtv); return 0; }
/* wav input */ static int wav_read_header(AVFormatContext *s, AVFormatParameters *ap) { int64_t size, av_uninit(data_size); int rf64; unsigned int tag; ByteIOContext *pb = s->pb; AVStream *st; WAVContext *wav = s->priv_data; /* check RIFF header */ tag = get_le32(pb); rf64 = tag == MKTAG('R', 'F', '6', '4'); if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F')) return -1; get_le32(pb); /* file size */ tag = get_le32(pb); if (tag != MKTAG('W', 'A', 'V', 'E')) return -1; if (rf64) { if (get_le32(pb) != MKTAG('d', 's', '6', '4')) return -1; size = get_le32(pb); if (size < 16) return -1; get_le64(pb); /* RIFF size */ data_size = get_le64(pb); url_fskip(pb, size - 16); /* skip rest of ds64 chunk */ } /* parse fmt header */ size = find_tag(pb, MKTAG('f', 'm', 't', ' ')); if (size < 0) return -1; st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); ff_get_wav_header(pb, st->codec, size); st->need_parsing = AVSTREAM_PARSE_FULL; av_set_pts_info(st, 64, 1, st->codec->sample_rate); size = find_tag(pb, MKTAG('d', 'a', 't', 'a')); if (rf64) size = data_size; if (size < 0) return -1; if (!size) { wav->data_end = INT64_MAX; } else wav->data_end= url_ftell(pb) + size; return 0; }
static av_always_inline int read_index(Index *read_idx, ByteIOContext *seek_pb) { read_idx->pts = get_le64(seek_pb); read_idx->dts = get_le64(seek_pb); read_idx->pes_offset = get_le64(seek_pb); read_idx->pic_type = get_byte(seek_pb); read_idx->timecode.frames = get_byte(seek_pb); read_idx->timecode.seconds = get_byte(seek_pb); read_idx->timecode.minutes = get_byte(seek_pb); read_idx->timecode.hours = get_byte(seek_pb); return 0; }
static int read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; AVRational time_base; get_le32(s->pb); // DKIF get_le16(s->pb); // version get_le16(s->pb); // header size st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_tag = get_le32(s->pb); st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag); st->codec->width = get_le16(s->pb); st->codec->height = get_le16(s->pb); time_base.den = get_le32(s->pb); time_base.num = get_le32(s->pb); st->duration = get_le64(s->pb); st->need_parsing = AVSTREAM_PARSE_HEADERS; if (!time_base.den || !time_base.num) { av_log(s, AV_LOG_ERROR, "Invalid frame rate\n"); return AVERROR_INVALIDDATA; } av_set_pts_info(st, 64, time_base.num, time_base.den); return 0; }
guint64 part_table_entry_get_offset (PartitionTable *p, int entry) { guint64 val; PartitionEntry *pe = g_slist_nth_data (p->entries, entry); val = G_MAXUINT64; if (p == NULL) goto out; switch (p->scheme) { case PART_TYPE_GPT: val = 0x200 * ((guint64) get_le64 (pe->data + 32)); break; case PART_TYPE_MSDOS: val = 0x200 * ((guint64) get_le32 (pe->data + 8)); break; case PART_TYPE_MSDOS_EXTENDED: /* tricky here.. the offset in the EMBR is from the start of the EMBR and they are * scattered around the ext partition... Hence, just use the entry's offset and subtract * it's offset from the EMBR.. */ val = 0x200 * ((guint64) get_le32 (pe->data + 8)) + pe->offset - MSDOS_PARTTABLE_OFFSET; break; case PART_TYPE_APPLE: val = 0x200 * ((guint64) get_be32 (pe->data + 2*2 + 1*4)); break; default: break; } out: return val; }
static int read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size = get_le32(s->pb); int64_t pts = get_le64(s->pb); ret = av_get_packet(s->pb, pkt, size); pkt->stream_index = 0; pkt->pts = pts; pkt->pos -= 12; return ret; }
int sj_index_load(char *filename, SJ_IndexContext *sj_ic) { ByteIOContext pb; register_protocol(&file_protocol); if (url_fopen(&pb, filename, URL_RDONLY) < 0) { // file could not be open return -1; } sj_ic->size = url_fsize(&pb) - HEADER_SIZE; sj_ic->index_num = (sj_ic->size / INDEX_SIZE); sj_ic->indexes = av_malloc(sj_ic->index_num * sizeof(Index)); int64_t magic = get_le64(&pb); if (magic != 0x534A2D494E444558LL) { // not an index file url_fclose(&pb); return -2; } sj_ic->version = get_byte(&pb); sj_ic->start_pts = get_le64(&pb); sj_ic->start_dts = get_le64(&pb); sj_ic->start_timecode.frames = get_byte(&pb); sj_ic->start_timecode.seconds = get_byte(&pb); sj_ic->start_timecode.minutes = get_byte(&pb); sj_ic->start_timecode.hours = get_byte(&pb); if (!sj_ic->index_num) { // empty index url_fclose(&pb); return -4; } for(int i = 0; i < sj_ic->index_num; i++) { read_index(&sj_ic->indexes[i], &pb); } url_fclose(&pb); return 0; }
static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap) { int64_t size; ByteIOContext *pb = s->pb; WAVContext *wav = s->priv_data; AVStream *st; uint8_t guid[16]; get_buffer(pb, guid, 16); if (memcmp(guid, guid_riff, 16)) return -1; if (get_le64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */ return -1; get_buffer(pb, guid, 16); if (memcmp(guid, guid_wave, 16)) { av_log(s, AV_LOG_ERROR, "could not find wave guid\n"); return -1; } size = find_guid(pb, guid_fmt); if (size < 0) { av_log(s, AV_LOG_ERROR, "could not find fmt guid\n"); return -1; } st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); /* subtract chunk header size - normal wav file doesn't count it */ ff_get_wav_header(pb, st->codec, size - 24); url_fskip(pb, FFALIGN(size, INT64_C(8)) - size); st->need_parsing = AVSTREAM_PARSE_FULL; av_set_pts_info(st, 64, 1, st->codec->sample_rate); size = find_guid(pb, guid_data); if (size < 0) { av_log(s, AV_LOG_ERROR, "could not find data guid\n"); return -1; } wav->data_end = url_ftell(pb) + size - 24; wav->w64 = 1; return 0; }
/** Find chunk with w64 GUID by skipping over other chunks * @return the size of the found chunk */ static int64_t find_guid(ByteIOContext *pb, const uint8_t guid1[16]) { uint8_t guid[16]; int64_t size; while (!url_feof(pb)) { get_buffer(pb, guid, 16); size = get_le64(pb); if (size <= 24) return -1; if (!memcmp(guid, guid1, 16)) return size; url_fskip(pb, FFALIGN(size, INT64_C(8)) - 24); } return -1; }
static int ble_hs_hci_evt_le_lt_key_req(uint8_t subevent, uint8_t *data, int len) { struct hci_le_lt_key_req evt; if (len < BLE_HCI_LE_LT_KEY_REQ_LEN) { return BLE_HS_ECONTROLLER; } evt.subevent_code = data[0]; evt.connection_handle = get_le16(data + 1); evt.random_number = get_le64(data + 3); evt.encrypted_diversifier = get_le16(data + 11); ble_sm_ltk_req_rx(&evt); return 0; }
blargg_err_t Zip_Extractor::open_v() { if ( arc().size() < end_entry_size ) return blargg_err_file_type; isZIP64 = false; if (arc().size() > 0xffffffff) isZIP64 = true; // Read final end_read_size bytes of file //BOOST::uint64_t file_pos = max( (BOOST::uint64_t) 0, arc().size() - end_read_size ); BOOST::int64_t file_pos = max( (BOOST::int64_t) 0, (BOOST::int64_t) arc().size() - end_read_size ); file_pos -= file_pos % disk_block_size; RETURN_ERR( catalog.resize( (size_t)(arc().size() - file_pos) ) ); RETURN_ERR( arc().seek( file_pos ) ); RETURN_ERR( arc().read( catalog.begin(), catalog.size() ) ); BOOST::int64_t end_pos = 0; if (!isZIP64) { // Find end-of-catalog entry end_pos = catalog.size() - end_entry_size; while (end_pos >= 0 && memcmp(&catalog[(size_t)end_pos], "PK\5\6", 4)) end_pos--; if (end_pos < 0) return blargg_err_file_type; end_entry_t const& end_entry = (end_entry_t&)catalog[(size_t)end_pos]; catalog_begin = get_le32(end_entry.dir_offset); } if (isZIP64) { // Find end64-of-catalog entry end_pos = catalog.size() - end64_entry_size; while (end_pos >= 0 && memcmp(&catalog[(size_t)end_pos], "PK\6\6", 4)) end_pos--; if (end_pos < 0) return blargg_err_file_type; end64_entry_t const& end_entry = (end64_entry_t&)catalog[(size_t)end_pos]; catalog_begin = get_le64(end_entry.dir_offset); } end_pos += file_pos; // some idiotic zip compressors add data to end of zip without setting comment len // check( arc().size() == end_pos + end_entry_size + get_le16( end_entry.comment_len ) ); BOOST::int64_t catalog_size = end_pos - catalog_begin; if ( catalog_size < 0 ) return blargg_err_file_corrupt; if (isZIP64) catalog_size += end64_entry_size; else catalog_size += end_entry_size; // See if catalog is entirely contained in bytes already read BOOST::int64_t begin_offset = catalog_begin - file_pos; if ( begin_offset >= 0 ) memmove( catalog.begin(), &catalog [(size_t)begin_offset], (size_t)catalog_size ); RETURN_ERR( catalog.resize( (size_t)catalog_size ) ); if ( begin_offset < 0 ) { // Catalog begins before bytes read, so it needs to be read RETURN_ERR( arc().seek( catalog_begin ) ); RETURN_ERR( arc().read( catalog.begin(), catalog.size() ) ); } // First entry in catalog should be a file or end of archive if ( memcmp( catalog.begin(), "PK\1\2", 4 ) && memcmp( catalog.begin(), "PK\5\6", 4 ) ) return blargg_err_file_type; reorder_entry_header( 0 ); return rewind_v(); }
int __acc_cdecl_qsort le64_compare(const void *e1, const void *e2) { const upx_uint64_t d1 = get_le64(e1); const upx_uint64_t d2 = get_le64(e2); return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0); }
static int sox_read_header(AVFormatContext *s, AVFormatParameters *ap) { ByteIOContext *pb = s->pb; unsigned header_size, comment_size; double sample_rate, sample_rate_frac; AVStream *st; st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = CODEC_TYPE_AUDIO; if (get_le32(pb) == SOX_TAG) { st->codec->codec_id = CODEC_ID_PCM_S32LE; header_size = get_le32(pb); url_fskip(pb, 8); /* sample count */ sample_rate = av_int2dbl(get_le64(pb)); st->codec->channels = get_le32(pb); comment_size = get_le32(pb); } else { st->codec->codec_id = CODEC_ID_PCM_S32BE; header_size = get_be32(pb); url_fskip(pb, 8); /* sample count */ sample_rate = av_int2dbl(get_be64(pb)); st->codec->channels = get_be32(pb); comment_size = get_be32(pb); } if (comment_size > 0xFFFFFFFFU - SOX_FIXED_HDR - 4U) { av_log(s, AV_LOG_ERROR, "invalid comment size (%u)\n", comment_size); return -1; } if (sample_rate <= 0 || sample_rate > INT_MAX) { av_log(s, AV_LOG_ERROR, "invalid sample rate (%f)\n", sample_rate); return -1; } sample_rate_frac = sample_rate - floor(sample_rate); if (sample_rate_frac) av_log(s, AV_LOG_WARNING, "truncating fractional part of sample rate (%f)\n", sample_rate_frac); if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size || st->codec->channels > 65535) /* Reserve top 16 bits */ { av_log(s, AV_LOG_ERROR, "invalid header\n"); return -1; } if (comment_size && comment_size + FF_INPUT_BUFFER_PADDING_SIZE >= comment_size) { char *comment = av_mallocz(comment_size + FF_INPUT_BUFFER_PADDING_SIZE); if (get_buffer(pb, comment, comment_size) != comment_size) { av_freep(&comment); return AVERROR_IO; } av_metadata_set(&s->metadata, "comment", comment); av_freep(&comment); } url_fskip(pb, header_size - SOX_FIXED_HDR - comment_size); st->codec->sample_rate = sample_rate; st->codec->bits_per_coded_sample = 32; st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels; st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; }
static PartitionTable * part_table_parse_gpt (int fd, guint64 offset, guint64 size) { int n; PartitionTable *p; guint8 buf[16]; guint64 partition_entry_lba; int num_entries; int size_of_entry; HAL_INFO (("Entering EFI GPT parser")); /* by way of getting here, we've already checked for a protective MBR */ p = NULL; /* Check GPT signature */ if (lseek (fd, offset + 512 + 0, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, buf, 8) != 8) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } if (memcmp (buf, GPT_MAGIC, 8) != 0) { HAL_INFO (("No GPT_MAGIC found")); goto out; } HAL_INFO (("GPT magic found")); /* Disk UUID */ if (lseek (fd, offset + 512 + 56, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, buf, 16) != 16) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } //hexdump ((guint8*) buf, 16); if (lseek (fd, offset + 512 + 72, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, buf, 8) != 8) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } partition_entry_lba = get_le64 (buf); if (lseek (fd, offset + 512 + 80, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, buf, 4) != 4) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } num_entries = get_le32 (buf); if (lseek (fd, offset + 512 + 84, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, buf, 4) != 4) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } size_of_entry = get_le32(buf); p = part_table_new_empty (PART_TYPE_GPT); p->offset = offset; p->size = size; HAL_INFO (("partition_entry_lba=%d", partition_entry_lba)); HAL_INFO (("num_entries=%d", num_entries)); HAL_INFO (("size_of_entry=%d", size_of_entry)); for (n = 0; n < num_entries; n++) { PartitionEntry *pe; struct { guint8 partition_type_guid[16]; guint8 partition_guid[16]; guint8 starting_lba[8]; guint8 ending_lba[8]; guint8 attributes[8]; guint8 partition_name[72]; } gpt_part_entry; char *partition_type_guid; if (lseek (fd, offset + partition_entry_lba * 512 + n * size_of_entry, SEEK_SET) < 0) { HAL_INFO (("lseek failed (%s)", strerror (errno))); goto out; } if (read (fd, &gpt_part_entry, 128) != 128) { HAL_INFO (("read failed (%s)", strerror (errno))); goto out; } partition_type_guid = get_le_guid (gpt_part_entry.partition_type_guid); if (strcmp (partition_type_guid, GPT_PART_TYPE_GUID_EMPTY) == 0) continue; pe = part_entry_new (NULL, (guint8*) &gpt_part_entry, 128, offset + partition_entry_lba * 512 + n * size_of_entry); p->entries = g_slist_append (p->entries, pe); g_free (partition_type_guid); //hexdump ((guint8 *) &gpt_part_entry, 128); } out: HAL_INFO (("Leaving EFI GPT parser")); return p; }
int WMA_File::asfReadHeader() { int noEndlessLoop = 0; // ASFContext asf; TAGGER_GUID g; // int size, i; int64_t gsize; get_guid(this, &g); if (memcmp(&g, &asf_header, sizeof(TAGGER_GUID))) goto fail; get_le64(this); get_le32(this); get_byte(this); get_byte(this); // memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { noEndlessLoop++; if( noEndlessLoop > 256 ) { goto fail; } get_guid(this, &g); gsize = get_le64(this); // #ifdef DEBUG // printf("%08Lx: ", url_ftell(f) - 24); // print_guid(&g); // printf(" size=0x%Lx\n", gsize); // #endif if (gsize < 24) goto fail; if (!memcmp(&g, &file_header, sizeof(TAGGER_GUID))) { get_guid(this, &g); // asf.hdr.file_size = get_le64(this); // asf.hdr.create_time = get_le64(this); // asf.hdr.packets_count = get_le64(this); // asf.hdr.play_time int64_t play_time = get_le64(this); // play_time is in 100ns = 10^-7s units if (wmaProperties) wmaProperties->m_length = (play_time / 10000000L); // asf.hdr.send_time = get_le64(this); // asf.hdr.preroll = get_le32(this); // asf.hdr.ignore = get_le32(this); // asf.hdr.flags = get_le32(this); // asf.hdr.min_pktsize = get_le32(this); // asf.hdr.max_pktsize = get_le32(this); // asf.hdr.max_bitrate = get_le32(this); // asf.packet_size = asf.hdr.max_pktsize; // asf.nb_packets = asf.hdr.packets_count; } else if (!memcmp(&g, &stream_header, sizeof(TAGGER_GUID))) { //int type; int type_specific_size; //unsigned int tag1; int64_t pos1, pos2; pos1 = Tell(); get_guid(this, &g); if (!memcmp(&g, &audio_stream, sizeof(TAGGER_GUID))) { // type = CODEC_TYPE_AUDIO; } else { wxLogDebug(wxT("Tagger: WMA file contains non-audio streams.")); return false; } get_guid(this, &g); get_le64(this); // total size type_specific_size = get_le32(this); get_le32(this); get_le16(this) /*& 0x7f*/; /* stream id */ get_le32(this); // st->codec.codec_type = type; // /* 1 fps default (XXX: put 0 fps instead) */ // st->codec.frame_rate = 1000; // st->codec.frame_rate_base = 1; // if (type == CODEC_TYPE_AUDIO) { getWavHeader(type_specific_size); // st->need_parsing = 1; /* We have to init the frame size at some point .... */ pos2 = Tell(); if (gsize > (pos2 + 8 - pos1 + 24)) { /* asf_st.ds_span = */ get_byte(this); /* asf_st.ds_packet_size = */ get_le16(this); // asf_st.ds_chunk_size = get_le16(this); // asf_st.ds_data_size = get_le16(this); // asf_st.ds_silence_data = get_byte(this); } pos2 = Tell(); Seek(gsize - (pos2 - pos1 + 24), SJ_SEEK_CUR); } else if (!memcmp(&g, &data_header, sizeof(TAGGER_GUID))) { break; } else if (!memcmp(&g, &comment_header, sizeof(TAGGER_GUID))) { int len1, len2, len3, len4, len5; len1 = get_le16(this); len2 = get_le16(this); len3 = get_le16(this); len4 = get_le16(this); len5 = get_le16(this); if (wmaTag) { wxString s; //char buf[1]; get_str16_nolen(this, len1, s); wmaTag->setTitle(s); get_str16_nolen(this, len2, s); wmaTag->setLeadArtist(s); get_str16_nolen(this, len3, s); // Copyright notice get_str16_nolen(this, len4, s); wmaTag->setComment(s); Seek(len5, SJ_SEEK_CUR); } else { Seek(len1+len2+len3+len4+len5, SJ_SEEK_CUR); } } else if (!memcmp(&g, &extended_content_header, sizeof(TAGGER_GUID))) { int desc_count, i; desc_count = get_le16(this); for(i=0; i<desc_count; i++) { int name_len,value_type,value_len = 0; int64_t value_num = 0; wxString name, value; name_len = get_le16(this); get_str16_nolen(this, name_len, name); value_type = get_le16(this); value_len = get_le16(this); //debug (name); // printf ("value_type is %d; name_len is %d\n", value_type, name_len); if ((value_type == 0) || (value_type == 1)) // unicode or byte { get_str16_nolen(this, value_len, value); //debug ("string value:"); //debug(value); if ( wmaTag ) { if (name == wxT("WM/AlbumTitle")) { wmaTag->setAlbum(value); } if (name == wxT("WM/Genre")) { wmaTag->setGenre(value); } if (name == wxT("WM/Year")) { long l; if(!value.ToLong(&l)){l=0;} wmaTag->setYear(l); } if (name==wxT("WM/TrackNumber")) { long l; if(!value.ToLong(&l)){l=0;} wmaTag->setTrack(l, 0); } } } if ((value_type >= 2) && (value_type <= 5)) // boolean or DWORD or QWORD or WORD { if (value_type==2) value_num = get_le32(this); if (value_type==3) value_num = get_le32(this); if (value_type==4) value_num = get_le64(this); if (value_type==5) value_num = get_le16(this); //printf("numerical value: %d\n", value_num); if (wmaTag) { if (name==wxT("WM/Track")) { wmaTag->setTrack(value_num + 1, 0); } if (name==wxT("WM/TrackNumber")) { wmaTag->setTrack(value_num, 0); } } } } #if 0 } else if (!memcmp(&g, &head1_guid, sizeof(TAGGER_GUID))) { int v1, v2; get_guid(f, &g); v1 = get_le32(this); v2 = get_le16(this); } else if (!memcmp(&g, &codec_comment_header, sizeof(TAGGER_GUID))) { int len, v1, n, num; char str[256], *q; char tag[16]; get_guid(this, &g); print_guid(&g); n = get_le32(this); for(i=0; i<n; i++) { num = get_le16(this); /* stream number */ get_str16(this, str, sizeof(str)); get_str16(this, str, sizeof(str)); len = get_le16(this); q = tag; while (len > 0) { v1 = get_byte(this); if ((q - tag) < sizeof(tag) - 1) *q++ = v1; len--; } *q = '\0'; } #endif // FIXME: Can we eliminate all further reads? // FIXME: implement EOF check // } else if (url_feof(f)) { // goto fail; } else { Seek(gsize - 24, SJ_SEEK_CUR); } } get_guid(this, &g); get_le64(this); get_byte(this); get_byte(this); // FIXME: implement EOF check // if (url_feof(f)) // goto fail; // asf->data_offset = url_ftell(f); // asf->packet_size_left = 0; return true; fail: return false; // for(i=0;i<s->nb_streams;i++) { // AVStream *st = s->streams[i]; // if (st) { // av_free(st->priv_data); // av_free(st->codec.extradata); // } // av_free(st); // } // return -1; }