codec/subtitle: support empty rects
This commit is contained in:
parent
d5b024dea9
commit
e48ee1e3eb
@ -108,26 +108,27 @@ impl<'a> Iterator for RectIter<'a> {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self.cur += 1;
|
self.cur += 1;
|
||||||
Rect::wrap(*(*self.ptr).rects.offset((self.cur - 1) as isize))
|
Some(Rect::wrap(*(*self.ptr).rects.offset((self.cur - 1) as isize)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Rect<'a> {
|
pub enum Rect<'a> {
|
||||||
|
None,
|
||||||
Bitmap(Bitmap<'a>),
|
Bitmap(Bitmap<'a>),
|
||||||
Text(Text<'a>),
|
Text(Text<'a>),
|
||||||
Ass(Ass<'a>),
|
Ass(Ass<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Rect<'a> {
|
impl<'a> Rect<'a> {
|
||||||
pub fn wrap(ptr: *mut AVSubtitleRect) -> Option<Self> {
|
pub fn wrap(ptr: *mut AVSubtitleRect) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
match Type::from((*ptr).kind) {
|
match Type::from((*ptr).kind) {
|
||||||
Type::None => None,
|
Type::None => Rect::None,
|
||||||
Type::Bitmap => Some(Rect::Bitmap(Bitmap::wrap(ptr))),
|
Type::Bitmap => Rect::Bitmap(Bitmap::wrap(ptr)),
|
||||||
Type::Text => Some(Rect::Text(Text::wrap(ptr))),
|
Type::Text => Rect::Text(Text::wrap(ptr)),
|
||||||
Type::Ass => Some(Rect::Ass(Ass::wrap(ptr)))
|
Type::Ass => Rect::Ass(Ass::wrap(ptr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +136,7 @@ impl<'a> Rect<'a> {
|
|||||||
pub fn flags(&self) -> Flags {
|
pub fn flags(&self) -> Flags {
|
||||||
unsafe {
|
unsafe {
|
||||||
Flags::from_bits_truncate(match self {
|
Flags::from_bits_truncate(match self {
|
||||||
|
&Rect::None => 0,
|
||||||
&Rect::Bitmap(ref b) => (*b.ptr).flags,
|
&Rect::Bitmap(ref b) => (*b.ptr).flags,
|
||||||
&Rect::Text(ref t) => (*t.ptr).flags,
|
&Rect::Text(ref t) => (*t.ptr).flags,
|
||||||
&Rect::Ass(ref a) => (*a.ptr).flags
|
&Rect::Ass(ref a) => (*a.ptr).flags
|
||||||
|
Loading…
x
Reference in New Issue
Block a user