Mercurial > libavcodec.hg
comparison mpegvideo.c @ 2419:0c5ceb97815d libavcodec
picture heap corruption fix
author | michael |
---|---|
date | Mon, 10 Jan 2005 23:41:25 +0000 |
parents | 81516be6d0e4 |
children | 18b8b2dcc037 |
comparison
equal
deleted
inserted
replaced
2418:82af834636c2 | 2419:0c5ceb97815d |
---|---|
1957 AVFrame *pic=NULL; | 1957 AVFrame *pic=NULL; |
1958 int i; | 1958 int i; |
1959 const int encoding_delay= s->max_b_frames; | 1959 const int encoding_delay= s->max_b_frames; |
1960 int direct=1; | 1960 int direct=1; |
1961 | 1961 |
1962 if(pic_arg){ | |
1963 if(pic_arg->pts != AV_NOPTS_VALUE){ | |
1964 if(s->user_specified_pts != AV_NOPTS_VALUE){ | |
1965 int64_t time= av_rescale(pic_arg->pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE); | |
1966 int64_t last= av_rescale(s->user_specified_pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE); | |
1967 | |
1968 if(time <= last){ | |
1969 av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pic_arg->pts, s->user_specified_pts); | |
1970 return -1; | |
1971 } | |
1972 } | |
1973 s->user_specified_pts= pic_arg->pts; | |
1974 }else{ | |
1975 if(s->user_specified_pts != AV_NOPTS_VALUE){ | |
1976 s->user_specified_pts= | |
1977 pic_arg->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate; | |
1978 av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic_arg->pts); | |
1979 }else{ | |
1980 pic_arg->pts= av_rescale(pic_arg->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate); | |
1981 } | |
1982 } | |
1983 } | |
1984 | |
1962 if(pic_arg){ | 1985 if(pic_arg){ |
1963 if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0; | 1986 if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0; |
1964 if(pic_arg->linesize[0] != s->linesize) direct=0; | 1987 if(pic_arg->linesize[0] != s->linesize) direct=0; |
1965 if(pic_arg->linesize[1] != s->uvlinesize) direct=0; | 1988 if(pic_arg->linesize[1] != s->uvlinesize) direct=0; |
1966 if(pic_arg->linesize[2] != s->uvlinesize) direct=0; | 1989 if(pic_arg->linesize[2] != s->uvlinesize) direct=0; |
2019 } | 2042 } |
2020 copy_picture_attributes(s, pic, pic_arg); | 2043 copy_picture_attributes(s, pic, pic_arg); |
2021 | 2044 |
2022 pic->display_picture_number= s->input_picture_number++; | 2045 pic->display_picture_number= s->input_picture_number++; |
2023 | 2046 |
2024 if(pic->pts != AV_NOPTS_VALUE){ | |
2025 if(s->user_specified_pts != AV_NOPTS_VALUE){ | |
2026 int64_t time= av_rescale(pic->pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE); | |
2027 int64_t last= av_rescale(s->user_specified_pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE); | |
2028 | |
2029 if(time <= last){ | |
2030 av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pic->pts, s->user_specified_pts); | |
2031 return -1; | |
2032 } | |
2033 } | |
2034 s->user_specified_pts= pic->pts; | |
2035 }else{ | |
2036 if(s->user_specified_pts != AV_NOPTS_VALUE){ | |
2037 s->user_specified_pts= | |
2038 pic->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate; | |
2039 av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic->pts); | |
2040 }else{ | |
2041 pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate); | |
2042 } | |
2043 } | |
2044 } | 2047 } |
2045 | 2048 |
2046 /* shift buffer entries */ | 2049 /* shift buffer entries */ |
2047 for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++) | 2050 for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++) |
2048 s->input_picture[i-1]= s->input_picture[i]; | 2051 s->input_picture[i-1]= s->input_picture[i]; |