Commit d92550d1 authored by Anton Khirnov's avatar Anton Khirnov Committed by Michael Niedermayer

lavf: eliminate ff_get_audio_frame_size()

It is basically a wrapper around av_get_audio_frame_duration(), with a
fallback to AVCodecContext.frame_size. However, that field is set only
when the stream codec context is actually used for encoding or decoding,
which is discouraged.

For muxing, it is generally the responsibility of the caller to set the
packet duration.
For demuxing, if the duration is not stored at the container level, it
should be set by the parser.

Therefore, removing the frame_size fallback should not break any
important case.
(cherry picked from commit 30e50c50)

Conflicts:

	libavformat/utils.c
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 7b59217b
...@@ -337,8 +337,6 @@ void ff_free_stream(AVFormatContext *s, AVStream *st); ...@@ -337,8 +337,6 @@ void ff_free_stream(AVFormatContext *s, AVStream *st);
void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st, void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt); AVCodecParserContext *pc, AVPacket *pkt);
int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux);
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id); unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag); enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag);
......
...@@ -521,7 +521,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt) ...@@ -521,7 +521,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ? frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ?
((AVFrame *)pkt->data)->nb_samples : ((AVFrame *)pkt->data)->nb_samples :
ff_get_audio_frame_size(st->codec, pkt->size, 1); av_get_audio_frame_duration(st->codec, pkt->size);
/* HACK/FIXME, we skip the initial 0 size packets as they are most /* HACK/FIXME, we skip the initial 0 size packets as they are most
* likely equal to the encoder delay, but it would be better if we * likely equal to the encoder delay, but it would be better if we
......
...@@ -712,21 +712,6 @@ static int determinable_frame_size(AVCodecContext *avctx) ...@@ -712,21 +712,6 @@ static int determinable_frame_size(AVCodecContext *avctx)
return 0; return 0;
} }
/**
* Get the number of samples of an audio frame. Return -1 on error.
*/
int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux)
{
int frame_size;
if ((frame_size = av_get_audio_frame_duration(enc, size)) > 0)
return frame_size;
return -1;
}
/** /**
* Return the frame duration in seconds. Return 0 if not available. * Return the frame duration in seconds. Return 0 if not available.
*/ */
...@@ -762,7 +747,7 @@ void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st, ...@@ -762,7 +747,7 @@ void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
} }
break; break;
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 0); frame_size = av_get_audio_frame_duration(st->codec, pkt->size);
if (frame_size <= 0 || st->codec->sample_rate <= 0) if (frame_size <= 0 || st->codec->sample_rate <= 0)
break; break;
*pnum = frame_size; *pnum = frame_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment