diff options
author | Aman Gupta <aman@tmm1.net> | 2019-08-23 12:56:33 -0700 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2019-09-10 19:01:13 -0700 |
commit | c0c7946196710d0579a9c85bf65289d5a123ab89 (patch) | |
tree | 35373c710bfb5d4930efe033bbcf9c61b29c7af1 /libavcodec/v4l2_m2m_dec.c | |
parent | d61cf1b1ebc2477749d7d7825a072400ed24af9f (diff) | |
download | ffmpeg-c0c7946196710d0579a9c85bf65289d5a123ab89.tar.gz |
avcodec/v4l2_m2m: decouple v4l2_m2m helpers from AVCodecContext
This will allow re-use of the m2m backend with AVFilterContext
Signed-off-by: Aman Gupta <aman@tmm1.net>
Diffstat (limited to 'libavcodec/v4l2_m2m_dec.c')
-rw-r--r-- | libavcodec/v4l2_m2m_dec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index 5fb8ddd542..596e435463 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -169,9 +169,10 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) { V4L2Context *capture, *output; V4L2m2mContext *s; + V4L2m2mPriv *priv = avctx->priv_data; int ret; - ret = ff_v4l2_m2m_create_context(avctx, &s); + ret = ff_v4l2_m2m_create_context(priv, &s); if (ret < 0) return ret; @@ -191,19 +192,24 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) capture->av_codec_id = AV_CODEC_ID_RAWVIDEO; capture->av_pix_fmt = avctx->pix_fmt; - ret = ff_v4l2_m2m_codec_init(avctx); + ret = ff_v4l2_m2m_codec_init(priv); if (ret) { - V4L2m2mPriv *priv = avctx->priv_data; av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n"); s->self_ref = NULL; av_buffer_unref(&priv->context_ref); return ret; } + s->avctx = avctx; return v4l2_prepare_decoder(s); } +static av_cold int v4l2_decode_close(AVCodecContext *avctx) +{ + return ff_v4l2_m2m_codec_end(avctx->priv_data); +} + #define OFFSET(x) offsetof(V4L2m2mPriv, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM @@ -231,7 +237,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ .priv_class = &v4l2_m2m_ ## NAME ## _dec_class,\ .init = v4l2_decode_init,\ .receive_frame = v4l2_receive_frame,\ - .close = ff_v4l2_m2m_codec_end,\ + .close = v4l2_decode_close,\ .bsfs = bsf_name, \ .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | \ AV_CODEC_CAP_AVOID_PROBING, \ |