[FFmpeg-devel] [PATCH v6 3/3] aadec: improve seeking in mp3 content

Karsten Otto ottoka at posteo.de
Sat Jul 14 11:36:37 EEST 2018


> Am 14.07.2018 um 02:20 schrieb Michael Niedermayer <michael at niedermayer.cc>:
> 
> Signierter PGP-Teil
> On Fri, Jul 13, 2018 at 12:35:07PM +0200, Karsten Otto wrote:
>> MP3 frames may not be aligned to aa chunk boundaries. When seeking,
>> calculate the expected frame offset in the target chunk. Adjust the
>> timestamp and truncate the next packet accordingly.
>> 
>> This solution works for the majority of tested audio material. For
>> some rare encodings with mp3 padding or embedded id3 tags, it will
>> mispredict the correct offset, and at worst skip an extra frame.
>> ---
> 
>> This revision includes some comments documenting how/why it works.
> 
> this is not what i meant.
> 
> The input can be arbitrary, and generally would be manually created to
> exploit the code.
> iam not at all against documenting what it "// normally," does
> but the question is what makes a check unneeded
> 
> I was more thinking of a single comment in place of the missing check
> explaining why it is _guranteed_ to be unneeded.
> 
> It could also be done in form of a documented av_assert0();
> 
> Also if you need a lot of text to explain this, theres a problem.
> People who work on this in the future must understand what condition
> they need to maintain to make this stay true.
> 
Right, so you were concerned about maintainability:

With a thorough understanding of the code, I know I only need to handle
the last block correctly, then I won't need an extra check at packet creation.

But if I move the check down there, packet creation is obviously safe to
anybody, even without the context. And in case someone (intentionally)
messed up the file. Or needs to refactor the code in a hurry.

I will change the patch accordingly.

Cheers, Karsten



More information about the ffmpeg-devel mailing list