Lines Matching refs:enc
59 static void flush(struct rvce_encoder *enc) in flush() argument
61 enc->ws->cs_flush(enc->cs, RADEON_FLUSH_ASYNC, NULL); in flush()
62 enc->task_info_idx = 0; in flush()
63 enc->bs_idx = 0; in flush()
67 static void dump_feedback(struct rvce_encoder *enc, struct rvid_buffer *fb)
69 uint32_t *ptr = enc->ws->buffer_map(fb->res->buf, enc->cs, PIPE_TRANSFER_READ_WRITE);
88 enc->ws->buffer_unmap(fb->res->buf);
95 static void reset_cpb(struct rvce_encoder *enc) in reset_cpb() argument
99 LIST_INITHEAD(&enc->cpb_slots); in reset_cpb()
100 for (i = 0; i < enc->cpb_num; ++i) { in reset_cpb()
101 struct rvce_cpb_slot *slot = &enc->cpb_array[i]; in reset_cpb()
106 LIST_ADDTAIL(&slot->list, &enc->cpb_slots); in reset_cpb()
113 static void sort_cpb(struct rvce_encoder *enc) in sort_cpb() argument
117 LIST_FOR_EACH_ENTRY(i, &enc->cpb_slots, list) { in sort_cpb()
118 if (i->frame_num == enc->pic.ref_idx_l0) in sort_cpb()
121 if (i->frame_num == enc->pic.ref_idx_l1) in sort_cpb()
124 if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P && l0) in sort_cpb()
127 if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B && in sort_cpb()
134 LIST_ADD(&l1->list, &enc->cpb_slots); in sort_cpb()
139 LIST_ADD(&l0->list, &enc->cpb_slots); in sort_cpb()
146 static unsigned get_cpb_num(struct rvce_encoder *enc) in get_cpb_num() argument
148 unsigned w = align(enc->base.width, 16) / 16; in get_cpb_num()
149 unsigned h = align(enc->base.height, 16) / 16; in get_cpb_num()
152 switch (enc->base.level) { in get_cpb_num()
200 struct rvce_cpb_slot *current_slot(struct rvce_encoder *enc) in current_slot() argument
202 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.prev, list); in current_slot()
208 struct rvce_cpb_slot *l0_slot(struct rvce_encoder *enc) in l0_slot() argument
210 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next, list); in l0_slot()
216 struct rvce_cpb_slot *l1_slot(struct rvce_encoder *enc) in l1_slot() argument
218 return LIST_ENTRY(struct rvce_cpb_slot, enc->cpb_slots.next->next, list); in l1_slot()
224 void rvce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, in rvce_frame_offset() argument
227 unsigned pitch = align(enc->luma->level[0].nblk_x * enc->luma->bpe, 128); in rvce_frame_offset()
228 unsigned vpitch = align(enc->luma->level[0].nblk_y, 16); in rvce_frame_offset()
240 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_destroy() local
241 if (enc->stream_handle) { in rvce_destroy()
243 rvid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING); in rvce_destroy()
244 enc->fb = &fb; in rvce_destroy()
245 enc->session(enc); in rvce_destroy()
246 enc->feedback(enc); in rvce_destroy()
247 enc->destroy(enc); in rvce_destroy()
248 flush(enc); in rvce_destroy()
251 rvid_destroy_buffer(&enc->cpb); in rvce_destroy()
252 enc->ws->cs_destroy(enc->cs); in rvce_destroy()
253 FREE(enc->cpb_array); in rvce_destroy()
254 FREE(enc); in rvce_destroy()
261 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_begin_frame() local
266 enc->pic.rate_ctrl.rate_ctrl_method != pic->rate_ctrl.rate_ctrl_method || in rvce_begin_frame()
267 enc->pic.quant_i_frames != pic->quant_i_frames || in rvce_begin_frame()
268 enc->pic.quant_p_frames != pic->quant_p_frames || in rvce_begin_frame()
269 enc->pic.quant_b_frames != pic->quant_b_frames; in rvce_begin_frame()
271 enc->pic = *pic; in rvce_begin_frame()
272 get_pic_param(enc, pic); in rvce_begin_frame()
274 enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma); in rvce_begin_frame()
275 enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma); in rvce_begin_frame()
278 reset_cpb(enc); in rvce_begin_frame()
281 sort_cpb(enc); in rvce_begin_frame()
283 if (!enc->stream_handle) { in rvce_begin_frame()
285 enc->stream_handle = rvid_alloc_stream_handle(); in rvce_begin_frame()
286 rvid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING); in rvce_begin_frame()
287 enc->fb = &fb; in rvce_begin_frame()
288 enc->session(enc); in rvce_begin_frame()
289 enc->create(enc); in rvce_begin_frame()
290 enc->config(enc); in rvce_begin_frame()
291 enc->feedback(enc); in rvce_begin_frame()
292 flush(enc); in rvce_begin_frame()
299 enc->session(enc); in rvce_begin_frame()
300 enc->config(enc); in rvce_begin_frame()
301 flush(enc); in rvce_begin_frame()
310 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_encode_bitstream() local
311 enc->get_buffer(destination, &enc->bs_handle, NULL); in rvce_encode_bitstream()
312 enc->bs_size = destination->width0; in rvce_encode_bitstream()
314 *fb = enc->fb = CALLOC_STRUCT(rvid_buffer); in rvce_encode_bitstream()
315 if (!rvid_create_buffer(enc->screen, enc->fb, 512, PIPE_USAGE_STAGING)) { in rvce_encode_bitstream()
319 if (!radeon_emitted(enc->cs, 0)) in rvce_encode_bitstream()
320 enc->session(enc); in rvce_encode_bitstream()
321 enc->encode(enc); in rvce_encode_bitstream()
322 enc->feedback(enc); in rvce_encode_bitstream()
329 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_end_frame() local
331 struct rvce_cpb_slot, enc->cpb_slots.prev, list); in rvce_end_frame()
333 if (!enc->dual_inst || enc->bs_idx > 1) in rvce_end_frame()
334 flush(enc); in rvce_end_frame()
337 slot->picture_type = enc->pic.picture_type; in rvce_end_frame()
338 slot->frame_num = enc->pic.frame_num; in rvce_end_frame()
339 slot->pic_order_cnt = enc->pic.pic_order_cnt; in rvce_end_frame()
340 if (!enc->pic.not_referenced) { in rvce_end_frame()
342 LIST_ADD(&slot->list, &enc->cpb_slots); in rvce_end_frame()
349 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_get_feedback() local
353 uint32_t *ptr = enc->ws->buffer_map(fb->res->buf, enc->cs, PIPE_TRANSFER_READ_WRITE); in rvce_get_feedback()
361 enc->ws->buffer_unmap(fb->res->buf); in rvce_get_feedback()
373 struct rvce_encoder *enc = (struct rvce_encoder*)encoder; in rvce_flush() local
375 flush(enc); in rvce_flush()
391 struct rvce_encoder *enc; in rvce_create_encoder() local
405 enc = CALLOC_STRUCT(rvce_encoder); in rvce_create_encoder()
406 if (!enc) in rvce_create_encoder()
410 enc->use_vm = true; in rvce_create_encoder()
413 enc->use_vui = true; in rvce_create_encoder()
418 enc->dual_pipe = true; in rvce_create_encoder()
423 enc->dual_inst = true; in rvce_create_encoder()
425 enc->base = *templ; in rvce_create_encoder()
426 enc->base.context = context; in rvce_create_encoder()
428 enc->base.destroy = rvce_destroy; in rvce_create_encoder()
429 enc->base.begin_frame = rvce_begin_frame; in rvce_create_encoder()
430 enc->base.encode_bitstream = rvce_encode_bitstream; in rvce_create_encoder()
431 enc->base.end_frame = rvce_end_frame; in rvce_create_encoder()
432 enc->base.flush = rvce_flush; in rvce_create_encoder()
433 enc->base.get_feedback = rvce_get_feedback; in rvce_create_encoder()
434 enc->get_buffer = get_buffer; in rvce_create_encoder()
436 enc->screen = context->screen; in rvce_create_encoder()
437 enc->ws = ws; in rvce_create_encoder()
438 enc->cs = ws->cs_create(rctx->ctx, RING_VCE, rvce_cs_flush, enc); in rvce_create_encoder()
439 if (!enc->cs) { in rvce_create_encoder()
446 templat.width = enc->base.width; in rvce_create_encoder()
447 templat.height = enc->base.height; in rvce_create_encoder()
454 enc->cpb_num = get_cpb_num(enc); in rvce_create_encoder()
455 if (!enc->cpb_num) in rvce_create_encoder()
462 cpb_size = cpb_size * enc->cpb_num; in rvce_create_encoder()
463 if (enc->dual_pipe) in rvce_create_encoder()
467 if (!rvid_create_buffer(enc->screen, &enc->cpb, cpb_size, PIPE_USAGE_DEFAULT)) { in rvce_create_encoder()
472 enc->cpb_array = CALLOC(enc->cpb_num, sizeof(struct rvce_cpb_slot)); in rvce_create_encoder()
473 if (!enc->cpb_array) in rvce_create_encoder()
476 reset_cpb(enc); in rvce_create_encoder()
480 radeon_vce_40_2_2_init(enc); in rvce_create_encoder()
488 radeon_vce_50_init(enc); in rvce_create_encoder()
495 radeon_vce_52_init(enc); in rvce_create_encoder()
503 return &enc->base; in rvce_create_encoder()
506 if (enc->cs) in rvce_create_encoder()
507 enc->ws->cs_destroy(enc->cs); in rvce_create_encoder()
509 rvid_destroy_buffer(&enc->cpb); in rvce_create_encoder()
511 FREE(enc->cpb_array); in rvce_create_encoder()
512 FREE(enc); in rvce_create_encoder()
539 void rvce_add_buffer(struct rvce_encoder *enc, struct pb_buffer *buf, in rvce_add_buffer() argument
545 reloc_idx = enc->ws->cs_add_buffer(enc->cs, buf, usage | RADEON_USAGE_SYNCHRONIZED, in rvce_add_buffer()
547 if (enc->use_vm) { in rvce_add_buffer()
549 addr = enc->ws->buffer_get_virtual_address(buf); in rvce_add_buffer()
554 offset += enc->ws->buffer_get_reloc_offset(buf); in rvce_add_buffer()