Lines Matching refs:obj
38 #define to_scalar(obj, t, ptr) \ argument
39 __to_scalar(obj, t, (void *)(ptr))
41 #define to_1d_ptr(obj, t, n, ptr) \ argument
42 __to_1d_ptr(obj, t, n, (void **)(ptr))
44 #define to_2d_ptr(obj, t, n1, n2, ptr) \ argument
45 __to_2d_ptr(obj, t, n1, n2, (void **)(ptr))
47 #define to_1d_copy(obj, t, ptr, n) \ argument
48 __to_1d_copy(obj, t, ptr, n)
50 #define to_2d_copy(obj, t, ptr, n1, n2) \ argument
51 __to_2d_copy(obj, t, ptr, n1, n2)
58 #define new_scalar(obj, ptr) \ argument
59 __new_scalar(obj, ptr)
77 static PyObject *__to_scalar(PyObject *obj, int t, void *ptr) in __to_scalar() argument
79 obj = obj ? PyArray_FROMANY(obj, t, 0, 0, NPY_ARRAY_FORCECAST) : obj; in __to_scalar()
80 if (!obj) in __to_scalar()
83 memcpy(ptr, PyArray_DATA((PyArrayObject *)obj), in __to_scalar()
84 PyArray_NBYTES((PyArrayObject *)obj)); in __to_scalar()
86 return obj; in __to_scalar()
90 static PyObject *__to_1d_ptr(PyObject *obj, int t, int n, void **ptr) in __to_1d_ptr() argument
92 obj = obj ? PyArray_FROMANY(obj, in __to_1d_ptr()
93 t, 1, 1, NPY_ARRAY_FORCECAST|NPY_ARRAY_CARRAY) : obj; in __to_1d_ptr()
94 if (!obj || (n && PyArray_SIZE((PyArrayObject *)obj) != n)) in __to_1d_ptr()
97 *ptr = PyArray_DATA((PyArrayObject *)obj); in __to_1d_ptr()
98 return obj; in __to_1d_ptr()
102 static PyObject *__to_2d_ptr(PyObject *obj, int t, int n1, int n2, void **ptr) in __to_2d_ptr() argument
104 obj = obj ? PyArray_FROMANY(obj, in __to_2d_ptr()
105 t, 2, 2, NPY_ARRAY_FORCECAST|NPY_ARRAY_CARRAY) : obj; in __to_2d_ptr()
106 if (!obj || (n1 && PyArray_DIMS((PyArrayObject *)obj)[0] != n1) in __to_2d_ptr()
107 || (n2 && PyArray_DIMS((PyArrayObject *)obj)[1] != n2)) in __to_2d_ptr()
110 *ptr = PyArray_DATA((PyArrayObject *)obj); in __to_2d_ptr()
111 return obj; in __to_2d_ptr()
115 static PyObject *__to_1d_copy(PyObject *obj, int t, void *v, int n) in __to_1d_copy() argument
119 if ((obj = to_1d_ptr(obj, t, n, &src))) in __to_1d_copy()
120 memcpy(v, src, PyArray_NBYTES((PyArrayObject *)obj)); in __to_1d_copy()
122 return obj; in __to_1d_copy()
126 static PyObject *__to_2d_copy(PyObject *obj, int t, void *v, int n1, int n2) in __to_2d_copy() argument
130 if ((obj = to_2d_ptr(obj, t, n1, n2, &src))) in __to_2d_copy()
131 memcpy(v, src, PyArray_NBYTES((PyArrayObject *)obj)); in __to_2d_copy()
133 return obj; in __to_2d_copy()
141 PyObject *obj = PyArray_SimpleNew(0, NULL, t); in __new_scalar() local
143 memcpy(PyArray_DATA((PyArrayObject *)obj), ptr, in __new_scalar()
144 PyArray_NBYTES((PyArrayObject *)obj)); in __new_scalar()
146 return obj; in __new_scalar()
152 PyObject *obj = PyArray_SimpleNew(1, (const npy_intp []){ n }, t); in __new_1d_ptr() local
154 *ptr = PyArray_DATA((PyArrayObject *)obj); in __new_1d_ptr()
155 return obj; in __new_1d_ptr()
161 PyObject *obj; in __new_2d_ptr() local
163 obj = PyArray_SimpleNew(2, ((const npy_intp []){ n1, n2 }), t); in __new_2d_ptr()
165 *ptr = PyArray_DATA((PyArrayObject *)obj); in __new_2d_ptr()
166 return obj; in __new_2d_ptr()
172 PyObject *obj; in __new_1d_copy() local
175 if ((obj = new_1d_ptr(t, n, &dst))) in __new_1d_copy()
176 memcpy(dst, src, PyArray_NBYTES((PyArrayObject *)obj)); in __new_1d_copy()
178 return obj; in __new_1d_copy()
184 PyObject *obj; in __new_2d_copy() local
187 if ((obj = new_2d_ptr(t, n1, n2, &dst))) in __new_2d_copy()
188 memcpy(dst, src, PyArray_NBYTES((PyArrayObject *)obj)); in __new_2d_copy()
190 return obj; in __new_2d_copy()
199 PyObject *obj, struct lc3_attdet_analysis *attdet) in to_attdet_analysis() argument
201 CTYPES_CHECK("attdet", obj && PyDict_Check(obj)); in to_attdet_analysis()
204 PyDict_GetItemString(obj, "en1"), NPY_INT32, &attdet->en1)); in to_attdet_analysis()
207 PyDict_GetItemString(obj, "an1"), NPY_INT32, &attdet->an1)); in to_attdet_analysis()
210 PyDict_GetItemString(obj, "p_att"), NPY_INT, &attdet->p_att)); in to_attdet_analysis()
212 return obj; in to_attdet_analysis()
217 PyObject *obj, const struct lc3_attdet_analysis *attdet) in from_attdet_analysis() argument
219 if (!obj) obj = PyDict_New(); in from_attdet_analysis()
221 PyDict_SetItemString(obj, "en1", in from_attdet_analysis()
224 PyDict_SetItemString(obj, "an1", in from_attdet_analysis()
227 PyDict_SetItemString(obj, "p_att", in from_attdet_analysis()
230 return obj; in from_attdet_analysis()
239 PyObject *obj, struct lc3_ltpf_hp50_state *hp50) in to_ltpf_hp50_state() argument
241 CTYPES_CHECK("hp50", obj && PyDict_Check(obj)); in to_ltpf_hp50_state()
244 PyDict_GetItemString(obj, "s1"), NPY_INT64, &hp50->s1)); in to_ltpf_hp50_state()
247 PyDict_GetItemString(obj, "s2"), NPY_INT64, &hp50->s2)); in to_ltpf_hp50_state()
249 return obj; in to_ltpf_hp50_state()
254 PyObject *obj, const struct lc3_ltpf_hp50_state *hp50) in from_ltpf_hp50_state() argument
256 PyDict_SetItemString(obj, "s1", in from_ltpf_hp50_state()
259 PyDict_SetItemString(obj, "s2", in from_ltpf_hp50_state()
262 return obj; in from_ltpf_hp50_state()
267 PyObject *obj, struct lc3_ltpf_analysis *ltpf) in to_ltpf_analysis() argument
273 CTYPES_CHECK("ltpf", obj && PyDict_Check(obj)); in to_ltpf_analysis()
276 PyDict_GetItemString(obj, "active"), NPY_BOOL, <pf->active)); in to_ltpf_analysis()
279 PyDict_GetItemString(obj, "pitch"), NPY_INT, <pf->pitch)); in to_ltpf_analysis()
282 PyDict_GetItemString(obj, "nc"), NPY_FLOAT, ltpf->nc, 2)); in to_ltpf_analysis()
283 PyDict_SetItemString(obj, "nc", nc_obj); in to_ltpf_analysis()
286 PyDict_GetItemString(obj, "hp50"), <pf->hp50)); in to_ltpf_analysis()
289 PyDict_GetItemString(obj, "x_12k8"), NPY_INT16, ltpf->x_12k8, n_12k8)); in to_ltpf_analysis()
290 PyDict_SetItemString(obj, "x_12k8", x_12k8_obj); in to_ltpf_analysis()
293 PyDict_GetItemString(obj, "x_6k4"), NPY_INT16, ltpf->x_6k4, n_6k4)); in to_ltpf_analysis()
294 PyDict_SetItemString(obj, "x_6k4", x_6k4_obj); in to_ltpf_analysis()
297 PyDict_GetItemString(obj, "tc"), NPY_INT, <pf->tc)); in to_ltpf_analysis()
299 return obj; in to_ltpf_analysis()
304 PyObject *obj, const struct lc3_ltpf_analysis *ltpf) in from_ltpf_analysis() argument
309 if (!obj) obj = PyDict_New(); in from_ltpf_analysis()
311 PyDict_SetItemString(obj, "active", in from_ltpf_analysis()
314 PyDict_SetItemString(obj, "pitch", in from_ltpf_analysis()
317 PyDict_SetItemString(obj, "nc", in from_ltpf_analysis()
320 PyDict_SetItemString(obj, "hp50", in from_ltpf_analysis()
323 PyDict_SetItemString(obj, "x_12k8", in from_ltpf_analysis()
326 PyDict_SetItemString(obj, "x_6k4", in from_ltpf_analysis()
329 PyDict_SetItemString(obj, "tc", in from_ltpf_analysis()
332 return obj; in from_ltpf_analysis()
337 PyObject *obj, struct lc3_ltpf_synthesis *ltpf) in to_ltpf_synthesis() argument
341 CTYPES_CHECK("ltpf", obj && PyDict_Check(obj)); in to_ltpf_synthesis()
344 PyDict_GetItemString(obj, "active"), NPY_BOOL, <pf->active)); in to_ltpf_synthesis()
347 PyDict_GetItemString(obj, "pitch"), NPY_INT, <pf->pitch)); in to_ltpf_synthesis()
350 PyDict_GetItemString(obj, "c"), NPY_FLOAT, ltpf->c, 2*12)); in to_ltpf_synthesis()
351 PyDict_SetItemString(obj, "c", c_obj); in to_ltpf_synthesis()
354 PyDict_GetItemString(obj, "x"), NPY_FLOAT, ltpf->x, 12)); in to_ltpf_synthesis()
355 PyDict_SetItemString(obj, "x", x_obj); in to_ltpf_synthesis()
357 return obj; in to_ltpf_synthesis()
362 PyObject *obj, const struct lc3_ltpf_synthesis *ltpf) in from_ltpf_synthesis() argument
364 if (!obj) obj = PyDict_New(); in from_ltpf_synthesis()
366 PyDict_SetItemString(obj, "active", in from_ltpf_synthesis()
369 PyDict_SetItemString(obj, "pitch", in from_ltpf_synthesis()
372 PyDict_SetItemString(obj, "c", in from_ltpf_synthesis()
375 PyDict_SetItemString(obj, "x", in from_ltpf_synthesis()
378 return obj; in from_ltpf_synthesis()
384 PyObject *obj = PyDict_New(); in new_ltpf_data() local
386 PyDict_SetItemString(obj, "active", in new_ltpf_data()
389 PyDict_SetItemString(obj, "pitch_index", in new_ltpf_data()
392 return obj; in new_ltpf_data()
397 PyObject *obj, const struct lc3_ltpf_data *data) in to_ltpf_data() argument
401 CTYPES_CHECK("ltpf", obj && PyDict_Check(obj)); in to_ltpf_data()
403 if ((item = PyDict_GetItemString(obj, "active"))) in to_ltpf_data()
407 if ((item = PyDict_GetItemString(obj, "pitch_index"))) in to_ltpf_data()
411 return obj; in to_ltpf_data()
421 PyObject *obj = PyDict_New(); in new_sns_data() local
423 PyDict_SetItemString(obj, "lfcb", in new_sns_data()
426 PyDict_SetItemString(obj, "hfcb", in new_sns_data()
429 PyDict_SetItemString(obj, "shape", in new_sns_data()
432 PyDict_SetItemString(obj, "gain", in new_sns_data()
435 PyDict_SetItemString(obj, "idx_a", in new_sns_data()
438 PyDict_SetItemString(obj, "ls_a", in new_sns_data()
441 PyDict_SetItemString(obj, "idx_b", in new_sns_data()
444 PyDict_SetItemString(obj, "ls_b", in new_sns_data()
447 return obj; in new_sns_data()
451 static PyObject *to_sns_data(PyObject *obj, struct lc3_sns_data *data) in to_sns_data() argument
455 CTYPES_CHECK("sns", obj && PyDict_Check(obj)); in to_sns_data()
457 if ((item = PyDict_GetItemString(obj, "lfcb"))) in to_sns_data()
460 if ((item = PyDict_GetItemString(obj, "hfcb"))) in to_sns_data()
463 if ((item = PyDict_GetItemString(obj, "shape"))) in to_sns_data()
466 if ((item = PyDict_GetItemString(obj, "gain"))) in to_sns_data()
469 if ((item = PyDict_GetItemString(obj, "idx_a"))) in to_sns_data()
472 if ((item = PyDict_GetItemString(obj, "ls_a"))) in to_sns_data()
475 if ((item = PyDict_GetItemString(obj, "idx_b"))) in to_sns_data()
478 if ((item = PyDict_GetItemString(obj, "ls_b"))) in to_sns_data()
481 return obj; in to_sns_data()
491 PyObject *obj = PyDict_New(); in new_tns_data() local
493 PyDict_SetItemString(obj, "nfilters", in new_tns_data()
496 PyDict_SetItemString(obj, "lpc_weighting", in new_tns_data()
499 PyDict_SetItemString(obj, "rc_order", in new_tns_data()
502 PyDict_SetItemString(obj, "rc", in new_tns_data()
505 return obj; in new_tns_data()
509 static PyObject *to_tns_data(PyObject *obj, struct lc3_tns_data *side) in to_tns_data() argument
513 CTYPES_CHECK("tns", obj && PyDict_Check(obj)); in to_tns_data()
515 if ((item = PyDict_GetItemString(obj, "nfilters"))) in to_tns_data()
519 if ((item = PyDict_GetItemString(obj, "lpc_weighting"))) { in to_tns_data()
524 if ((item = PyDict_GetItemString(obj, "rc_order"))) { in to_tns_data()
527 PyDict_SetItemString(obj, "rc_order", item); in to_tns_data()
530 if ((item = PyDict_GetItemString(obj, "rc"))) { in to_tns_data()
533 PyDict_SetItemString(obj, "rc", item); in to_tns_data()
536 return obj; in to_tns_data()
545 PyObject *obj, const struct lc3_spec_analysis *spec) in from_spec_analysis() argument
547 if (!obj) obj = PyDict_New(); in from_spec_analysis()
549 PyDict_SetItemString(obj, "nbits_off", in from_spec_analysis()
552 PyDict_SetItemString(obj, "nbits_spare", in from_spec_analysis()
555 return obj; in from_spec_analysis()
560 PyObject *obj, struct lc3_spec_analysis *spec) in to_spec_analysis() argument
562 CTYPES_CHECK("spec", obj && PyDict_Check(obj)); in to_spec_analysis()
565 to_scalar(PyDict_GetItemString(obj, "nbits_off"), in to_spec_analysis()
569 to_scalar(PyDict_GetItemString(obj, "nbits_spare"), in to_spec_analysis()
572 return obj; in to_spec_analysis()
578 PyObject *obj = PyDict_New(); in new_spec_side() local
580 PyDict_SetItemString(obj, "g_idx", in new_spec_side()
583 PyDict_SetItemString(obj, "nq", in new_spec_side()
586 PyDict_SetItemString(obj, "lsb_mode", in new_spec_side()
589 return obj; in new_spec_side()
594 PyObject *obj, struct lc3_spec_side *side) in to_spec_data() argument
598 CTYPES_CHECK("side", obj && PyDict_Check(obj)); in to_spec_data()
600 if ((item = PyDict_GetItemString(obj, "g_idx"))) in to_spec_data()
604 if ((item = PyDict_GetItemString(obj, "nq"))) in to_spec_data()
608 if ((item = PyDict_GetItemString(obj, "lsb_mode"))) in to_spec_data()
612 return obj; in to_spec_data()
622 PyObject *obj = PyDict_New(); in new_side_data() local
624 PyDict_SetItemString(obj, "bw", in new_side_data()
627 PyDict_SetItemString(obj, "ltpf", in new_side_data()
630 PyDict_SetItemString(obj, "sns", in new_side_data()
633 PyDict_SetItemString(obj, "tns", in new_side_data()
636 return obj; in new_side_data()
640 static PyObject *to_side_data(PyObject *obj, struct side_data *side) in to_side_data() argument
644 CTYPES_CHECK("frame", obj && PyDict_Check(obj)); in to_side_data()
646 if ((item = PyDict_GetItemString(obj, "bw"))) { in to_side_data()
652 if ((item = PyDict_GetItemString(obj, "ltpf"))) in to_side_data()
655 if ((item = PyDict_GetItemString(obj, "sns"))) in to_side_data()
658 if ((item = PyDict_GetItemString(obj, "tns"))) in to_side_data()
661 return obj; in to_side_data()
667 PyObject *obj = PyDict_New(); in new_plc_state() local
669 PyDict_SetItemString(obj, "seed", in new_plc_state()
672 PyDict_SetItemString(obj, "count", in new_plc_state()
675 PyDict_SetItemString(obj, "alpha", in new_plc_state()
678 return obj; in new_plc_state()
683 PyObject *obj, struct lc3_plc_state *plc) in to_plc_state() argument
685 CTYPES_CHECK("plc", obj && PyDict_Check(obj)); in to_plc_state()
688 PyDict_GetItemString(obj, "seed"), NPY_UINT16, &plc->seed)); in to_plc_state()
691 PyDict_GetItemString(obj, "count"), NPY_INT, &plc->count)); in to_plc_state()
694 PyDict_GetItemString(obj, "alpha"), NPY_FLOAT, &plc->alpha)); in to_plc_state()
696 return obj; in to_plc_state()
700 static PyObject *from_encoder(PyObject *obj, const struct lc3_encoder *enc) in from_encoder() argument
708 if (!obj) obj = PyDict_New(); in from_encoder()
710 PyDict_SetItemString(obj, "dt", in from_encoder()
713 PyDict_SetItemString(obj, "sr", in from_encoder()
716 PyDict_SetItemString(obj, "sr_pcm", in from_encoder()
719 PyDict_SetItemString(obj, "attdet", in from_encoder()
722 PyDict_SetItemString(obj, "ltpf", in from_encoder()
725 PyDict_SetItemString(obj, "quant", in from_encoder()
728 PyDict_SetItemString(obj, "xt", in from_encoder()
732 PyDict_SetItemString(obj, "xs", in from_encoder()
735 PyDict_SetItemString(obj, "xd", in from_encoder()
738 return obj; in from_encoder()
742 static PyObject *to_encoder(PyObject *obj, struct lc3_encoder *enc) in to_encoder() argument
747 CTYPES_CHECK("encoder", obj && PyDict_Check(obj)); in to_encoder()
750 PyDict_GetItemString(obj, "dt"), NPY_INT, &dt)); in to_encoder()
754 PyDict_GetItemString(obj, "sr"), NPY_INT, &sr)); in to_encoder()
758 PyDict_GetItemString(obj, "sr_pcm"), NPY_INT, &sr_pcm)); in to_encoder()
767 PyDict_GetItemString(obj, "attdet"), &enc->attdet)); in to_encoder()
770 PyDict_GetItemString(obj, "ltpf"), &enc->ltpf)); in to_encoder()
773 PyDict_GetItemString(obj, "quant"), &enc->spec)); in to_encoder()
776 PyDict_GetItemString(obj, "xt"), NPY_INT16, in to_encoder()
778 PyDict_SetItemString(obj, "xt", xt_obj); in to_encoder()
781 PyDict_GetItemString(obj, "xs"), NPY_FLOAT, in to_encoder()
783 PyDict_SetItemString(obj, "xs", xs_obj); in to_encoder()
786 PyDict_GetItemString(obj, "xd"), NPY_FLOAT, in to_encoder()
788 PyDict_SetItemString(obj, "xd", xd_obj); in to_encoder()
790 return obj; in to_encoder()
794 static PyObject *from_decoder(PyObject *obj, const struct lc3_decoder *dec) in from_decoder() argument
803 if (!obj) obj = PyDict_New(); in from_decoder()
805 PyDict_SetItemString(obj, "dt", in from_decoder()
808 PyDict_SetItemString(obj, "sr", in from_decoder()
811 PyDict_SetItemString(obj, "sr_pcm", in from_decoder()
814 PyDict_SetItemString(obj, "ltpf", in from_decoder()
817 PyDict_SetItemString(obj, "plc", in from_decoder()
820 PyDict_SetItemString(obj, "xh", in from_decoder()
823 PyDict_SetItemString(obj, "xs_pos", in from_decoder()
826 PyDict_SetItemString(obj, "xd", in from_decoder()
829 PyDict_SetItemString(obj, "xg", in from_decoder()
832 return obj; in from_decoder()
836 static PyObject *to_decoder(PyObject *obj, struct lc3_decoder *dec) in to_decoder() argument
841 CTYPES_CHECK("decoder", obj && PyDict_Check(obj)); in to_decoder()
844 PyDict_GetItemString(obj, "dt"), NPY_INT, &dt)); in to_decoder()
848 PyDict_GetItemString(obj, "sr"), NPY_INT, &sr)); in to_decoder()
852 PyDict_GetItemString(obj, "sr_pcm"), NPY_INT, &sr_pcm)); in to_decoder()
861 PyDict_GetItemString(obj, "ltpf"), &dec->ltpf)); in to_decoder()
864 PyDict_GetItemString(obj, "plc"), &dec->plc)); in to_decoder()
867 PyDict_GetItemString(obj, "xh"), NPY_FLOAT, in to_decoder()
869 PyDict_SetItemString(obj, "xh", xh_obj); in to_decoder()
872 PyDict_GetItemString(obj, "xs_pos"), NPY_INT, &xs_pos)); in to_decoder()
876 PyDict_GetItemString(obj, "xd"), NPY_FLOAT, in to_decoder()
878 PyDict_SetItemString(obj, "xd", xd_obj); in to_decoder()
881 PyDict_GetItemString(obj, "xg"), NPY_FLOAT, in to_decoder()
883 PyDict_SetItemString(obj, "xg", xg_obj); in to_decoder()
885 return obj; in to_decoder()