uint8_t header[CDXL_HEADER_SIZE];
int video_stream_index;
int audio_stream_index;
+ int64_t filesize;
} CDXLDemuxContext;
static int cdxl_read_probe(AVProbeData *p)
cdxl->video_stream_index = -1;
cdxl->audio_stream_index = -1;
+ cdxl->filesize = avio_size(s->pb);
+
s->ctx_flags |= AVFMTCTX_NOHEADER;
return 0;
uint32_t current_size, video_size, image_size;
uint16_t audio_size, palette_size, width, height;
int64_t pos;
- int ret;
+ int frames, ret;
if (avio_feof(pb))
return AVERROR_EOF;
height = AV_RB16(&cdxl->header[16]);
palette_size = AV_RB16(&cdxl->header[20]);
audio_size = AV_RB16(&cdxl->header[22]);
+ if (FFALIGN(width, 16) * (uint64_t)height * cdxl->header[19] > INT_MAX)
+ return AVERROR_INVALIDDATA;
image_size = FFALIGN(width, 16) * height * cdxl->header[19] / 8;
video_size = palette_size + image_size;
st->codec->codec_id = AV_CODEC_ID_CDXL;
st->codec->width = width;
st->codec->height = height;
+
+ if (audio_size + video_size && cdxl->filesize > 0) {
+ frames = cdxl->filesize / (audio_size + video_size);
+
+ if(cdxl->framerate)
+ st->duration = frames;
+ else
+ st->duration = frames * (int64_t)audio_size;
+ }
st->start_time = 0;
cdxl->video_stream_index = st->index;
if (cdxl->framerate)