Re: how to interpret tell_off, and the right way to use sox_seek

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> static int seek(sox_format_t * ft, uint64_t offset)
> {
>   priv_t *   wav = (priv_t *) ft->priv;
> 
>   if (ft->encoding.bits_per_sample & 7)
>     lsx_fail_errno(ft, SOX_ENOTSUP, "seeking not supported with this encoding");
>   else if (wav->formatTag == WAVE_FORMAT_GSM610) {
>     int alignment;
>     size_t gsmoff;
> 
>     /* rounding bytes to blockAlign so that we
>      * don't have to decode partial block. */
>     gsmoff = offset * wav->blockAlign / wav->samplesPerBlock +
>              wav->blockAlign * ft->signal.channels / 2;
>     gsmoff -= gsmoff % (wav->blockAlign * ft->signal.channels);
> 
>     ft->sox_errno = lsx_seeki(ft, (off_t)(gsmoff + wav->dataStart), SEEK_SET);
>     if (ft->sox_errno == SOX_SUCCESS) {
>       /* offset is in samples */
>       uint64_t new_offset = offset;
>       alignment = offset % wav->samplesPerBlock;
>       if (alignment != 0)
>           new_offset += (wav->samplesPerBlock - alignment);
>       wav->numSamples = ft->signal.length - (new_offset / ft->signal.channels);
>     }
>   } else {
>     double wide_sample = offset - (offset % ft->signal.channels);
>     double to_d = wide_sample * ft->encoding.bits_per_sample / 8;
>     off_t to = to_d;
>     ft->sox_errno = (to != to_d)? SOX_EOF : lsx_seeki(ft, (off_t)wav->dataStart + (off_t)to, SEEK_SET);
>     if (ft->sox_errno == SOX_SUCCESS)
>       wav->numSamples -= (size_t)wide_sample / ft->signal.channels;
>   }
> 
>   return ft->sox_errno;
> }
> 
> 
> It seems you are right: wav->numSamples get decremented no matter what.

Hm, not true; but I don't understand the computation either.
Is the double there so that the integer count does not overflow?
And is that related to the problem you are seeing?

	Jan


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sox-users mailing list
Sox-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sox-users



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux