#include "cedrus_dec.h"
#include "cedrus_hw.h"
+int cedrus_reference_index_find(struct vb2_queue *queue,
+ struct vb2_buffer *vb2_buf, u64 timestamp)
+{
+ /*
+ * Allow using the current capture buffer as reference, which can occur
+ * for field-coded pictures.
+ */
+ if (vb2_buf->timestamp == timestamp)
+ return vb2_buf->index;
+ else
+ return vb2_find_timestamp(queue, timestamp, 0);
+}
+
void cedrus_device_run(void *priv)
{
struct cedrus_ctx *ctx = priv;
#include <media/videobuf2-dma-contig.h>
#include "cedrus.h"
+#include "cedrus_dec.h"
#include "cedrus_hw.h"
#include "cedrus_regs.h"
cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
/* Forward and backward prediction reference buffers. */
- forward_idx = vb2_find_timestamp(cap_q,
- slice_params->forward_ref_ts, 0);
+ forward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
+ slice_params->forward_ref_ts);
fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr);
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr);
- backward_idx = vb2_find_timestamp(cap_q,
- slice_params->backward_ref_ts, 0);
+ backward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
+ slice_params->backward_ref_ts);
+
bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0);
bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1);