Lines Matching refs:enc
54 static void flush(struct rvce_encoder *enc) in flush() argument
56 enc->ws->cs_flush(enc->cs, PIPE_FLUSH_ASYNC, NULL); in flush()
57 enc->task_info_idx = 0; in flush()
58 enc->bs_idx = 0; in flush()
62 static void dump_feedback(struct rvce_encoder *enc, struct rvid_buffer *fb)
64 uint32_t *ptr = enc->ws->buffer_map(fb->res->buf, enc->cs, PIPE_TRANSFER_READ_WRITE);
83 enc->ws->buffer_unmap(fb->res->buf);
90 static void reset_cpb(struct rvce_encoder *enc) in reset_cpb() argument
94 LIST_INITHEAD(&enc->cpb_slots); in reset_cpb()
95 for (i = 0; i < enc->cpb_num; ++i) { in reset_cpb()
96 struct rvce_cpb_slot *slot = &enc->cpb_array[i]; in reset_cpb()
101 LIST_ADDTAIL(&slot->list, &enc->cpb_slots); in reset_cpb()
108 static void sort_cpb(struct rvce_encoder *enc) in sort_cpb() argument
112 LIST_FOR_EACH_ENTRY(i, &enc->cpb_slots, list) { in sort_cpb()
113 if (i->frame_num == enc->pic.ref_idx_l0) in sort_cpb()
116 if (i->frame_num == enc->pic.ref_idx_l1) in sort_cpb()
119 if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P && l0) in sort_cpb()
122 if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B && in sort_cpb()
129 LIST_ADD(&l1->list, &enc->cpb_slots); in sort_cpb()
134 LIST_ADD(&l0->list, &enc->cpb_slots); in sort_cpb()
141 static unsigned get_cpb_num(struct rvce_encoder *enc) in get_cpb_num() argument
143 unsigned w = align(enc->base.width, 16) / 16; in get_cpb_num()
144 unsigned h = align(enc->base.height, 16) / 16; in get_cpb_num()
147 switch (enc->base.level) { in get_cpb_num()
195 struct rvce_cpb_slot *si_current_slot(struct rvce_encoder *enc) in si_current_slot() argument
197 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.prev, list); in si_current_slot()
203 struct rvce_cpb_slot *si_l0_slot(struct rvce_encoder *enc) in si_l0_slot() argument
205 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next, list); in si_l0_slot()
211 struct rvce_cpb_slot *si_l1_slot(struct rvce_encoder *enc) in si_l1_slot() argument
213 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next->next, list); in si_l1_slot()
219 void si_vce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, in si_vce_frame_offset() argument
222 struct si_screen *sscreen = (struct si_screen *)enc->screen; in si_vce_frame_offset()
226 pitch = align(enc->luma->u.legacy.level[0].nblk_x * enc->luma->bpe, 128); in si_vce_frame_offset()
227 vpitch = align(enc->luma->u.legacy.level[0].nblk_y, 16); in si_vce_frame_offset()
229 pitch = align(enc->luma->u.gfx9.surf_pitch * enc->luma->bpe, 256); in si_vce_frame_offset()
230 vpitch = align(enc->luma->u.gfx9.surf_height, 16); in si_vce_frame_offset()
243 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_destroy() local
244 if (enc->stream_handle) { in rvce_destroy()
246 si_vid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING); in rvce_destroy()
247 enc->fb = &fb; in rvce_destroy()
248 enc->session(enc); in rvce_destroy()
249 enc->destroy(enc); in rvce_destroy()
250 flush(enc); in rvce_destroy()
253 si_vid_destroy_buffer(&enc->cpb); in rvce_destroy()
254 enc->ws->cs_destroy(enc->cs); in rvce_destroy()
255 FREE(enc->cpb_array); in rvce_destroy()
256 FREE(enc); in rvce_destroy()
263 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_begin_frame() local
268 enc->pic.rate_ctrl.rate_ctrl_method != pic->rate_ctrl.rate_ctrl_method || in rvce_begin_frame()
269 enc->pic.quant_i_frames != pic->quant_i_frames || in rvce_begin_frame()
270 enc->pic.quant_p_frames != pic->quant_p_frames || in rvce_begin_frame()
271 enc->pic.quant_b_frames != pic->quant_b_frames; in rvce_begin_frame()
273 enc->pic = *pic; in rvce_begin_frame()
274 si_get_pic_param(enc, pic); in rvce_begin_frame()
276 enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma); in rvce_begin_frame()
277 enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma); in rvce_begin_frame()
280 reset_cpb(enc); in rvce_begin_frame()
283 sort_cpb(enc); in rvce_begin_frame()
285 if (!enc->stream_handle) { in rvce_begin_frame()
287 enc->stream_handle = si_vid_alloc_stream_handle(); in rvce_begin_frame()
288 si_vid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING); in rvce_begin_frame()
289 enc->fb = &fb; in rvce_begin_frame()
290 enc->session(enc); in rvce_begin_frame()
291 enc->create(enc); in rvce_begin_frame()
292 enc->config(enc); in rvce_begin_frame()
293 enc->feedback(enc); in rvce_begin_frame()
294 flush(enc); in rvce_begin_frame()
301 enc->session(enc); in rvce_begin_frame()
302 enc->config(enc); in rvce_begin_frame()
303 flush(enc); in rvce_begin_frame()
312 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_encode_bitstream() local
313 enc->get_buffer(destination, &enc->bs_handle, NULL); in rvce_encode_bitstream()
314 enc->bs_size = destination->width0; in rvce_encode_bitstream()
316 *fb = enc->fb = CALLOC_STRUCT(rvid_buffer); in rvce_encode_bitstream()
317 if (!si_vid_create_buffer(enc->screen, enc->fb, 512, PIPE_USAGE_STAGING)) { in rvce_encode_bitstream()
321 if (!radeon_emitted(enc->cs, 0)) in rvce_encode_bitstream()
322 enc->session(enc); in rvce_encode_bitstream()
323 enc->encode(enc); in rvce_encode_bitstream()
324 enc->feedback(enc); in rvce_encode_bitstream()
331 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_end_frame() local
333 struct rvce_cpb_slot, enc->cpb_slots.prev, list); in rvce_end_frame()
335 if (!enc->dual_inst || enc->bs_idx > 1) in rvce_end_frame()
336 flush(enc); in rvce_end_frame()
339 slot->picture_type = enc->pic.picture_type; in rvce_end_frame()
340 slot->frame_num = enc->pic.frame_num; in rvce_end_frame()
341 slot->pic_order_cnt = enc->pic.pic_order_cnt; in rvce_end_frame()
342 if (!enc->pic.not_referenced) { in rvce_end_frame()
344 LIST_ADD(&slot->list, &enc->cpb_slots); in rvce_end_frame()
351 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_get_feedback() local
355 uint32_t *ptr = enc->ws->buffer_map(fb->res->buf, enc->cs, PIPE_TRANSFER_READ_WRITE); in rvce_get_feedback()
363 enc->ws->buffer_unmap(fb->res->buf); in rvce_get_feedback()
375 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_flush() local
377 flush(enc); in rvce_flush()
393 struct rvce_encoder *enc; in si_vce_create_encoder() local
407 enc = CALLOC_STRUCT(rvce_encoder); in si_vce_create_encoder()
408 if (!enc) in si_vce_create_encoder()
412 enc->use_vm = true; in si_vce_create_encoder()
415 enc->use_vui = true; in si_vce_create_encoder()
420 enc->dual_pipe = true; in si_vce_create_encoder()
425 enc->dual_inst = true; in si_vce_create_encoder()
427 enc->base = *templ; in si_vce_create_encoder()
428 enc->base.context = context; in si_vce_create_encoder()
430 enc->base.destroy = rvce_destroy; in si_vce_create_encoder()
431 enc->base.begin_frame = rvce_begin_frame; in si_vce_create_encoder()
432 enc->base.encode_bitstream = rvce_encode_bitstream; in si_vce_create_encoder()
433 enc->base.end_frame = rvce_end_frame; in si_vce_create_encoder()
434 enc->base.flush = rvce_flush; in si_vce_create_encoder()
435 enc->base.get_feedback = rvce_get_feedback; in si_vce_create_encoder()
436 enc->get_buffer = get_buffer; in si_vce_create_encoder()
438 enc->screen = context->screen; in si_vce_create_encoder()
439 enc->ws = ws; in si_vce_create_encoder()
440 enc->cs = ws->cs_create(rctx->ctx, RING_VCE, rvce_cs_flush, enc); in si_vce_create_encoder()
441 if (!enc->cs) { in si_vce_create_encoder()
448 templat.width = enc->base.width; in si_vce_create_encoder()
449 templat.height = enc->base.height; in si_vce_create_encoder()
456 enc->cpb_num = get_cpb_num(enc); in si_vce_create_encoder()
457 if (!enc->cpb_num) in si_vce_create_encoder()
470 cpb_size = cpb_size * enc->cpb_num; in si_vce_create_encoder()
471 if (enc->dual_pipe) in si_vce_create_encoder()
475 if (!si_vid_create_buffer(enc->screen, &enc->cpb, cpb_size, PIPE_USAGE_DEFAULT)) { in si_vce_create_encoder()
480 enc->cpb_array = CALLOC(enc->cpb_num, sizeof(struct rvce_cpb_slot)); in si_vce_create_encoder()
481 if (!enc->cpb_array) in si_vce_create_encoder()
484 reset_cpb(enc); in si_vce_create_encoder()
488 si_vce_40_2_2_init(enc); in si_vce_create_encoder()
496 si_vce_50_init(enc); in si_vce_create_encoder()
503 si_vce_52_init(enc); in si_vce_create_encoder()
509 si_vce_52_init(enc); in si_vce_create_encoder()
515 return &enc->base; in si_vce_create_encoder()
518 if (enc->cs) in si_vce_create_encoder()
519 enc->ws->cs_destroy(enc->cs); in si_vce_create_encoder()
521 si_vid_destroy_buffer(&enc->cpb); in si_vce_create_encoder()
523 FREE(enc->cpb_array); in si_vce_create_encoder()
524 FREE(enc); in si_vce_create_encoder()
554 void si_vce_add_buffer(struct rvce_encoder *enc, struct pb_buffer *buf, in si_vce_add_buffer() argument
560 reloc_idx = enc->ws->cs_add_buffer(enc->cs, buf, usage | RADEON_USAGE_SYNCHRONIZED, in si_vce_add_buffer()
562 if (enc->use_vm) { in si_vce_add_buffer()
564 addr = enc->ws->buffer_get_virtual_address(buf); in si_vce_add_buffer()
569 offset += enc->ws->buffer_get_reloc_offset(buf); in si_vce_add_buffer()