Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2016-09-09 17:35:48 +0300
committerTimo Rothenpieler <timo@rothenpieler.org>2016-09-09 18:56:07 +0300
commitb91e0e59874d28f35a28acb4f886ab1e7d80cacb (patch)
tree40cd7f67f8d27c6ff8c039cce65c688947404866 /libavcodec
parent132adf73af31a1a5a8c7c0798b09f7012d73bd4c (diff)
avcodec/cuvid: check for and warn about invalid pkt_timebase
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/cuvid.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 120b045945..de75960ecc 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -258,7 +258,10 @@ static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (avpkt->pts != AV_NOPTS_VALUE) {
cupkt.flags = CUVID_PKT_TIMESTAMP;
- cupkt.timestamp = av_rescale_q(avpkt->pts, avctx->pkt_timebase, (AVRational){1, 10000000});
+ if (avctx->pkt_timebase.num && avctx->pkt_timebase.den)
+ cupkt.timestamp = av_rescale_q(avpkt->pts, avctx->pkt_timebase, (AVRational){1, 10000000});
+ else
+ cupkt.timestamp = avpkt->pts;
}
} else {
cupkt.flags = CUVID_PKT_ENDOFSTREAM;
@@ -363,7 +366,10 @@ static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
frame->width = avctx->width;
frame->height = avctx->height;
- frame->pts = av_rescale_q(dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase);
+ if (avctx->pkt_timebase.num && avctx->pkt_timebase.den)
+ frame->pts = av_rescale_q(dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase);
+ else
+ frame->pts = dispinfo.timestamp;
/* CUVIDs opaque reordering breaks the internal pkt logic.
* So set pkt_pts and clear all the other pkt_ fields.
@@ -679,6 +685,9 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
ctx->ever_flushed = 0;
+ if (!avctx->pkt_timebase.num || !avctx->pkt_timebase.den)
+ av_log(avctx, AV_LOG_WARNING, "Invalid pkt_timebase, passing timestamps as-is.\n");
+
return 0;
error: