Lines Matching refs:ctx
33 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_frame_params() local
36 Pps *pps = ctx->ppss.pps; in set_frame_params()
37 Vp8eSps *sps = &ctx->sps; in set_frame_params()
40 pps->qp_sgm[i] = ctx->rc->qp_hdr; in set_frame_params()
50 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_filter() local
51 Vp8eSps *sps = &ctx->sps; in set_filter()
55 Pps *p_pps = ctx->ppss.pps; in set_filter()
56 if (ctx->frame_type == VP8E_FRM_KEY) { in set_filter()
96 if (!ctx->picbuf.cur_pic->ipf && !ctx->picbuf.cur_pic->grf && in set_filter()
97 !ctx->picbuf.cur_pic->arf) { in set_filter()
125 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_segmentation() local
127 Vp8ePps *ppss = &ctx->ppss; in set_segmentation()
129 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in set_segmentation()
130 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in set_segmentation()
133 RK_S32 qp = ctx->rc->qp_hdr; in set_segmentation()
146 RK_U32 mapSize = (ctx->mb_per_frame + 15) / 16 * 8; in set_segmentation()
155 for (y = 0, mb = 0, mask = 0; y < ctx->mb_per_col; y++) { in set_segmentation()
156 for (x = 0; x < ctx->mb_per_row; x++) { in set_segmentation()
183 if (mb * 8 + x < ctx->mb_per_frame) { in set_segmentation()
194 if (ctx->picbuf.cur_pic->i_frame || !pps->segment_enabled) { in set_segmentation()
337 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_frame_header() local
339 Vp8eSps *sps = &ctx->sps; in set_frame_header()
340 Pps *pps = ctx->ppss.pps; in set_frame_header()
342 Vp8ePutBitBuf *bitbuf = &ctx->bitbuf[1]; in set_frame_header()
343 HalVp8eRefPic *cur_pic = ctx->picbuf.cur_pic; in set_frame_header()
344 Vp8eHalEntropy *entropy = &ctx->entropy; in set_frame_header()
354 set_hdr_segmentation(bitbuf, &ctx->ppss, entropy); in set_frame_header()
374 vp8e_put_lit(bitbuf, ctx->rc->qp_hdr, 7); in set_frame_header()
383 HalVp8eRefPic *ref_pic_list = ctx->picbuf.ref_pic_list; in set_frame_header()
437 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_new_frame() local
438 Vp8eSps *sps = &ctx->sps; in set_new_frame()
439 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in set_new_frame()
440 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in set_new_frame()
446 hw_cfg->output_strm_offset += ctx->bitbuf[1].byte_cnt; in set_new_frame()
452 RK_U8 *pTmp = (RK_U8 *)((size_t)(ctx->bitbuf[1].data) & (~0x07)); in set_new_frame()
481 if (ctx->mb_per_frame > 8160) in set_new_frame()
494 if (ctx->mb_per_frame > 1584) in set_new_frame()
501 qp = ctx->rc->qp_hdr; in set_new_frame()
503 RK_S32 tmp = 128 - ctx->entropy.intra_prob; in set_new_frame()
534 y = vp8e_calc_cost_mv(i * 2, ctx->entropy.mv_prob[0]); /* mv y */ in set_new_frame()
535 x = vp8e_calc_cost_mv(i * 2, ctx->entropy.mv_prob[1]); /* mv x */ in set_new_frame()
540 qp = ctx->ppss.pps->qp_sgm[i]; in set_new_frame()
541 hw_cfg->y1_quant_dc[i] = ctx->qp_y1[qp].quant[0]; in set_new_frame()
542 hw_cfg->y1_quant_ac[i] = ctx->qp_y1[qp].quant[1]; in set_new_frame()
543 hw_cfg->y2_quant_dc[i] = ctx->qp_y2[qp].quant[0]; in set_new_frame()
544 hw_cfg->y2_quant_ac[i] = ctx->qp_y2[qp].quant[1]; in set_new_frame()
545 hw_cfg->ch_quant_dc[i] = ctx->qp_ch[qp].quant[0]; in set_new_frame()
546 hw_cfg->ch_quant_ac[i] = ctx->qp_ch[qp].quant[1]; in set_new_frame()
547 hw_cfg->y1_zbin_dc[i] = ctx->qp_y1[qp].zbin[0]; in set_new_frame()
548 hw_cfg->y1_zbin_ac[i] = ctx->qp_y1[qp].zbin[1]; in set_new_frame()
549 hw_cfg->y2_zbin_dc[i] = ctx->qp_y2[qp].zbin[0]; in set_new_frame()
550 hw_cfg->y2_zbin_ac[i] = ctx->qp_y2[qp].zbin[1]; in set_new_frame()
551 hw_cfg->ch_zbin_dc[i] = ctx->qp_ch[qp].zbin[0]; in set_new_frame()
552 hw_cfg->ch_zbin_ac[i] = ctx->qp_ch[qp].zbin[1]; in set_new_frame()
553 hw_cfg->y1_round_dc[i] = ctx->qp_y1[qp].round[0]; in set_new_frame()
554 hw_cfg->y1_round_ac[i] = ctx->qp_y1[qp].round[1]; in set_new_frame()
555 hw_cfg->y2_round_dc[i] = ctx->qp_y2[qp].round[0]; in set_new_frame()
556 hw_cfg->y2_round_ac[i] = ctx->qp_y2[qp].round[1]; in set_new_frame()
557 hw_cfg->ch_round_dc[i] = ctx->qp_ch[qp].round[0]; in set_new_frame()
558 hw_cfg->ch_round_ac[i] = ctx->qp_ch[qp].round[1]; in set_new_frame()
559 hw_cfg->y1_dequant_dc[i] = ctx->qp_y1[qp].dequant[0]; in set_new_frame()
560 hw_cfg->y1_dequant_ac[i] = ctx->qp_y1[qp].dequant[1]; in set_new_frame()
561 hw_cfg->y2_dequant_dc[i] = ctx->qp_y2[qp].dequant[0]; in set_new_frame()
562 hw_cfg->y2_dequant_ac[i] = ctx->qp_y2[qp].dequant[1]; in set_new_frame()
563 hw_cfg->ch_dequant_dc[i] = ctx->qp_ch[qp].dequant[0]; in set_new_frame()
564 hw_cfg->ch_dequant_ac[i] = ctx->qp_ch[qp].dequant[1]; in set_new_frame()
566 hw_cfg->filter_level[i] = ctx->ppss.pps->level_sgm[i]; in set_new_frame()
569 hw_cfg->bool_enc_value = ctx->bitbuf[1].bottom; in set_new_frame()
570 hw_cfg->bool_enc_value_bits = 24 - ctx->bitbuf[1].bits_left; in set_new_frame()
571 hw_cfg->bool_enc_range = ctx->bitbuf[1].range; in set_new_frame()
573 if (ctx->picbuf.cur_pic->i_frame) in set_new_frame()
583 hw_cfg->segment_enable = ctx->ppss.pps->segment_enabled; in set_new_frame()
584 hw_cfg->segment_map_update = ctx->ppss.pps->sgm.map_modified; in set_new_frame()
586 ctx->ppss.pps->sgm.map_modified = 0; in set_new_frame()
604 HalVp8eCtx *ctx = (HalVp8eCtx *) hal; in set_code_frame() local
606 vp8e_init_entropy(ctx); in set_code_frame()
607 set_segmentation(ctx); in set_code_frame()
608 set_filter(ctx); in set_code_frame()
609 set_frame_header(ctx); in set_code_frame()
610 set_new_frame(ctx); in set_code_frame()
611 vp8e_write_entropy_tables(ctx); in set_code_frame()
669 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in init_picbuf() local
670 HalVp8ePicBuf *buf = &ctx->picbuf; in init_picbuf()
698 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_picbuf_ref() local
699 HalVp8ePicBuf *pic_buf = &ctx->picbuf; in set_picbuf_ref()
700 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in set_picbuf_ref()
797 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in write_ivf_header() local
799 MppEncPrepCfg *prep = &ctx->cfg->prep; in write_ivf_header()
800 MppEncRcCfg *rc = &ctx->cfg->rc; in write_ivf_header()
829 data[24] = ctx->frame_cnt & 0xff; in write_ivf_header()
830 data[25] = (ctx->frame_cnt >> 8) & 0xff; in write_ivf_header()
831 data[26] = (ctx->frame_cnt >> 16) & 0xff; in write_ivf_header()
832 data[27] = (ctx->frame_cnt >> 24) & 0xff; in write_ivf_header()
841 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in write_ivf_frame() local
842 RK_S32 byte_cnt = ctx->frame_size; in write_ivf_frame()
849 data[4] = ctx->frame_cnt & 0xff; in write_ivf_frame()
850 data[5] = (ctx->frame_cnt >> 8) & 0xff; in write_ivf_frame()
851 data[6] = (ctx->frame_cnt >> 16) & 0xff; in write_ivf_frame()
852 data[7] = (ctx->frame_cnt >> 24) & 0xff; in write_ivf_frame()
853 data[8] = (ctx->frame_cnt >> 32) & 0xff; in write_ivf_frame()
854 data[9] = (ctx->frame_cnt >> 40) & 0xff; in write_ivf_frame()
855 data[10] = (ctx->frame_cnt >> 48) & 0xff; in write_ivf_frame()
856 data[11] = (ctx->frame_cnt >> 56) & 0xff; in write_ivf_frame()
864 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_frame_tag() local
866 HalVp8ePicBuf *pic_buf = &ctx->picbuf; in set_frame_tag()
868 Vp8ePutBitBuf *bitbuf = &ctx->bitbuf[0]; in set_frame_tag()
874 tmp = ((ctx->bitbuf[1].byte_cnt) << 5) | in set_frame_tag()
876 (ctx->sps.profile << 1) | in set_frame_tag()
892 if (ctx->hw_cfg.input_rotation) { in set_frame_tag()
893 pic_height_in_pixel = ctx->sps.pic_width_in_pixel; in set_frame_tag()
894 pic_width_in_pixel = ctx->sps.pic_height_in_pixel; in set_frame_tag()
895 h_scaling = ctx->sps.vertical_scaling; in set_frame_tag()
896 v_scaling = ctx->sps.horizontal_scaling; in set_frame_tag()
898 pic_height_in_pixel = ctx->sps.pic_height_in_pixel; in set_frame_tag()
899 pic_width_in_pixel = ctx->sps.pic_width_in_pixel; in set_frame_tag()
900 h_scaling = ctx->sps.horizontal_scaling; in set_frame_tag()
901 v_scaling = ctx->sps.vertical_scaling; in set_frame_tag()
918 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_data_part_size() local
920 if (!ctx->sps.dct_partitions) in set_data_part_size()
923 for (i = 2; i < ctx->sps.partition_cnt - 1; i++) { in set_data_part_size()
924 Vp8ePutBitBuf *bitbuf = ctx->bitbuf; in set_data_part_size()
984 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_parameter() local
986 Vp8eSps *sps = &ctx->sps; in set_parameter()
987 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in set_parameter()
988 MppEncPrepCfg *set = &ctx->cfg->prep; in set_parameter()
1013 stride = get_vepu_pixel_stride(&ctx->stride_cfg, width, in set_parameter()
1016 ctx->mb_per_frame = width_align / 16 * height_align / 16; in set_parameter()
1017 ctx->mb_per_row = width_align / 16; in set_parameter()
1018 ctx->mb_per_col = height_align / 16; in set_parameter()
1163 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in set_picbuf() local
1168 RK_S32 width = ctx->sps.pic_width_in_mbs * 16; in set_picbuf()
1169 RK_S32 height = ctx->sps.pic_height_in_mbs * 16; in set_picbuf()
1170 HalVp8ePicBuf *picbuf = &ctx->picbuf; in set_picbuf()
1187 ctx->ppss.size = 1; in set_picbuf()
1188 ctx->ppss.store = (Pps *)mpp_calloc(Pps, 1); in set_picbuf()
1189 if (ctx->ppss.store == NULL) { in set_picbuf()
1194 ctx->ppss.pps = ctx->ppss.store; in set_picbuf()
1195 ctx->ppss.pps->segment_enabled = 0; in set_picbuf()
1196 ctx->ppss.pps->sgm.map_modified = 0; in set_picbuf()
1208 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in alloc_buffer() local
1210 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in alloc_buffer()
1211 MppEncPrepCfg *pre = &ctx->cfg->prep; in alloc_buffer()
1212 RK_U32 mb_total = ctx->mb_per_frame; in alloc_buffer()
1213 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in alloc_buffer()
1308 ctx->picbuf.size = 1; in alloc_buffer()
1310 ctx->picbuf.ref_pic[i].picture.lum = mpp_buffer_get_fd(buffers->hw_luma_buf); in alloc_buffer()
1312 ctx->picbuf.ref_pic[i].picture.cb = mpp_buffer_get_fd(buffers->hw_cbcr_buf[i]); in alloc_buffer()
1324 ctx->regs = mpp_calloc(RK_U32, ctx->reg_size); in alloc_buffer()
1325 if (!ctx->regs) { in alloc_buffer()
1361 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in hal_vp8e_enc_strm_code() local
1362 Vp8eHwCfg *hw_cfg = &ctx->hw_cfg; in hal_vp8e_enc_strm_code()
1365 MppEncCfgSet *cfg = ctx->cfg; in hal_vp8e_enc_strm_code()
1371 ctx->p_out_buf[i] = NULL; in hal_vp8e_enc_strm_code()
1372 ctx->stream_size[i] = 0; in hal_vp8e_enc_strm_code()
1403 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in hal_vp8e_enc_strm_code()
1410 if (ctx->frame_type == VP8E_FRM_KEY) in hal_vp8e_enc_strm_code()
1412 vp8e_set_buffer(&ctx->bitbuf[0], p_start, p_end - p_start); in hal_vp8e_enc_strm_code()
1421 vp8e_set_buffer(&ctx->bitbuf[1], p_start, p_end - p_start); in hal_vp8e_enc_strm_code()
1430 vp8e_set_buffer(&ctx->bitbuf[2], p_start, p_end - p_start); in hal_vp8e_enc_strm_code()
1441 HalVp8ePicBuf *pic_buf = &ctx->picbuf; in hal_vp8e_enc_strm_code()
1444 pic_buf->cur_pic->poc = ctx->frame_cnt; in hal_vp8e_enc_strm_code()
1445 pic_buf->cur_pic->i_frame = (ctx->frame_type == VP8E_FRM_KEY); in hal_vp8e_enc_strm_code()
1447 init_picbuf(ctx); in hal_vp8e_enc_strm_code()
1449 if (ctx->frame_type == VP8E_FRM_P) { in hal_vp8e_enc_strm_code()
1459 if (ctx->rc->frame_coded == 0) in hal_vp8e_enc_strm_code()
1462 if (ctx->rc->golden_picture_rate) { in hal_vp8e_enc_strm_code()
1468 set_frame_params(ctx); in hal_vp8e_enc_strm_code()
1469 set_picbuf_ref(ctx); in hal_vp8e_enc_strm_code()
1470 set_code_frame(ctx); in hal_vp8e_enc_strm_code()
1478 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in hal_vp8e_init_qp_table() local
1482 Vp8eQp * qp = &ctx->qp_y1[i]; in hal_vp8e_init_qp_table()
1497 qp = &ctx->qp_y2[i]; in hal_vp8e_init_qp_table()
1514 qp = &ctx->qp_ch[i]; in hal_vp8e_init_qp_table()
1535 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in hal_vp8e_update_buffers() local
1536 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in hal_vp8e_update_buffers()
1537 const RK_U32 hw_offset = ctx->hw_cfg.first_free_bit / 8; in hal_vp8e_update_buffers()
1542 ctx->bitbuf[1].byte_cnt += part[0] - hw_offset; in hal_vp8e_update_buffers()
1543 ctx->bitbuf[1].data += part[0] - hw_offset; in hal_vp8e_update_buffers()
1545 ctx->bitbuf[2].byte_cnt = part[1]; in hal_vp8e_update_buffers()
1546 ctx->bitbuf[2].data += part[1]; in hal_vp8e_update_buffers()
1547 ctx->bitbuf[3].byte_cnt = part[2]; in hal_vp8e_update_buffers()
1548 ctx->bitbuf[3].data += part[2]; in hal_vp8e_update_buffers()
1550 set_frame_tag(ctx); in hal_vp8e_update_buffers()
1552 if (vp8e_buffer_gap(&ctx->bitbuf[1], 4) == MPP_OK) { in hal_vp8e_update_buffers()
1553 set_data_part_size(ctx); in hal_vp8e_update_buffers()
1556 ctx->prev_frame_lost = 0; in hal_vp8e_update_buffers()
1558 ctx->p_out_buf[0] = (RK_U32 *)ctx->bitbuf[0].p_data; in hal_vp8e_update_buffers()
1559 ctx->p_out_buf[1] = (RK_U32 *)ctx->bitbuf[2].p_data; in hal_vp8e_update_buffers()
1560 if (ctx->sps.dct_partitions) in hal_vp8e_update_buffers()
1561 ctx->p_out_buf[2] = (RK_U32 *)ctx->bitbuf[3].p_data; in hal_vp8e_update_buffers()
1563 ctx->stream_size[0] = ctx->bitbuf[0].byte_cnt + in hal_vp8e_update_buffers()
1564 ctx->bitbuf[1].byte_cnt; in hal_vp8e_update_buffers()
1565 ctx->stream_size[1] = ctx->bitbuf[2].byte_cnt; in hal_vp8e_update_buffers()
1567 if (ctx->sps.dct_partitions) in hal_vp8e_update_buffers()
1568 ctx->stream_size[2] = ctx->bitbuf[3].byte_cnt; in hal_vp8e_update_buffers()
1570 ctx->frame_size = ctx->stream_size[0] + ctx->stream_size[1] + in hal_vp8e_update_buffers()
1571 ctx->stream_size[2]; in hal_vp8e_update_buffers()
1573 update_picbuf(&ctx->picbuf); in hal_vp8e_update_buffers()
1577 RK_S32 disable_ivf = ctx->cfg->vp8.disable_ivf; in hal_vp8e_update_buffers()
1584 if (ctx->frame_size) { in hal_vp8e_update_buffers()
1585 write_ivf_frame(ctx, p_out); in hal_vp8e_update_buffers()
1592 memcpy(p_out, ctx->p_out_buf[0], ctx->stream_size[0]); in hal_vp8e_update_buffers()
1593 p_out += ctx->stream_size[0]; in hal_vp8e_update_buffers()
1594 enc_task->length += ctx->stream_size[0]; in hal_vp8e_update_buffers()
1596 memcpy(p_out, ctx->p_out_buf[1], ctx->stream_size[1]); in hal_vp8e_update_buffers()
1597 p_out += ctx->stream_size[1]; in hal_vp8e_update_buffers()
1598 enc_task->length += ctx->stream_size[1]; in hal_vp8e_update_buffers()
1600 memcpy(p_out, ctx->p_out_buf[2], ctx->stream_size[2]); in hal_vp8e_update_buffers()
1601 p_out += ctx->stream_size[2]; in hal_vp8e_update_buffers()
1602 enc_task->length += ctx->stream_size[2]; in hal_vp8e_update_buffers()
1612 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in hal_vp8e_setup() local
1614 if (set_parameter(ctx)) { in hal_vp8e_setup()
1619 if (set_picbuf(ctx)) { in hal_vp8e_setup()
1624 ret = alloc_buffer(ctx); in hal_vp8e_setup()
1631 HalVp8eCtx *ctx = (HalVp8eCtx *)hal; in hal_vp8e_buf_free() local
1632 Vp8eVpuBuf *buffers = (Vp8eVpuBuf *)ctx->buffers; in hal_vp8e_buf_free()