pub fn get_height(&self) -> usize { self.height as usize }
pub fn is_flipped(&self) -> bool { self.flipped }
pub fn get_format(&self) -> NAPixelFormaton { self.format }
+ pub fn set_width(&mut self, w: usize) { self.width = w; }
+ pub fn set_height(&mut self, h: usize) { self.height = h; }
}
impl fmt::Display for NAVideoInfo {
pub fn alloc_audio_buffer(ainfo: NAAudioInfo, nsamples: usize, chmap: NAChannelMap) -> Result<NABufferType, AllocatorError> {
let mut offs: Vec<usize> = Vec::new();
- if ainfo.format.is_planar() {
+ if ainfo.format.is_planar() || (ainfo.channels == 1 && (ainfo.format.get_bits() % 8) == 0) {
let len = nsamples.checked_mul(ainfo.channels as usize);
if len == None { return Err(AllocatorError::TooLargeDimensions); }
let length = len.unwrap();
let mut data: Vec<u8> = Vec::with_capacity(length);
data.resize(length, 0);
let buf: NAAudioBuffer<u8> = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap, len: nsamples };
- Ok(NABufferType::AudioPacked(buf))
+ Ok(NABufferType::AudioPacked(buf))
}
}