summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-02 18:44:22 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-02 18:57:29 +0200
commitfd68371b072824ee6f63e38e1b2f6921a05bedcc (patch)
treed9bda44cd1f8c8c450549632fb8370776032e361
parent60ab4480423769ac3db487aba5232b187036c7ea (diff)
nutdec: Implement duration parsing for indexed nuts
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/nutdec.c8
-rw-r--r--tests/ref/fate/ffprobe_compact8
-rw-r--r--tests/ref/fate/ffprobe_csv8
-rw-r--r--tests/ref/fate/ffprobe_default16
-rw-r--r--tests/ref/fate/ffprobe_flat16
-rw-r--r--tests/ref/fate/ffprobe_ini16
-rw-r--r--tests/ref/fate/ffprobe_json10
-rw-r--r--tests/ref/fate/ffprobe_xml8
8 files changed, 45 insertions, 45 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 8896518142..ea0fc1d53a 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -601,6 +601,7 @@ static int find_and_decode_index(NUTContext *nut)
int i, j, syncpoint_count;
int64_t filesize = avio_size(bc);
int64_t *syncpoints;
+ uint64_t max_pts;
int8_t *has_keyframe;
int ret = -1;
@@ -620,7 +621,12 @@ static int find_and_decode_index(NUTContext *nut)
end = get_packetheader(nut, bc, 1, INDEX_STARTCODE);
end += avio_tell(bc);
- ffio_read_varlen(bc); // max_pts
+ max_pts = ffio_read_varlen(bc);
+ s->duration = av_rescale_q(max_pts / nut->time_base_count,
+ nut->time_base[max_pts % nut->time_base_count],
+ AV_TIME_BASE_Q);
+ s->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
+
GET_V(syncpoint_count, tmp < INT_MAX / 8 && tmp > 0);
syncpoints = av_malloc(sizeof(int64_t) * syncpoint_count);
has_keyframe = av_malloc(sizeof(int8_t) * (syncpoint_count + 1));
diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact
index 470a3f7cea..409ac9c5e9 100644
--- a/tests/ref/fate/ffprobe_compact
+++ b/tests/ref/fate/ffprobe_compact
@@ -26,7 +26,7 @@ packet|codec_type=video|stream_index=1|pts=6144|pts_time=0.120000|dts=6144|dts_t
frame|media_type=video|key_frame=1|pkt_pts=6144|pkt_pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=794307|pkt_size=N/A|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0
packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=1024731|flags=K
frame|media_type=video|key_frame=1|pkt_pts=6144|pkt_pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=1024731|pkt_size=N/A|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0
-stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=527406|duration=11.959320|bit_rate=705600|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:E=mc²
-stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=612317|duration=11.959316|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt
-stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=612317|duration=11.959316|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0
-format|filename=tests/data/ffprobe-test.nut|nb_streams=3|format_name=nut|start_time=0.000000|duration=11.959320|size=1054812|bit_rate=705599|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': <tag value="x">|tag:comment2=I ♥ Üñîçød€
+stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:E=mc²
+stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt
+stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0
+format|filename=tests/data/ffprobe-test.nut|nb_streams=3|format_name=nut|start_time=0.000000|duration=0.120000|size=1054812|bit_rate=70320800|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': <tag value="x">|tag:comment2=I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_csv b/tests/ref/fate/ffprobe_csv
index 95b93b5872..0094c39c65 100644
--- a/tests/ref/fate/ffprobe_csv
+++ b/tests/ref/fate/ffprobe_csv
@@ -26,7 +26,7 @@ packet,video,1,6144,0.120000,6144,0.120000,2048,0.040000,N/A,N/A,230400,794307,K
frame,video,1,6144,0.120000,6144,0.120000,2048,0.040000,794307,N/A,320,240,rgb24,1:1,I,0,0,0,0,0
packet,video,2,6144,0.120000,6144,0.120000,2048,0.040000,N/A,N/A,30000,1024731,K
frame,video,1,6144,0.120000,6144,0.120000,2048,0.040000,1024731,N/A,100,100,rgb24,1:1,I,0,0,0,0,0
-stream,0,pcm_s16le,unknown,audio,1/44100,PSD[16],0x10445350,s16,44100,1,16,N/A,0/0,0/0,1/44100,0,0.000000,527406,11.959320,705600,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,mc²
-stream,1,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,320,240,0,1:1,4:3,rgb24,-99,N/A,N/A,25/1,25/1,1/51200,0,0.000000,612317,11.959316,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt
-stream,2,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,100,100,0,1:1,1:1,rgb24,-99,N/A,N/A,25/1,25/1,1/51200,0,0.000000,612317,11.959316,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0
-format,tests/data/ffprobe-test.nut,3,nut,0.000000,11.959320,1054812,705599,ffprobe test file,"'A comment with CSV, XML & JSON special chars': <tag value=""x"">",I ♥ Üñîçød€
+stream,0,pcm_s16le,unknown,audio,1/44100,PSD[16],0x10445350,s16,44100,1,16,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,mc²
+stream,1,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,320,240,0,1:1,4:3,rgb24,-99,N/A,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt
+stream,2,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,100,100,0,1:1,1:1,rgb24,-99,N/A,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0
+format,tests/data/ffprobe-test.nut,3,nut,0.000000,0.120000,1054812,70320800,ffprobe test file,"'A comment with CSV, XML & JSON special chars': <tag value=""x"">",I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_default b/tests/ref/fate/ffprobe_default
index 6f6341da3b..9f523fdba1 100644
--- a/tests/ref/fate/ffprobe_default
+++ b/tests/ref/fate/ffprobe_default
@@ -498,8 +498,8 @@ avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
-duration_ts=527406
-duration=11.959320
+duration_ts=N/A
+duration=N/A
bit_rate=705600
nb_frames=N/A
nb_read_frames=6
@@ -539,8 +539,8 @@ avg_frame_rate=25/1
time_base=1/51200
start_pts=0
start_time=0.000000
-duration_ts=612317
-duration=11.959316
+duration_ts=N/A
+duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=4
@@ -581,8 +581,8 @@ avg_frame_rate=25/1
time_base=1/51200
start_pts=0
start_time=0.000000
-duration_ts=612317
-duration=11.959316
+duration_ts=N/A
+duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=4
@@ -604,9 +604,9 @@ filename=tests/data/ffprobe-test.nut
nb_streams=3
format_name=nut
start_time=0.000000
-duration=11.959320
+duration=0.120000
size=1054812
-bit_rate=705599
+bit_rate=70320800
TAG:title=ffprobe test file
TAG:comment='A comment with CSV, XML & JSON special chars': <tag value="x">
TAG:comment2=I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_flat b/tests/ref/fate/ffprobe_flat
index 324b94f875..c08ca0fa94 100644
--- a/tests/ref/fate/ffprobe_flat
+++ b/tests/ref/fate/ffprobe_flat
@@ -441,8 +441,8 @@ streams.stream.0.avg_frame_rate="0/0"
streams.stream.0.time_base="1/44100"
streams.stream.0.start_pts=0
streams.stream.0.start_time="0.000000"
-streams.stream.0.duration_ts=527406
-streams.stream.0.duration="11.959320"
+streams.stream.0.duration_ts="N/A"
+streams.stream.0.duration="N/A"
streams.stream.0.bit_rate="705600"
streams.stream.0.nb_frames="N/A"
streams.stream.0.nb_read_frames="6"
@@ -480,8 +480,8 @@ streams.stream.1.avg_frame_rate="25/1"
streams.stream.1.time_base="1/51200"
streams.stream.1.start_pts=0
streams.stream.1.start_time="0.000000"
-streams.stream.1.duration_ts=612317
-streams.stream.1.duration="11.959316"
+streams.stream.1.duration_ts="N/A"
+streams.stream.1.duration="N/A"
streams.stream.1.bit_rate="N/A"
streams.stream.1.nb_frames="N/A"
streams.stream.1.nb_read_frames="4"
@@ -520,8 +520,8 @@ streams.stream.2.avg_frame_rate="25/1"
streams.stream.2.time_base="1/51200"
streams.stream.2.start_pts=0
streams.stream.2.start_time="0.000000"
-streams.stream.2.duration_ts=612317
-streams.stream.2.duration="11.959316"
+streams.stream.2.duration_ts="N/A"
+streams.stream.2.duration="N/A"
streams.stream.2.bit_rate="N/A"
streams.stream.2.nb_frames="N/A"
streams.stream.2.nb_read_frames="4"
@@ -541,9 +541,9 @@ format.filename="tests/data/ffprobe-test.nut"
format.nb_streams=3
format.format_name="nut"
format.start_time="0.000000"
-format.duration="11.959320"
+format.duration="0.120000"
format.size="1054812"
-format.bit_rate="705599"
+format.bit_rate="70320800"
format.tags.title="ffprobe test file"
format.tags.comment="'A comment with CSV, XML & JSON special chars': <tag value=\"x\">"
format.tags.comment2="I ♥ Üñîçød€"
diff --git a/tests/ref/fate/ffprobe_ini b/tests/ref/fate/ffprobe_ini
index 63a03f67b9..1bc46d0d91 100644
--- a/tests/ref/fate/ffprobe_ini
+++ b/tests/ref/fate/ffprobe_ini
@@ -500,8 +500,8 @@ avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
-duration_ts=527406
-duration=11.959320
+duration_ts=N/A
+duration=N/A
bit_rate=705600
nb_frames=N/A
nb_read_frames=6
@@ -545,8 +545,8 @@ avg_frame_rate=25/1
time_base=1/51200
start_pts=0
start_time=0.000000
-duration_ts=612317
-duration=11.959316
+duration_ts=N/A
+duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=4
@@ -591,8 +591,8 @@ avg_frame_rate=25/1
time_base=1/51200
start_pts=0
start_time=0.000000
-duration_ts=612317
-duration=11.959316
+duration_ts=N/A
+duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=4
@@ -616,9 +616,9 @@ filename=tests/data/ffprobe-test.nut
nb_streams=3
format_name=nut
start_time=0.000000
-duration=11.959320
+duration=0.120000
size=1054812
-bit_rate=705599
+bit_rate=70320800
[format.tags]
title=ffprobe test file
diff --git a/tests/ref/fate/ffprobe_json b/tests/ref/fate/ffprobe_json
index 51404cb932..fc3d22e89c 100644
--- a/tests/ref/fate/ffprobe_json
+++ b/tests/ref/fate/ffprobe_json
@@ -486,8 +486,6 @@
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
- "duration_ts": 527406,
- "duration": "11.959320",
"bit_rate": "705600",
"nb_read_frames": "6",
"nb_read_packets": "6",
@@ -527,8 +525,6 @@
"time_base": "1/51200",
"start_pts": 0,
"start_time": "0.000000",
- "duration_ts": 612317,
- "duration": "11.959316",
"nb_read_frames": "4",
"nb_read_packets": "4",
"disposition": {
@@ -568,8 +564,6 @@
"time_base": "1/51200",
"start_pts": 0,
"start_time": "0.000000",
- "duration_ts": 612317,
- "duration": "11.959316",
"nb_read_frames": "4",
"nb_read_packets": "4",
"disposition": {
@@ -592,9 +586,9 @@
"nb_streams": 3,
"format_name": "nut",
"start_time": "0.000000",
- "duration": "11.959320",
+ "duration": "0.120000",
"size": "1054812",
- "bit_rate": "705599",
+ "bit_rate": "70320800",
"tags": {
"title": "ffprobe test file",
"comment": "'A comment with CSV, XML & JSON special chars': <tag value=\"x\">",
diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml
index 0600ad7f0d..1f2715a8e4 100644
--- a/tests/ref/fate/ffprobe_xml
+++ b/tests/ref/fate/ffprobe_xml
@@ -32,21 +32,21 @@
</packets_and_frames>
<streams>
- <stream index="0" codec_name="pcm_s16le" codec_type="audio" codec_time_base="1/44100" codec_tag_string="PSD[16]" codec_tag="0x10445350" sample_fmt="s16" sample_rate="44100" channels="1" bits_per_sample="16" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/44100" start_pts="0" start_time="0.000000" duration_ts="527406" duration="11.959320" bit_rate="705600" nb_read_frames="6" nb_read_packets="6">
+ <stream index="0" codec_name="pcm_s16le" codec_type="audio" codec_time_base="1/44100" codec_tag_string="PSD[16]" codec_tag="0x10445350" sample_fmt="s16" sample_rate="44100" channels="1" bits_per_sample="16" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/44100" start_pts="0" start_time="0.000000" bit_rate="705600" nb_read_frames="6" nb_read_packets="6">
<disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
<tag key="E" value="mc²"/>
</stream>
- <stream index="1" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" duration_ts="612317" duration="11.959316" nb_read_frames="4" nb_read_packets="4">
+ <stream index="1" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
<disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
<tag key="title" value="foobar"/>
<tag key="duration_ts" value="field-and-tags-conflict-attempt"/>
</stream>
- <stream index="2" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" duration_ts="612317" duration="11.959316" nb_read_frames="4" nb_read_packets="4">
+ <stream index="2" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
<disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
</stream>
</streams>
- <format filename="tests/data/ffprobe-test.nut" nb_streams="3" format_name="nut" start_time="0.000000" duration="11.959320" size="1054812" bit_rate="705599">
+ <format filename="tests/data/ffprobe-test.nut" nb_streams="3" format_name="nut" start_time="0.000000" duration="0.120000" size="1054812" bit_rate="70320800">
<tag key="title" value="ffprobe test file"/>
<tag key="comment" value="&apos;A comment with CSV, XML &amp; JSON special chars&apos;: &lt;tag value=&quot;x&quot;&gt;"/>
<tag key="comment2" value="I ♥ Üñîçød€"/>