History

avcodec: add duration field to AVCodecParserContext

This will allow parsers to export the duration of the current frame being output, if known, instead of using AVCodecContext.frame_size.

Justin Ruggles committed 14 years ago

Commit e9cda851 parent 0b42a933 files · +24 −0Browse files

Unified · Split

3 files
  1. doc/APIchanges +3 −0
  2. libavcodec/avcodec.h +7 −0
  3. libavformat/utils.c +14 −0
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162012-xx-xx - xxxxxxx - lavc 54.x.x
17 Add duration field to AVCodecParserContext
18
162012-02-xx - xxxxxxx - lavu 51.23.1 - mathematics.h192012-02-xx - xxxxxxx - lavu 51.23.1 - mathematics.h
17 Add av_rescale_q_rnd()20 Add av_rescale_q_rnd()
18 21
libavcodec/avcodec.h+7−0
@@ -3994,6 +3994,13 @@ typedef struct AVCodecParserContext { · 3993 unmodified lines
3994 * Previous frame byte position.3994 * Previous frame byte position.
3995 */3995 */
3996 int64_t last_pos;3996 int64_t last_pos;
3997
3998 /**
3999 * Duration of the current frame.
4000 * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4001 * For all other types, this is in units of AVCodecContext.time_base.
4002 */
4003 int duration;
3997} AVCodecParserContext;4004} AVCodecParserContext;
3998 4005
3999typedef struct AVCodecParser {4006typedef struct AVCodecParser {
libavformat/utils.c+14−0
@@ -1039,6 +1039,20 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1038 unmodified lines
1039 if (pkt->size) {1039 if (pkt->size) {
1040 got_packet:1040 got_packet:
1041 pkt->duration = 0;1041 pkt->duration = 0;
1042 if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
1043 if (st->codec->sample_rate > 0) {
1044 pkt->duration = av_rescale_q_rnd(st->parser->duration,
1045 (AVRational){ 1, st->codec->sample_rate },
1046 st->time_base,
1047 AV_ROUND_DOWN);
1048 }
1049 } else if (st->codec->time_base.num != 0 &&
1050 st->codec->time_base.den != 0) {
1051 pkt->duration = av_rescale_q_rnd(st->parser->duration,
1052 st->codec->time_base,
1053 st->time_base,
1054 AV_ROUND_DOWN);
1055 }
1042 pkt->stream_index = st->index;1056 pkt->stream_index = st->index;
1043 pkt->pts = st->parser->pts;1057 pkt->pts = st->parser->pts;
1044 pkt->dts = st->parser->dts;1058 pkt->dts = st->parser->dts;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t