diff options
author | Aman Gupta <aman@tmm1.net> | 2019-08-23 22:56:33 +0300 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2019-09-11 05:01:13 +0300 |
commit | c0c7946196710d0579a9c85bf65289d5a123ab89 (patch) | |
tree | 35373c710bfb5d4930efe033bbcf9c61b29c7af1 /libavcodec/v4l2_m2m_enc.c | |
parent | d61cf1b1ebc2477749d7d7825a072400ed24af9f (diff) |
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_enc.c')
-rw-r--r-- | libavcodec/v4l2_m2m_enc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index a0d5bcf760..8014e442a8 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -285,9 +285,10 @@ static av_cold int v4l2_encode_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; @@ -306,15 +307,21 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx) capture->av_codec_id = avctx->codec_id; capture->av_pix_fmt = AV_PIX_FMT_NONE; - ret = ff_v4l2_m2m_codec_init(avctx); + ret = ff_v4l2_m2m_codec_init(priv); if (ret) { av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n"); return ret; } + s->avctx = avctx; return v4l2_prepare_encoder(s); } +static av_cold int v4l2_encode_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_ENCODING_PARAM @@ -343,7 +350,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ .init = v4l2_encode_init,\ .send_frame = v4l2_send_frame,\ .receive_packet = v4l2_receive_packet,\ - .close = ff_v4l2_m2m_codec_end,\ + .close = v4l2_encode_close,\ .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \ .wrapper_name = "v4l2m2m", \ }; |