[FFmpeg-devel] [PATCH] avcodec/utils: Add case for mp3 to av_get_audio_frame_duration()

Michael Niedermayer michael at niedermayer.cc
Fri Jan 1 23:47:08 CET 2016


On Fri, Jan 01, 2016 at 07:33:58PM +0100, Hendrik Leppkes wrote:
> On Fri, Jan 1, 2016 at 7:29 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> > Hi,
> >
> > On Fri, Jan 1, 2016 at 11:43 AM, Michael Niedermayer <michaelni at gmx.at>
> > wrote:
> >
> >> From: Michael Niedermayer <michael at niedermayer.cc>
> >>
> >> This is not guranteed to be correct but only the encoder or the packet
> >> headers
> >> can really provide the correct value. And before the first packet there is
> >> no alternative to receiving the value from the encoder by some means
> >>
> >> other codecs like AAC are still missing and are left for voluteers
> >>
> >> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> >> ---
> >>  libavcodec/utils.c |    6 ++++++
> >>  1 file changed, 6 insertions(+)
> >>
> >> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> >> index 4b4aea0..6ed47ef 100644
> >> --- a/libavcodec/utils.c
> >> +++ b/libavcodec/utils.c
> >> @@ -3042,6 +3042,12 @@ int av_get_audio_frame_duration(AVCodecContext
> >> *avctx, int frame_bytes)
> >>          if (id == AV_CODEC_ID_TTA)
> >>              return 256 * sr / 245;
> >>
> >> +        // When frame_bytes is set then the headers can be parsed to find
> >> the
> >> +        // frame size
> >> +        if (id == AV_CODEC_ID_MP3 && !frame_bytes) {
> >> +            return sr <= 24000 ? 576 : 1152;
> >> +        }
> >> +
> >>          if (ch > 0) {
> >>              /* calc from sample rate and channels */
> >>              if (id == AV_CODEC_ID_BINKAUDIO_DCT)
> >> --
> >> 1.7.9.5
> >
> >
> > Please, no more codec-specific hacks in generic code.
> >
> 
> This whole function is codec specific crazy.

yes, i surely would not mind if someone would split&move this function
into codecs or parsers or a callback in codec descriptors

AVCodecs is semantically wrong though as this is not specific to a
codec implementation

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160101/fbf06b0b/attachment.sig>


More information about the ffmpeg-devel mailing list