API changes, most recent first:
+2012-xx-xx - xxxxxxx - lavc 54.x.x
+ Add duration field to AVCodecParserContext
+
2012-02-xx - xxxxxxx - lavu 51.23.1 - mathematics.h
Add av_rescale_q_rnd()
* Previous frame byte position.
*/
int64_t last_pos;
+
+ /**
+ * Duration of the current frame.
+ * For audio, this is in units of 1 / AVCodecContext.sample_rate.
+ * For all other types, this is in units of AVCodecContext.time_base.
+ */
+ int duration;
} AVCodecParserContext;
typedef struct AVCodecParser {
if (pkt->size) {
got_packet:
pkt->duration = 0;
+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codec->sample_rate > 0) {
+ pkt->duration = av_rescale_q_rnd(st->parser->duration,
+ (AVRational){ 1, st->codec->sample_rate },
+ st->time_base,
+ AV_ROUND_DOWN);
+ }
+ } else if (st->codec->time_base.num != 0 &&
+ st->codec->time_base.den != 0) {
+ pkt->duration = av_rescale_q_rnd(st->parser->duration,
+ st->codec->time_base,
+ st->time_base,
+ AV_ROUND_DOWN);
+ }
pkt->stream_index = st->index;
pkt->pts = st->parser->pts;
pkt->dts = st->parser->dts;