1 #include "viddec_pm.h"
2 #include "viddec_fw_debug.h"
3 #include "viddec_parser_ops.h"
4 #include "viddec_emitter.h"
5 #include "viddec_fw_workload.h"
6 #include "viddec_pm_utils_bstream.h"
7
8 extern void viddec_pm_utils_list_emit_pixel_tags(viddec_pm_utils_list_t *list, uint32_t start, viddec_emitter *emitter, uint32_t using_next);
9 extern void viddec_pm_utils_list_emit_slice_tags(viddec_pm_utils_list_t *list, uint32_t start, uint32_t end, viddec_emitter *emitter, uint32_t is_cur_wkld, viddec_workload_item_t *wi);
10
viddec_pm_get_bits(void * parent,uint32_t * data,uint32_t num_bits)11 int32_t viddec_pm_get_bits(void *parent, uint32_t *data, uint32_t num_bits)
12 {
13 int32_t ret = 1;
14 viddec_pm_cxt_t *cxt;
15
16 cxt = (viddec_pm_cxt_t *)parent;
17 ret = viddec_pm_utils_bstream_peekbits(&(cxt->getbits), data, num_bits, 1);
18 if(ret == -1)
19 {DEB("FAILURE!!!! getbits returned %d\n", ret);}
20
21 return ret;
22 }
23
viddec_pm_peek_bits(void * parent,uint32_t * data,uint32_t num_bits)24 int32_t viddec_pm_peek_bits(void *parent, uint32_t *data, uint32_t num_bits)
25 {
26 int32_t ret = 1;
27 viddec_pm_cxt_t *cxt;
28
29 cxt = (viddec_pm_cxt_t *)parent;
30 ret = viddec_pm_utils_bstream_peekbits(&(cxt->getbits), data, num_bits, 0);
31 return ret;
32 }
33
viddec_pm_skip_bits(void * parent,uint32_t num_bits)34 int32_t viddec_pm_skip_bits(void *parent, uint32_t num_bits)
35 {
36 int32_t ret = 1;
37 viddec_pm_cxt_t *cxt;
38
39 cxt = (viddec_pm_cxt_t *)parent;
40 ret = viddec_pm_utils_bstream_skipbits(&(cxt->getbits), num_bits);
41 return ret;
42 }
43
viddec_pm_append_workitem(void * parent,viddec_workload_item_t * item)44 int32_t viddec_pm_append_workitem(void *parent, viddec_workload_item_t *item)
45 {
46 int32_t ret = 1;
47 viddec_pm_cxt_t *cxt;
48
49 cxt = (viddec_pm_cxt_t *)parent;
50 ret = viddec_emit_append(&(cxt->emitter.cur), item);
51 return ret;
52 }
53
viddec_pm_append_workitem_next(void * parent,viddec_workload_item_t * item)54 int32_t viddec_pm_append_workitem_next(void *parent, viddec_workload_item_t *item)
55 {
56 int32_t ret = 1;
57 viddec_pm_cxt_t *cxt;
58
59 cxt = (viddec_pm_cxt_t *)parent;
60 ret = viddec_emit_append(&(cxt->emitter.next), item);
61 return ret;
62 }
63
viddec_pm_get_au_pos(void * parent,uint32_t * bit,uint32_t * byte,uint8_t * is_emul)64 int32_t viddec_pm_get_au_pos(void *parent, uint32_t *bit, uint32_t *byte, uint8_t *is_emul)
65 {
66 int32_t ret = 1;
67 viddec_pm_cxt_t *cxt;
68
69 cxt = (viddec_pm_cxt_t *)parent;
70 viddec_pm_utils_bstream_get_au_offsets(&(cxt->getbits), bit, byte, is_emul);
71
72 return ret;
73
74 }
75
viddec_pm_append_restof_pixel_data(void * parent,uint32_t cur_wkld)76 static inline int32_t viddec_pm_append_restof_pixel_data(void *parent, uint32_t cur_wkld)
77 {
78 int32_t ret = 1;
79 viddec_pm_cxt_t *cxt;
80 uint32_t start=0, b_off=0;
81 uint8_t emul=0;
82 viddec_workload_item_t wi;
83
84 cxt = (viddec_pm_cxt_t *)parent;
85 viddec_pm_utils_bstream_get_au_offsets(&(cxt->getbits), &b_off, &start, &emul);
86 if(emul) start--;
87
88 wi.vwi_type = VIDDEC_WORKLOAD_PIXEL_ES;
89 wi.es.es_flags = 0;
90 viddec_pm_utils_list_emit_slice_tags(&(cxt->list), start, cxt->list.total_bytes -1, &(cxt->emitter), cur_wkld, &wi);
91 return ret;
92 }
93
viddec_pm_append_pixeldata(void * parent)94 int32_t viddec_pm_append_pixeldata(void *parent)
95 {
96 return viddec_pm_append_restof_pixel_data(parent, 1);
97 }
98
viddec_pm_append_pixeldata_next(void * parent)99 int32_t viddec_pm_append_pixeldata_next(void *parent)
100 {
101 return viddec_pm_append_restof_pixel_data(parent, 0);
102 }
103
viddec_pm_get_header(void * parent)104 viddec_workload_t* viddec_pm_get_header(void *parent)
105 {
106 viddec_pm_cxt_t *cxt;
107
108 cxt = (viddec_pm_cxt_t *)parent;
109
110 return cxt->emitter.cur.data;
111 }
112
viddec_pm_get_next_header(void * parent)113 viddec_workload_t* viddec_pm_get_next_header(void *parent)
114 {
115 viddec_pm_cxt_t *cxt;
116
117 cxt = (viddec_pm_cxt_t *)parent;
118
119 return cxt->emitter.next.data;
120 }
121
viddec_pm_is_nomoredata(void * parent)122 int32_t viddec_pm_is_nomoredata(void *parent)
123 {
124 int32_t ret=0;
125 viddec_pm_cxt_t *cxt;
126
127 cxt = (viddec_pm_cxt_t *)parent;
128 ret = viddec_pm_utils_bstream_nomorerbspdata(&(cxt->getbits));
129 return ret;
130 }
131
viddec_pm_get_cur_byte(void * parent,uint8_t * byte)132 uint32_t viddec_pm_get_cur_byte(void *parent, uint8_t *byte)
133 {
134 int32_t ret=-1;
135 viddec_pm_cxt_t *cxt;
136
137 cxt = (viddec_pm_cxt_t *)parent;
138 ret = viddec_pm_utils_bstream_get_current_byte(&(cxt->getbits), byte);
139 return ret;
140 }
141
viddec_pm_append_misc_tags(void * parent,uint32_t start,uint32_t end,viddec_workload_item_t * wi,uint32_t using_next)142 int32_t viddec_pm_append_misc_tags(void *parent, uint32_t start, uint32_t end, viddec_workload_item_t *wi, uint32_t using_next)
143 {
144 int32_t ret = 1;
145 viddec_pm_cxt_t *cxt;
146
147 cxt = (viddec_pm_cxt_t *)parent;
148 if (end == VIDDEC_PARSE_INVALID_POS) end = (cxt->list.total_bytes -1);
149 viddec_pm_utils_list_emit_slice_tags(&(cxt->list), start, end, &(cxt->emitter), using_next, wi);
150
151 return ret;
152
153 }
154
viddec_pm_set_next_frame_error_on_eos(void * parent,uint32_t error)155 void viddec_pm_set_next_frame_error_on_eos(void *parent, uint32_t error)
156 {
157 viddec_pm_cxt_t *cxt;
158 cxt = (viddec_pm_cxt_t *)parent;
159 cxt->next_workload_error_eos = error;
160 }
161
viddec_pm_set_late_frame_detect(void * parent)162 void viddec_pm_set_late_frame_detect(void *parent)
163 {
164 viddec_pm_cxt_t *cxt;
165 cxt = (viddec_pm_cxt_t *)parent;
166 cxt->late_frame_detect = true;
167 }
168
viddec_pm_setup_userdata(viddec_workload_item_t * wi)169 void viddec_pm_setup_userdata(viddec_workload_item_t *wi)
170 {
171 #ifdef MFDBIGENDIAN
172 wi->vwi_payload[0] = SWAP_WORD(wi->vwi_payload[0]);
173 wi->vwi_payload[1] = SWAP_WORD(wi->vwi_payload[1]);
174 wi->vwi_payload[2] = SWAP_WORD(wi->vwi_payload[2]);
175 #else
176 wi=wi;
177 #endif
178 }
179