|
|
|
@ -244,82 +244,6 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s) |
|
|
|
|
{ |
|
|
|
|
void *log_ctx = s->avctx; |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
av_log(log_ctx, AV_LOG_DEBUG, "%s full reinit\n", s->devname); |
|
|
|
|
|
|
|
|
|
/* wait for pending buffer references */ |
|
|
|
|
if (atomic_load(&s->refcount)) |
|
|
|
|
while(sem_wait(&s->refsync) == -1 && errno == EINTR); |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "output VIDIOC_STREAMOFF\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* release and unmmap the buffers */ |
|
|
|
|
ff_v4l2_context_release(&s->output); |
|
|
|
|
ff_v4l2_context_release(&s->capture); |
|
|
|
|
|
|
|
|
|
/* start again now that we know the stream dimensions */ |
|
|
|
|
s->draining = 0; |
|
|
|
|
s->reinit = 0; |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_get_format(&s->output, 0); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_get_format(&s->capture, 0); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_set_format(&s->output); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_set_format(&s->capture); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "can't to set v4l2 capture format\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = ff_v4l2_context_init(&s->output); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 output context's buffers\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* decoder's buffers need to be updated at a later stage */ |
|
|
|
|
if (s->avctx && !av_codec_is_decoder(s->avctx->codec)) { |
|
|
|
|
ret = ff_v4l2_context_init(&s->capture); |
|
|
|
|
if (ret) { |
|
|
|
|
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n"); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
error: |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context) |
|
|
|
|
{ |
|
|
|
|
V4L2m2mContext *s = (V4L2m2mContext*)context; |
|
|
|
|