summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2016-09-29 18:58:49 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2016-09-29 22:58:34 +0200
commit49511501aa06ac98e41f0aa30c75ec2868a7dbd2 (patch)
treee9c24ded83afe92892f1139da8c30d97c7e318ea
parentf0ea96d8a2c902455bf0df1aa02deecceccfe930 (diff)
avcodec/cuvid: support a pre-initialized hw_frames_ctx
-rw-r--r--libavcodec/cuvid.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index faef711987..ffe449fc37 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -52,7 +52,6 @@ typedef struct CuvidContext
int64_t prev_pts;
int internal_error;
- int ever_flushed;
int decoder_flushing;
cudaVideoCodec codec_type;
@@ -145,8 +144,12 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
return 0;
}
- if (hwframe_ctx->pool && !ctx->ever_flushed) {
- av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized\n");
+ if (hwframe_ctx->pool && (
+ hwframe_ctx->width < avctx->width ||
+ hwframe_ctx->height < avctx->height ||
+ hwframe_ctx->format != AV_PIX_FMT_CUDA ||
+ hwframe_ctx->sw_format != AV_PIX_FMT_NV12)) {
+ av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n");
ctx->internal_error = AVERROR(EINVAL);
return 0;
}
@@ -805,8 +808,6 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
if (ret < 0)
goto error;
- ctx->ever_flushed = 0;
-
ctx->prev_pts = INT64_MIN;
if (!avctx->pkt_timebase.num || !avctx->pkt_timebase.den)
@@ -828,8 +829,6 @@ static void cuvid_flush(AVCodecContext *avctx)
CUVIDSOURCEDATAPACKET seq_pkt = { 0 };
int ret;
- ctx->ever_flushed = 1;
-
ret = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
if (ret < 0)
goto error;