Ignore:
Timestamp:
10/31/08 00:20:05 (15 years ago)
Author:
r2d
Message:

added chapter gain / peak to libmpcdec and mpcchap as in the spec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/libmpcdec/mpc_demux.c

    r407 r411  
    331331                d->chap_nb++;
    332332                chap_size += size;
    333                 size = mpc_bits_get_size(&d->bits_reader, &chap_sample);
     333                size = mpc_bits_get_size(&d->bits_reader, &chap_sample) + 4;
    334334                chap_size += size;
    335335                tag_size += b.size - size;
     
    340340        if (d->chap_nb > 0) {
    341341                char * ptag;
    342                 d->chap = malloc(sizeof(mpc_chap_t) * d->chap_nb + tag_size);
     342                d->chap = malloc(sizeof(mpc_chap_info) * d->chap_nb + tag_size);
    343343                ptag = (char*)(d->chap + d->chap_nb);
    344344
     
    347347                while (memcmp(b.key, "CT", 2) == 0) {
    348348                        mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0);
    349                         size = mpc_bits_get_size(&d->bits_reader, &d->chap[i].sample);
     349                        size = mpc_bits_get_size(&d->bits_reader, &d->chap[i].sample) + 4;
     350                        d->chap[i].gain = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16);
     351                        d->chap[i].peak = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16);
    350352                        memcpy(ptag, d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3), b.size - size);
    351353                        d->bits_reader.buff += b.size - size;
     
    375377/**
    376378 * Gets datas associated to a given chapter
    377  * You can pass 0 for tag and tag_size if you don't needs the tag information
    378379 * The chapter tag is an APEv2 tag without the preamble
    379380 * @param d pointer to a musepack demuxer
    380381 * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1)
    381  * @param tag will return a pointer to the chapter tag datas
    382  * @param tag_size will be filed with the tag data size (0 if no tag for this chapter)
    383  * @return the sample where the chapter starts
     382 * @return the chapter information structure
    384383 */
    385 mpc_uint64_t mpc_demux_chap(mpc_demux * d, int chap_nb, char ** tag, mpc_uint_t * tag_size)
     384mpc_chap_info * mpc_demux_chap(mpc_demux * d, int chap_nb)
    386385{
    387386        if (d->chap_nb == -1)
     
    389388        if (chap_nb >= d->chap_nb || chap_nb < 0)
    390389                return 0;
    391         if (tag != 0 && tag_size != 0) {
    392                 *tag = d->chap[chap_nb].tag;
    393                 *tag_size = d->chap[chap_nb].tag_size;
    394         }
    395         return d->chap[chap_nb].sample;
     390        return &d->chap[chap_nb];
    396391}
    397392
Note: See TracChangeset for help on using the changeset viewer.