mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-04-16 04:44:06 +00:00
analytics: Remove batch_size and TensorDim as they're gone from Gst
We removed those from the API. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1632>
This commit is contained in:
parent
a6e7c1a237
commit
3f8fc9e9e9
3 changed files with 11 additions and 43 deletions
|
@ -3,26 +3,6 @@
|
|||
use crate::ffi;
|
||||
use crate::*;
|
||||
use glib::translate::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct TensorDim {
|
||||
pub size: usize,
|
||||
pub order_index: usize,
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::translate::ToGlibPtrMut<'a, *mut ffi::GstTensorDim> for TensorDim {
|
||||
type Storage = PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(
|
||||
&'a mut self,
|
||||
) -> glib::translate::StashMut<'a, *mut ffi::GstTensorDim, Self> {
|
||||
glib::translate::StashMut(self as *mut _ as *mut _, PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -44,7 +24,6 @@ impl Tensor {
|
|||
pub fn new_simple(
|
||||
id: glib::Quark,
|
||||
data_type: TensorDataType,
|
||||
batch_size: usize,
|
||||
data: gst::Buffer,
|
||||
dims_order: TensorDimOrder,
|
||||
dims: &[usize],
|
||||
|
@ -54,7 +33,6 @@ impl Tensor {
|
|||
from_glib_full(ffi::gst_tensor_new_simple(
|
||||
id.into_glib(),
|
||||
data_type.into_glib(),
|
||||
batch_size,
|
||||
data.into_glib_ptr(),
|
||||
dims_order.into_glib(),
|
||||
dims.len(),
|
||||
|
@ -65,7 +43,7 @@ impl Tensor {
|
|||
|
||||
#[doc(alias = "gst_tensor_get_dims")]
|
||||
#[doc(alias = "get_dims")]
|
||||
pub fn dims(&self) -> &[TensorDim] {
|
||||
pub fn dims(&self) -> &[usize] {
|
||||
let mut num_dims: usize = 0;
|
||||
unsafe {
|
||||
let dims = ffi::gst_tensor_get_dims(self.as_ptr(), &mut num_dims);
|
||||
|
@ -83,11 +61,6 @@ impl Tensor {
|
|||
unsafe { from_glib(self.inner.data_type) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn batch_size(&self) -> usize {
|
||||
self.inner.batch_size
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn data(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.inner.data) }
|
||||
|
@ -115,13 +88,12 @@ mod tests {
|
|||
fn create_tensor() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let buf = gst::Buffer::with_size(2 * 2 * 3 * 4 * 5).unwrap();
|
||||
assert_eq!(buf.size(), 2 * 2 * 3 * 4 * 5);
|
||||
let buf = gst::Buffer::with_size(2 * 3 * 4 * 5).unwrap();
|
||||
assert_eq!(buf.size(), 2 * 3 * 4 * 5);
|
||||
|
||||
let mut tensor = Tensor::new_simple(
|
||||
glib::Quark::from_str("me"),
|
||||
TensorDataType::Int16,
|
||||
2,
|
||||
buf,
|
||||
TensorDimOrder::RowMajor,
|
||||
&[3, 4, 5],
|
||||
|
@ -129,12 +101,11 @@ mod tests {
|
|||
|
||||
assert_eq!(tensor.id(), glib::Quark::from_str("me"));
|
||||
assert_eq!(tensor.data_type(), TensorDataType::Int16);
|
||||
assert_eq!(tensor.batch_size(), 2);
|
||||
assert_eq!(tensor.dims_order(), TensorDimOrder::RowMajor);
|
||||
assert_eq!(tensor.dims()[0].size, 3);
|
||||
assert_eq!(tensor.dims()[1].size, 4);
|
||||
assert_eq!(tensor.dims()[2].size, 5);
|
||||
assert_eq!(tensor.data().size(), 2 * 2 * 3 * 4 * 5);
|
||||
assert_eq!(tensor.dims()[0], 3);
|
||||
assert_eq!(tensor.dims()[1], 4);
|
||||
assert_eq!(tensor.dims()[2], 5);
|
||||
assert_eq!(tensor.data().size(), 2 * 3 * 4 * 5);
|
||||
|
||||
tensor.data();
|
||||
tensor.data_mut();
|
||||
|
|
|
@ -74,8 +74,7 @@ mod tests {
|
|||
let tensor = Tensor::new_simple(
|
||||
glib::Quark::from_str("me"),
|
||||
TensorDataType::Int16,
|
||||
2,
|
||||
gst::Buffer::with_size(2 * 2 * 3 * 4 * 5).unwrap(),
|
||||
gst::Buffer::with_size(2 * 3 * 4 * 5).unwrap(),
|
||||
TensorDimOrder::RowMajor,
|
||||
&[3, 4, 5],
|
||||
);
|
||||
|
@ -92,7 +91,7 @@ mod tests {
|
|||
assert_eq!(tptr, tensors[0].as_ptr());
|
||||
assert_eq!(tensors[0].dims_order(), TensorDimOrder::RowMajor);
|
||||
assert_eq!(tensors[0].dims().len(), 3);
|
||||
assert_eq!(tensors[0].dims()[0].size, 3);
|
||||
assert_eq!(tensors[0].dims()[0], 3);
|
||||
|
||||
assert_eq!(tmeta.as_slice().len(), 1);
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use gstreamer_sys as gst_sys;
|
||||
use libc::size_t;
|
||||
|
||||
use crate::{GstTensorDataType, GstTensorDim, GstTensorDimOrder, GstTensorLayout};
|
||||
use crate::{GstTensorDataType, GstTensorDimOrder, GstTensorLayout};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct GstTensor {
|
||||
pub id: glib_sys::GQuark,
|
||||
pub layout: GstTensorLayout,
|
||||
pub data_type: GstTensorDataType,
|
||||
pub batch_size: size_t,
|
||||
pub data: *mut gst_sys::GstBuffer,
|
||||
pub dims_order: GstTensorDimOrder,
|
||||
pub num_dims: size_t,
|
||||
pub dims: [GstTensorDim; 0],
|
||||
pub dims: [size_t; 0],
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for GstTensor {
|
||||
|
@ -21,7 +20,6 @@ impl ::std::fmt::Debug for GstTensor {
|
|||
.field("id", &self.id)
|
||||
.field("layout", &self.layout)
|
||||
.field("data_type", &self.data_type)
|
||||
.field("batch_size", &self.batch_size)
|
||||
.field("data", &self.data)
|
||||
.field("dims_order", &self.dims_order)
|
||||
.field("num_dims", &self.num_dims)
|
||||
|
|
Loading…
Reference in a new issue