[Libav-user] Issue with decoding APE files

Nicolas George george at nsup.org
Fri Aug 7 17:15:35 CEST 2015


Le decadi 20 thermidor, an CCXXIII, Michał Kurowski a écrit :
> 	Thank you for the fast reply. Now I understand the issue and it
> makes sense (my APE files seem to have around 15 frames per packet).
> Unfortunately I ran into another problem - the return value of
> avcodec_decode_audio4() equals the packet size when I decode ALAC or FLAC,
> but when decoding APE, it is always 0, hence my first implementation of
> the fix resulted in an infinite loop.

Are you sure the problem is exactly that? I just checked what I remembered
about the APE decoder, using sample luckynight-mac394b1-c4000.ape from the
FATE suite, and it returns 0 fifteen times and then returns the size of the
packet.

(What actually happens is that the first call pre-decodes the full packet
into a "jumbo frame", and then does the second pass of decoding for the
beginning of that frame; next calls do the second pass on the rest of the
frame. Technically, the first call consumes the packet and the next calls
only take from the internal buffer, but to fit to the API it was necessary
to pretend that the first calls consume 0 octets and the last one consumes
the packet.)

If you loop until got_output is 0, then you called the decode function once
too many. I am surprised it works, I would have imagined that it would
decode every even packet twice and skip every odd packet. Have you tested
the actual decoded data?

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20150807/cdaed8b6/attachment.sig>


More information about the Libav-user mailing list