fixes ticket #1937
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -37,6 +37,7 @@ typedef struct CDXLDemuxContext { |
37 | 37 |
uint8_t header[CDXL_HEADER_SIZE]; |
38 | 38 |
int video_stream_index; |
39 | 39 |
int audio_stream_index; |
40 |
+ int64_t filesize; |
|
40 | 41 |
} CDXLDemuxContext; |
41 | 42 |
|
42 | 43 |
static int cdxl_read_probe(AVProbeData *p) |
... | ... |
@@ -96,6 +97,8 @@ static int cdxl_read_header(AVFormatContext *s) |
96 | 96 |
cdxl->video_stream_index = -1; |
97 | 97 |
cdxl->audio_stream_index = -1; |
98 | 98 |
|
99 |
+ cdxl->filesize = avio_size(s->pb); |
|
100 |
+ |
|
99 | 101 |
s->ctx_flags |= AVFMTCTX_NOHEADER; |
100 | 102 |
|
101 | 103 |
return 0; |
... | ... |
@@ -108,7 +111,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) |
108 | 108 |
uint32_t current_size, video_size, image_size; |
109 | 109 |
uint16_t audio_size, palette_size, width, height; |
110 | 110 |
int64_t pos; |
111 |
- int ret; |
|
111 |
+ int frames, ret; |
|
112 | 112 |
|
113 | 113 |
if (avio_feof(pb)) |
114 | 114 |
return AVERROR_EOF; |
... | ... |
@@ -175,6 +178,15 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) |
175 | 175 |
st->codec->codec_id = AV_CODEC_ID_CDXL; |
176 | 176 |
st->codec->width = width; |
177 | 177 |
st->codec->height = height; |
178 |
+ |
|
179 |
+ if (audio_size + video_size && cdxl->filesize > 0) { |
|
180 |
+ frames = cdxl->filesize / (audio_size + video_size); |
|
181 |
+ |
|
182 |
+ if(cdxl->framerate) |
|
183 |
+ st->duration = frames; |
|
184 |
+ else |
|
185 |
+ st->duration = frames * audio_size; |
|
186 |
+ } |
|
178 | 187 |
st->start_time = 0; |
179 | 188 |
cdxl->video_stream_index = st->index; |
180 | 189 |
if (cdxl->framerate) |