Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/anim_movie.c
| Show First 20 Lines • Show All 564 Lines • ▼ Show 20 Lines | # endif | ||||
| } | } | ||||
| if (pCodecCtx->pix_fmt == AV_PIX_FMT_NONE) { | if (pCodecCtx->pix_fmt == AV_PIX_FMT_NONE) { | ||||
| avcodec_close(anim->pCodecCtx); | avcodec_close(anim->pCodecCtx); | ||||
| avformat_close_input(&pFormatCtx); | avformat_close_input(&pFormatCtx); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| frame_rate = av_guess_frame_rate(pFormatCtx, video_stream, NULL); | frame_rate = av_guess_frame_rate(pFormatCtx, video_stream, NULL); | ||||
| anim->duration = 0; | |||||
| /* Take from the stream if we can. */ | |||||
| if (video_stream->nb_frames != 0) { | if (video_stream->nb_frames != 0) { | ||||
| anim->duration = video_stream->nb_frames; | anim->duration = video_stream->nb_frames; | ||||
| /* Sanity check on the detected duration. This is to work around corruption like reported in | |||||
| * T68091. */ | |||||
| if (frame_rate.den != 0 && pFormatCtx->duration > 0) { | |||||
| double stream_sec = anim->duration * av_q2d(frame_rate); | |||||
jbakker: Possible integer overflow error?
`anim->duration * av_q2d(framerate)` | |||||
| double container_sec = pFormatCtx->duration / (double)AV_TIME_BASE; | |||||
| if (stream_sec > 4.0 * container_sec) { | |||||
Done Inline Actions4.0 as both are already doubles. jbakker: 4.0 as both are already doubles. | |||||
| /* The stream is significantly longer than the container duration, which is | |||||
| * suspicious. */ | |||||
| anim->duration = 0; | |||||
| } | } | ||||
| else { | } | ||||
| } | |||||
| /* Fall back to the container. */ | |||||
| if (anim->duration == 0) { | |||||
| anim->duration = (int)(pFormatCtx->duration * av_q2d(frame_rate) / AV_TIME_BASE + 0.5f); | anim->duration = (int)(pFormatCtx->duration * av_q2d(frame_rate) / AV_TIME_BASE + 0.5f); | ||||
| } | } | ||||
| frs_num = frame_rate.num; | frs_num = frame_rate.num; | ||||
| frs_den = frame_rate.den; | frs_den = frame_rate.den; | ||||
| frs_den *= AV_TIME_BASE; | frs_den *= AV_TIME_BASE; | ||||
| ▲ Show 20 Lines • Show All 871 Lines • Show Last 20 Lines | |||||
Possible integer overflow error?
anim->duration * av_q2d(framerate)