util/frame: handle unknown format case

This commit is contained in:
meh 2015-05-12 19:21:13 +02:00
parent 72025673c9
commit 05921ce5d8

View File

@ -141,7 +141,12 @@ impl Audio {
pub fn format(&self) -> SampleFormat { pub fn format(&self) -> SampleFormat {
unsafe { unsafe {
SampleFormat::from(mem::transmute::<_, AVSampleFormat>(((*self.ptr).format))) if (*self.ptr).format == -1 {
SampleFormat::None
}
else {
SampleFormat::from(mem::transmute::<_, AVSampleFormat>(((*self.ptr).format)))
}
} }
} }
@ -219,7 +224,12 @@ impl Video {
pub fn format(&self) -> PixelFormat { pub fn format(&self) -> PixelFormat {
unsafe { unsafe {
PixelFormat::from(mem::transmute::<_, AVPixelFormat>(((*self.ptr).format))) if (*self.ptr).format == -1 {
PixelFormat::None
}
else {
PixelFormat::from(mem::transmute::<_, AVPixelFormat>(((*self.ptr).format)))
}
} }
} }