Skip to content

Commit a512180

Browse files
6by9pelwell
authored andcommitted
bcm2835-codec: Return empty buffers to the VPU instead of queueing to vbuf2
The encoder can skip frames totally should rate control overshoot the target bitrate too far. In this situation it generates an output buffer of length 0. V4L2 treats a buffer of length 0 as an end of stream flag, which is not appropriate in this case, therefore we can not return that buffer to the client. The driver was returning the buffer to videobuf2 in the QUEUED state, however that buffer was then not dequeued again, so the number of buffers was reduced each time this happened. In the pathological case of using GStreamer's videotestsrc in mode 1 for noise, this happens sufficiently frequently to totally stall the pipeline. If the port is still enabled then return the buffer straight back to the VPU rather than to videobuf2. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 16c2452 commit a512180

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,10 +1159,15 @@ static void op_buffer_cb(struct vchiq_mmal_instance *instance,
11591159
v4l2_dbg(2, debug, &ctx->dev->v4l2_dev, "%s: Empty buffer - flags %04x",
11601160
__func__, mmal_buf->mmal_flags);
11611161
if (!(mmal_buf->mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS)) {
1162-
vb2_buffer_done(&vb2->vb2_buf, VB2_BUF_STATE_QUEUED);
1163-
if (!port->enabled &&
1164-
atomic_read(&port->buffers_with_vpu))
1165-
complete(&ctx->frame_cmplt);
1162+
if (!port->enabled) {
1163+
vb2_buffer_done(&vb2->vb2_buf, VB2_BUF_STATE_QUEUED);
1164+
if (atomic_read(&port->buffers_with_vpu))
1165+
complete(&ctx->frame_cmplt);
1166+
} else {
1167+
vchiq_mmal_submit_buffer(ctx->dev->instance,
1168+
&ctx->component->output[0],
1169+
mmal_buf);
1170+
}
11661171
return;
11671172
}
11681173
}

0 commit comments

Comments
 (0)