mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/v4l2_m2m: Simplify capture buffer init check
Before this commit s->avctx == NULL was used to infer that an encoder is being initialzed. Code readability has been improved by directly using !av_codec_is_decoder() instead. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
This commit is contained in:
parent
3905ecbc06
commit
4c1a3e9166
|
@ -176,7 +176,7 @@ static int v4l2_configure_contexts(V4L2m2mContext* s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decoder's buffers need to be updated at a later stage */
|
/* decoder's buffers need to be updated at a later stage */
|
||||||
if (!s->avctx || !av_codec_is_decoder(s->avctx->codec)) {
|
if (s->avctx && !av_codec_is_decoder(s->avctx->codec)) {
|
||||||
ret = ff_v4l2_context_init(&s->capture);
|
ret = ff_v4l2_context_init(&s->capture);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
|
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
|
||||||
|
@ -307,7 +307,7 @@ int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decoder's buffers need to be updated at a later stage */
|
/* decoder's buffers need to be updated at a later stage */
|
||||||
if (!s->avctx || !av_codec_is_decoder(s->avctx->codec)) {
|
if (s->avctx && !av_codec_is_decoder(s->avctx->codec)) {
|
||||||
ret = ff_v4l2_context_init(&s->capture);
|
ret = ff_v4l2_context_init(&s->capture);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
|
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
|
||||||
|
|
|
@ -312,12 +312,12 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
|
||||||
capture->av_codec_id = avctx->codec_id;
|
capture->av_codec_id = avctx->codec_id;
|
||||||
capture->av_pix_fmt = AV_PIX_FMT_NONE;
|
capture->av_pix_fmt = AV_PIX_FMT_NONE;
|
||||||
|
|
||||||
|
s->avctx = avctx;
|
||||||
ret = ff_v4l2_m2m_codec_init(priv);
|
ret = ff_v4l2_m2m_codec_init(priv);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");
|
av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
s->avctx = avctx;
|
|
||||||
|
|
||||||
if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
|
if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
|
||||||
v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
|
v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
|
||||||
|
|
Loading…
Reference in New Issue