Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions drivers/media/platform/apple/avd/avd-vp9.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ struct avd_vp9_frame_info {
u32 tx_mode : 3;
u32 interpolation_filter : 3;
u32 flags;
u32 width;
u32 height;
u64 timestamp;
dma_addr_t color;
struct v4l2_vp9_segmentation seg;
Expand Down Expand Up @@ -261,20 +263,32 @@ static void set_refs(struct avd_ctx *ctx, struct avd_vp9_run *run)
dst->vp9.width;
yscale = (ref_buf[i]->vp9.height << VP9_REF_SCALE_SHIFT) /
dst->vp9.height;
push(AVD_HDR_HEIGHT(xscale) | AVD_HDR_WIDTH(yscale),
push(AVD_HDR_HEIGHT(yscale) | AVD_HDR_WIDTH(xscale),
"ref_scale");

push_comp(ctx, addr, ref_buf[i]->comp.offsets);
}
}

/* Temporal MV input is the previous shown inter picture, not the new bank. */
static bool avd_vp9_uses_prev_mv(u32 flags, const struct avd_vp9_frame_info *last)
static bool avd_vp9_same_size(const struct v4l2_ctrl_vp9_frame *frame,
const struct avd_vp9_frame_info *last)
{
return !(flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) &&
!(flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) && last->valid &&
return last->width == frame->frame_width_minus_1 + 1 &&
last->height == frame->frame_height_minus_1 + 1;
}

/*
* Temporal MV input is the previous shown inter picture, not the new bank.
* VP9 uses it only if that picture has the same frame size.
*/
static bool avd_vp9_uses_prev_mv(const struct v4l2_ctrl_vp9_frame *frame,
const struct avd_vp9_frame_info *last)
{
return !(frame->flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) &&
!(frame->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) && last->valid &&
(last->flags & V4L2_VP9_FRAME_FLAG_SHOW_FRAME) &&
!(last->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME);
!(last->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) &&
avd_vp9_same_size(frame, last);
}

static u32 make_flags1(struct avd_ctx *ctx, struct avd_vp9_run *run)
Expand Down Expand Up @@ -328,7 +342,7 @@ static u32 make_flags1(struct avd_ctx *ctx, struct avd_vp9_run *run)
flags |= VP9_SEG_ENABLED(frame->seg.flags &
V4L2_VP9_SEGMENTATION_FLAG_ENABLED);

flags |= VP9_HAS_REF(avd_vp9_uses_prev_mv(frame->flags, &vp9_ctx->last));
flags |= VP9_HAS_REF(avd_vp9_uses_prev_mv(frame, &vp9_ctx->last));

flags |= VP9_SEG_RESET(
frame->seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED &&
Expand Down Expand Up @@ -426,7 +440,7 @@ static void set_header(struct avd_ctx *ctx, struct avd_vp9_run *run)
pusha(vp9_ctx->b->bufs.seg.addr, "seg", 1);
pusha(vp9_ctx->b->bufs.seg.addr, "seg", 2);
pusha(vp9_ctx->b->bufs.color.addr, "color", 3);
pusha(avd_vp9_uses_prev_mv(frame->flags, &vp9_ctx->last) ?
pusha(avd_vp9_uses_prev_mv(frame, &vp9_ctx->last) ?
vp9_ctx->last.color : vp9_ctx->b->bufs.color.addr,
"color", 4);

Expand Down Expand Up @@ -568,6 +582,8 @@ static void update_ctx_cur_info(struct avd_vp9_ctx *vp9_ctx,
vp9_ctx->b->cur.reference_mode = dec_params->reference_mode;
vp9_ctx->b->cur.interpolation_filter = dec_params->interpolation_filter;
vp9_ctx->b->cur.flags = dec_params->flags;
vp9_ctx->b->cur.width = dec_params->frame_width_minus_1 + 1;
vp9_ctx->b->cur.height = dec_params->frame_height_minus_1 + 1;
vp9_ctx->b->cur.timestamp = buf->base.vb.vb2_buf.timestamp;
vp9_ctx->b->cur.color = vp9_ctx->b->bufs.color.addr;
vp9_ctx->b->cur.seg = dec_params->seg;
Expand Down
19 changes: 19 additions & 0 deletions drivers/media/platform/apple/avd/tests/vp9-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,25 @@ def without_includes(s):
assert(p->bank[0].busy&&p->bank[1].busy);
avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE);
}
/* After a frame size change the temporal-MV input is not the prior bank. */
params=(struct v4l2_ctrl_vp9_frame){.flags=V4L2_VP9_FRAME_FLAG_SHOW_FRAME,
.frame_width_minus_1=1919,.frame_height_minus_1=1087,.bit_depth=8};
current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx));
struct avd_vp9_bank *shown=p->b;
params.frame_width_minus_1=1899;params.frame_height_minus_1=1079;
current_dst=&dst[1].base.vb;frame.idx=1;assert(!avd_vp9_run(&ctx));
assert(p->b!=shown&&p->last.width==1900&&p->last.height==1080);
{bool prior_color=false;u32 *words=program.cpu;
for(size_t j=0;j<frame.prog_words;j++)if(words[j]==(shown->bufs.color.addr>>8))prior_color=true;
assert(!prior_color);}
avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE);
/* A 1440x1088 reference of a 1920x1088 frame: vertical scale high, horizontal low. */
params.frame_width_minus_1=1919;params.frame_height_minus_1=1087;reference.vp9.width=1440;
current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx));
{bool scale=false;u32 *words=program.cpu;
for(size_t j=0;j<frame.prog_words;j++){assert(words[j]!=0x30004000);if(words[j]==0x40003000)scale=true;}
assert(scale);}
reference.vp9.width=1920;avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);
/* The firmware transport keeps the 64-pixel floor. */
ctx.decoded_fmt.fmt.pix_mp.width=64;ctx.decoded_fmt.fmt.pix_mp.height=64;
ctx.decoded_fmt.fmt.pix_mp.plane_fmt[0].bytesperline=64;
Expand Down
Loading