Exemplo n.º 1
0
static int
aac_seek_sample (DB_fileinfo_t *_info, int sample) {
    aac_info_t *info = (aac_info_t *)_info;

    sample += info->startsample;
    if (info->mp4file) {
        int scale = _info->fmt.samplerate / mp4ff_time_scale (info->mp4file, info->mp4track) * info->mp4framesize;
        info->mp4sample = sample / scale;
        info->skipsamples = sample - info->mp4sample * scale;
    }
    else {
        int skip = deadbeef->junk_get_leading_size (info->file);
        if (skip >= 0) {
            deadbeef->fseek (info->file, skip, SEEK_SET);
        }
        else {
            deadbeef->fseek (info->file, 0, SEEK_SET);
        }

        int res = seek_raw_aac (info, sample);
        if (res < 0) {
            return -1;
        }
        info->skipsamples = res;
    }
    info->remaining = 0;
    info->out_remaining = 0;
    info->currentsample = sample;
    _info->readpos = (float)(info->currentsample - info->startsample) / _info->fmt.samplerate;
    return 0;
}
Exemplo n.º 2
0
static int
aac_seek_sample (DB_fileinfo_t *_info, int sample) {
    aac_info_t *info = (aac_info_t *)_info;

    trace ("seek: start %d + %d\n", info->startsample, sample);

    sample += info->startsample;
    if (info->mp4) {
        int totalsamples = 0;
        int i;
        int num_sample_byte_sizes = mp4ff_get_num_sample_byte_sizes (info->mp4, info->mp4track);
        int scale = _info->fmt.samplerate / mp4ff_time_scale (info->mp4, info->mp4track);
        for (i = 0; i < num_sample_byte_sizes; i++)
        {
            unsigned int thissample_duration = 0;
            unsigned int thissample_bytesize = 0;

            mp4ff_get_sample_info(info->mp4, info->mp4track, i, &thissample_duration,
                    &thissample_bytesize);

            if (totalsamples + thissample_duration > sample / scale) {
                info->skipsamples = sample - totalsamples * scale;
                break;
            }
            totalsamples += thissample_duration;
        }
//        i = sample / info->mp4framesize;
//        info->skipsamples = sample - info->mp4sample * info->mp4framesize;
        info->mp4sample = i;
        trace ("seek res: frame %d (old: %d*%d), skip %d\n", info->mp4sample, sample / info->mp4framesize, info->mp4framesize, info->skipsamples);
    }
    else {
        int skip = deadbeef->junk_get_leading_size (info->file);
        if (skip >= 0) {
            deadbeef->fseek (info->file, skip, SEEK_SET);
        }
        else {
            deadbeef->fseek (info->file, 0, SEEK_SET);
        }

        int res = seek_raw_aac (info, sample);
        if (res < 0) {
            return -1;
        }
        info->skipsamples = res;
    }
    info->remaining = 0;
    info->out_remaining = 0;
    info->currentsample = sample;
    _info->readpos = (float)(info->currentsample - info->startsample) / _info->fmt.samplerate;
    return 0;
}