Skip to content

Commit

Permalink
avcodec/cuvid: support a pre-initialized hw_frames_ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
BtbN committed Sep 29, 2016
1 parent f0ea96d commit 4951150
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions libavcodec/cuvid.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ typedef struct CuvidContext
int64_t prev_pts;

int internal_error;
int ever_flushed;
int decoder_flushing;

cudaVideoCodec codec_type;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 4951150

Please sign in to comment.