mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avcodec/v4l2_m2m: fix av_pix_fmt changing when multiple /dev/video* devices are probed
On the RPI, three different /dev/video devices exist (decoder, scaler, encoder). When probing the devices in order, the originally requested pix fmt would be mutated causing the wrong one to be chosen when a matching device was finally found. Signed-off-by: Aman Gupta <aman@tmm1.net>
This commit is contained in:
parent
ac52e06e56
commit
7bb6898b16
@ -621,7 +621,7 @@ int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
|
|||||||
return ff_v4l2_buffer_buf_to_avpkt(pkt, avbuf);
|
return ff_v4l2_buffer_buf_to_avpkt(pkt, avbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_v4l2_context_get_format(V4L2Context* ctx)
|
int ff_v4l2_context_get_format(V4L2Context* ctx, int probe)
|
||||||
{
|
{
|
||||||
struct v4l2_format_update fmt = { 0 };
|
struct v4l2_format_update fmt = { 0 };
|
||||||
int ret;
|
int ret;
|
||||||
@ -631,7 +631,7 @@ int ff_v4l2_context_get_format(V4L2Context* ctx)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
fmt.update_avfmt = 1;
|
fmt.update_avfmt = !probe;
|
||||||
v4l2_save_to_context(ctx, &fmt);
|
v4l2_save_to_context(ctx, &fmt);
|
||||||
|
|
||||||
/* format has been tried already */
|
/* format has been tried already */
|
||||||
|
@ -113,9 +113,10 @@ int ff_v4l2_context_set_format(V4L2Context* ctx);
|
|||||||
* Queries the driver for a valid v4l2 format and copies it to the context.
|
* Queries the driver for a valid v4l2 format and copies it to the context.
|
||||||
*
|
*
|
||||||
* @param[in] ctx A pointer to a V4L2Context. See V4L2Context description for required variables.
|
* @param[in] ctx A pointer to a V4L2Context. See V4L2Context description for required variables.
|
||||||
|
* @param[in] probe Probe only and ignore changes to the format.
|
||||||
* @return 0 in case of success, a negative value representing the error otherwise.
|
* @return 0 in case of success, a negative value representing the error otherwise.
|
||||||
*/
|
*/
|
||||||
int ff_v4l2_context_get_format(V4L2Context* ctx);
|
int ff_v4l2_context_get_format(V4L2Context* ctx, int probe);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases a V4L2Context.
|
* Releases a V4L2Context.
|
||||||
|
@ -108,13 +108,13 @@ static int v4l2_probe_driver(V4L2m2mContext* s)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = ff_v4l2_context_get_format(&s->output);
|
ret = ff_v4l2_context_get_format(&s->output, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ff_v4l2_context_get_format(&s->capture);
|
ret = ff_v4l2_context_get_format(&s->capture, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
|
||||||
goto done;
|
goto done;
|
||||||
@ -222,7 +222,7 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext* s)
|
|||||||
ff_v4l2_context_release(&s->capture);
|
ff_v4l2_context_release(&s->capture);
|
||||||
|
|
||||||
/* 3. get the new capture format */
|
/* 3. get the new capture format */
|
||||||
ret = ff_v4l2_context_get_format(&s->capture);
|
ret = ff_v4l2_context_get_format(&s->capture, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "query the new capture format\n");
|
av_log(s->avctx, AV_LOG_ERROR, "query the new capture format\n");
|
||||||
return ret;
|
return ret;
|
||||||
@ -273,13 +273,13 @@ int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
|
|||||||
s->draining = 0;
|
s->draining = 0;
|
||||||
s->reinit = 0;
|
s->reinit = 0;
|
||||||
|
|
||||||
ret = ff_v4l2_context_get_format(&s->output);
|
ret = ff_v4l2_context_get_format(&s->output, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
|
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ff_v4l2_context_get_format(&s->capture);
|
ret = ff_v4l2_context_get_format(&s->capture, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
|
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user