use frame buffers with codec-specific type of data
[nihav.git] / src / frame.rs
1 use std::cmp::max;
2 use std::collections::HashMap;
3 use std::fmt;
4 use std::rc::Rc;
5 use std::cell::*;
6 use formats::*;
7
8 #[allow(dead_code)]
9 #[derive(Clone,Copy,PartialEq)]
10 pub struct NAAudioInfo {
11 sample_rate: u32,
12 channels: u8,
13 format: NASoniton,
14 block_len: usize,
15 }
16
17 impl NAAudioInfo {
18 pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self {
19 NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl }
20 }
21 pub fn get_sample_rate(&self) -> u32 { self.sample_rate }
22 pub fn get_channels(&self) -> u8 { self.channels }
23 pub fn get_format(&self) -> NASoniton { self.format }
24 pub fn get_block_len(&self) -> usize { self.block_len }
25 }
26
27 impl fmt::Display for NAAudioInfo {
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29 write!(f, "{} Hz, {} ch", self.sample_rate, self.channels)
30 }
31 }
32
33 #[allow(dead_code)]
34 #[derive(Clone,Copy,PartialEq)]
35 pub struct NAVideoInfo {
36 width: usize,
37 height: usize,
38 flipped: bool,
39 format: NAPixelFormaton,
40 }
41
42 impl NAVideoInfo {
43 pub fn new(w: usize, h: usize, flip: bool, fmt: NAPixelFormaton) -> Self {
44 NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
45 }
46 pub fn get_width(&self) -> usize { self.width as usize }
47 pub fn get_height(&self) -> usize { self.height as usize }
48 pub fn is_flipped(&self) -> bool { self.flipped }
49 pub fn get_format(&self) -> NAPixelFormaton { self.format }
50 }
51
52 impl fmt::Display for NAVideoInfo {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 write!(f, "{}x{}", self.width, self.height)
55 }
56 }
57
58 #[derive(Clone,Copy,PartialEq)]
59 pub enum NACodecTypeInfo {
60 None,
61 Audio(NAAudioInfo),
62 Video(NAVideoInfo),
63 }
64
65 impl NACodecTypeInfo {
66 pub fn get_video_info(&self) -> Option<NAVideoInfo> {
67 match *self {
68 NACodecTypeInfo::Video(vinfo) => Some(vinfo),
69 _ => None,
70 }
71 }
72 pub fn get_audio_info(&self) -> Option<NAAudioInfo> {
73 match *self {
74 NACodecTypeInfo::Audio(ainfo) => Some(ainfo),
75 _ => None,
76 }
77 }
78 }
79
80 impl fmt::Display for NACodecTypeInfo {
81 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
82 let ret = match *self {
83 NACodecTypeInfo::None => format!(""),
84 NACodecTypeInfo::Audio(fmt) => format!("{}", fmt),
85 NACodecTypeInfo::Video(fmt) => format!("{}", fmt),
86 };
87 write!(f, "{}", ret)
88 }
89 }
90
91 pub type BufferRef = Rc<RefCell<Vec<u8>>>;
92
93 #[allow(dead_code)]
94 #[derive(Clone)]
95 pub struct NABuffer {
96 id: u64,
97 data: BufferRef,
98 }
99
100 impl Drop for NABuffer {
101 fn drop(&mut self) { }
102 }
103
104 impl NABuffer {
105 pub fn get_data(&self) -> Ref<Vec<u8>> { self.data.borrow() }
106 pub fn get_data_mut(&mut self) -> RefMut<Vec<u8>> { self.data.borrow_mut() }
107 }
108
109 pub type NABufferRefT<T> = Rc<RefCell<Vec<T>>>;
110 pub type NABufferRef = Rc<RefCell<NABuffer>>;
111
112 #[derive(Clone)]
113 pub struct NAVideoBuffer<T> {
114 info: NAVideoInfo,
115 data: NABufferRefT<T>,
116 offs: Vec<usize>,
117 }
118
119 impl<T: Clone> NAVideoBuffer<T> {
120 pub fn get_offset(&self, idx: usize) -> usize {
121 if idx >= self.offs.len() { 0 }
122 else { self.offs[idx] }
123 }
124 pub fn get_info(&self) -> NAVideoInfo { self.info }
125 pub fn get_data(&self) -> Ref<Vec<T>> { self.data.borrow() }
126 pub fn get_data_mut(&mut self) -> RefMut<Vec<T>> { self.data.borrow_mut() }
127 pub fn copy_buffer(&mut self) -> Self {
128 let mut data: Vec<T> = Vec::with_capacity(self.data.borrow().len());
129 data.clone_from(self.data.borrow().as_ref());
130 let mut offs: Vec<usize> = Vec::with_capacity(self.offs.len());
131 offs.clone_from(&self.offs);
132 NAVideoBuffer { info: self.info, data: Rc::new(RefCell::new(data)), offs: offs }
133 }
134 pub fn get_stride(&self, idx: usize) -> usize {
135 if idx >= self.info.get_format().get_num_comp() { return 0; }
136 self.info.get_format().get_chromaton(idx).unwrap().get_linesize(self.info.get_width())
137 }
138 pub fn get_dimensions(&self, idx: usize) -> (usize, usize) {
139 get_plane_size(&self.info, idx)
140 }
141 }
142
143 #[derive(Clone)]
144 pub struct NAAudioBuffer<T> {
145 info: NAAudioInfo,
146 data: NABufferRefT<T>,
147 offs: Vec<usize>,
148 chmap: NAChannelMap,
149 }
150
151 impl<T: Clone> NAAudioBuffer<T> {
152 pub fn get_offset(&self, idx: usize) -> usize {
153 if idx >= self.offs.len() { 0 }
154 else { self.offs[idx] }
155 }
156 pub fn get_info(&self) -> NAAudioInfo { self.info }
157 pub fn get_chmap(&self) -> NAChannelMap { self.chmap.clone() }
158 pub fn get_data(&self) -> Ref<Vec<T>> { self.data.borrow() }
159 pub fn get_data_mut(&mut self) -> RefMut<Vec<T>> { self.data.borrow_mut() }
160 pub fn copy_buffer(&mut self) -> Self {
161 let mut data: Vec<T> = Vec::with_capacity(self.data.borrow().len());
162 data.clone_from(self.data.borrow().as_ref());
163 let mut offs: Vec<usize> = Vec::with_capacity(self.offs.len());
164 offs.clone_from(&self.offs);
165 NAAudioBuffer { info: self.info, data: Rc::new(RefCell::new(data)), offs: offs, chmap: self.get_chmap() }
166 }
167 }
168
169 #[derive(Clone)]
170 pub enum NABufferType {
171 Video (NAVideoBuffer<u8>),
172 Video16 (NAVideoBuffer<u16>),
173 VideoPacked(NAVideoBuffer<u8>),
174 AudioU8 (NAAudioBuffer<u8>),
175 AudioI16 (NAAudioBuffer<i16>),
176 AudioF32 (NAAudioBuffer<f32>),
177 AudioPacked(NAAudioBuffer<u8>),
178 Data (NABufferRefT<u8>),
179 None,
180 }
181
182 impl NABufferType {
183 pub fn get_offset(&self, idx: usize) -> usize {
184 match *self {
185 NABufferType::Video(ref vb) => vb.get_offset(idx),
186 NABufferType::Video16(ref vb) => vb.get_offset(idx),
187 NABufferType::VideoPacked(ref vb) => vb.get_offset(idx),
188 NABufferType::AudioU8(ref ab) => ab.get_offset(idx),
189 NABufferType::AudioI16(ref ab) => ab.get_offset(idx),
190 NABufferType::AudioF32(ref ab) => ab.get_offset(idx),
191 NABufferType::AudioPacked(ref ab) => ab.get_offset(idx),
192 _ => 0,
193 }
194 }
195 pub fn get_vbuf(&mut self) -> Option<NAVideoBuffer<u8>> {
196 match *self {
197 NABufferType::Video(ref vb) => Some(vb.clone()),
198 _ => None,
199 }
200 }
201 }
202
203 #[derive(Debug,Clone,Copy,PartialEq)]
204 pub enum AllocatorError {
205 TooLargeDimensions,
206 FormatError,
207 }
208
209 pub fn alloc_video_buffer(vinfo: NAVideoInfo, align: u8) -> Result<NABufferType, AllocatorError> {
210 let fmt = &vinfo.format;
211 let mut new_size: usize = 0;
212 let mut offs: Vec<usize> = Vec::new();
213
214 for i in 0..fmt.get_num_comp() {
215 if fmt.get_chromaton(i) == None { return Err(AllocatorError::FormatError); }
216 }
217
218 let align_mod = ((1 << align) as usize) - 1;
219 let width = ((vinfo.width as usize) + align_mod) & !align_mod;
220 let height = ((vinfo.height as usize) + align_mod) & !align_mod;
221 let mut max_depth = 0;
222 let mut all_packed = true;
223 for i in 0..fmt.get_num_comp() {
224 let chr = fmt.get_chromaton(i).unwrap();
225 if !chr.is_packed() {
226 all_packed = false;
227 break;
228 }
229 max_depth = max(max_depth, chr.get_depth());
230 }
231
232 //todo semi-packed like NV12
233 if !all_packed {
234 for i in 0..fmt.get_num_comp() {
235 let chr = fmt.get_chromaton(i).unwrap();
236 if !vinfo.is_flipped() {
237 offs.push(new_size as usize);
238 }
239 let cur_w = chr.get_width(width);
240 let cur_h = chr.get_height(height);
241 let cur_sz = cur_w.checked_mul(cur_h);
242 if cur_sz == None { return Err(AllocatorError::TooLargeDimensions); }
243 let new_sz = new_size.checked_add(cur_sz.unwrap());
244 if new_sz == None { return Err(AllocatorError::TooLargeDimensions); }
245 new_size = new_sz.unwrap();
246 if vinfo.is_flipped() {
247 offs.push(new_size as usize);
248 }
249 }
250 if max_depth <= 8 {
251 let mut data: Vec<u8> = Vec::with_capacity(new_size);
252 data.resize(new_size, 0);
253 let buf: NAVideoBuffer<u8> = NAVideoBuffer { data: Rc::new(RefCell::new(data)), info: vinfo, offs: offs };
254 Ok(NABufferType::Video(buf))
255 } else {
256 let mut data: Vec<u16> = Vec::with_capacity(new_size);
257 data.resize(new_size, 0);
258 let buf: NAVideoBuffer<u16> = NAVideoBuffer { data: Rc::new(RefCell::new(data)), info: vinfo, offs: offs };
259 Ok(NABufferType::Video16(buf))
260 }
261 } else {
262 let elem_sz = fmt.get_elem_size();
263 let line_sz = width.checked_mul(elem_sz as usize);
264 if line_sz == None { return Err(AllocatorError::TooLargeDimensions); }
265 let new_sz = line_sz.unwrap().checked_mul(height);
266 if new_sz == None { return Err(AllocatorError::TooLargeDimensions); }
267 new_size = new_sz.unwrap();
268 let mut data: Vec<u8> = Vec::with_capacity(new_size);
269 data.resize(new_size, 0);
270 let buf: NAVideoBuffer<u8> = NAVideoBuffer { data: Rc::new(RefCell::new(data)), info: vinfo, offs: offs };
271 Ok(NABufferType::VideoPacked(buf))
272 }
273 }
274
275 pub fn alloc_audio_buffer(ainfo: NAAudioInfo, nsamples: usize, chmap: NAChannelMap) -> Result<NABufferType, AllocatorError> {
276 let mut offs: Vec<usize> = Vec::new();
277 if ainfo.format.is_planar() {
278 let len = nsamples.checked_mul(ainfo.channels as usize);
279 if len == None { return Err(AllocatorError::TooLargeDimensions); }
280 let length = len.unwrap();
281 for i in 0..ainfo.channels {
282 offs.push((i as usize) * nsamples);
283 }
284 if ainfo.format.is_float() {
285 if ainfo.format.get_bits() == 32 {
286 let mut data: Vec<f32> = Vec::with_capacity(length);
287 data.resize(length, 0.0);
288 let buf: NAAudioBuffer<f32> = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap };
289 Ok(NABufferType::AudioF32(buf))
290 } else {
291 Err(AllocatorError::TooLargeDimensions)
292 }
293 } else {
294 if ainfo.format.get_bits() == 8 && !ainfo.format.is_signed() {
295 let mut data: Vec<u8> = Vec::with_capacity(length);
296 data.resize(length, 0);
297 let buf: NAAudioBuffer<u8> = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap };
298 Ok(NABufferType::AudioU8(buf))
299 } else if ainfo.format.get_bits() == 16 && ainfo.format.is_signed() {
300 let mut data: Vec<i16> = Vec::with_capacity(length);
301 data.resize(length, 0);
302 let buf: NAAudioBuffer<i16> = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap };
303 Ok(NABufferType::AudioI16(buf))
304 } else {
305 Err(AllocatorError::TooLargeDimensions)
306 }
307 }
308 } else {
309 let len = nsamples.checked_mul(ainfo.channels as usize);
310 if len == None { return Err(AllocatorError::TooLargeDimensions); }
311 let length = ainfo.format.get_audio_size(len.unwrap() as u64);
312 let mut data: Vec<u8> = Vec::with_capacity(length);
313 data.resize(length, 0);
314 let buf: NAAudioBuffer<u8> = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap };
315 Ok(NABufferType::AudioPacked(buf))
316 }
317 }
318
319 pub fn alloc_data_buffer(size: usize) -> Result<NABufferType, AllocatorError> {
320 let mut data: Vec<u8> = Vec::with_capacity(size);
321 data.resize(size, 0);
322 let buf: NABufferRefT<u8> = Rc::new(RefCell::new(data));
323 Ok(NABufferType::Data(buf))
324 }
325
326 pub fn copy_buffer(buf: NABufferType) -> NABufferType {
327 buf.clone()
328 }
329
330 #[allow(dead_code)]
331 #[derive(Clone)]
332 pub struct NACodecInfo {
333 name: &'static str,
334 properties: NACodecTypeInfo,
335 extradata: Option<Rc<Vec<u8>>>,
336 }
337
338 impl NACodecInfo {
339 pub fn new(name: &'static str, p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
340 let extradata = match edata {
341 None => None,
342 Some(vec) => Some(Rc::new(vec)),
343 };
344 NACodecInfo { name: name, properties: p, extradata: extradata }
345 }
346 pub fn new_ref(name: &'static str, p: NACodecTypeInfo, edata: Option<Rc<Vec<u8>>>) -> Self {
347 NACodecInfo { name: name, properties: p, extradata: edata }
348 }
349 pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
350 pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
351 if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
352 None
353 }
354 pub fn get_name(&self) -> &'static str { self.name }
355 pub fn is_video(&self) -> bool {
356 if let NACodecTypeInfo::Video(_) = self.properties { return true; }
357 false
358 }
359 pub fn is_audio(&self) -> bool {
360 if let NACodecTypeInfo::Audio(_) = self.properties { return true; }
361 false
362 }
363 }
364
365 impl fmt::Display for NACodecInfo {
366 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
367 let edata = match self.extradata.clone() {
368 None => format!("no extradata"),
369 Some(v) => format!("{} byte(s) of extradata", v.len()),
370 };
371 write!(f, "{}: {} {}", self.name, self.properties, edata)
372 }
373 }
374
375 pub const DUMMY_CODEC_INFO: NACodecInfo = NACodecInfo {
376 name: "none",
377 properties: NACodecTypeInfo::None,
378 extradata: None };
379
380 #[derive(Debug,Clone)]
381 pub enum NAValue {
382 None,
383 Int(i32),
384 Long(i64),
385 String(String),
386 Data(Rc<Vec<u8>>),
387 }
388
389 #[derive(Debug,Clone,Copy,PartialEq)]
390 #[allow(dead_code)]
391 pub enum FrameType {
392 I,
393 P,
394 B,
395 Other,
396 }
397
398 impl fmt::Display for FrameType {
399 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
400 match *self {
401 FrameType::I => write!(f, "I"),
402 FrameType::P => write!(f, "P"),
403 FrameType::B => write!(f, "B"),
404 FrameType::Other => write!(f, "x"),
405 }
406 }
407 }
408
409 #[allow(dead_code)]
410 #[derive(Clone)]
411 pub struct NAFrame {
412 pts: Option<u64>,
413 dts: Option<u64>,
414 duration: Option<u64>,
415 buffer: NABufferType,
416 info: Rc<NACodecInfo>,
417 ftype: FrameType,
418 key: bool,
419 options: HashMap<String, NAValue>,
420 }
421
422 pub type NAFrameRef = Rc<RefCell<NAFrame>>;
423
424 fn get_plane_size(info: &NAVideoInfo, idx: usize) -> (usize, usize) {
425 let chromaton = info.get_format().get_chromaton(idx);
426 if let None = chromaton { return (0, 0); }
427 let (hs, vs) = chromaton.unwrap().get_subsampling();
428 let w = (info.get_width() + ((1 << hs) - 1)) >> hs;
429 let h = (info.get_height() + ((1 << vs) - 1)) >> vs;
430 (w, h)
431 }
432
433 impl NAFrame {
434 pub fn new(pts: Option<u64>,
435 dts: Option<u64>,
436 duration: Option<u64>,
437 ftype: FrameType,
438 keyframe: bool,
439 info: Rc<NACodecInfo>,
440 options: HashMap<String, NAValue>,
441 buffer: NABufferType) -> Self {
442 NAFrame { pts: pts, dts: dts, duration: duration, buffer: buffer, info: info, ftype: ftype, key: keyframe, options: options }
443 }
444 pub fn get_pts(&self) -> Option<u64> { self.pts }
445 pub fn get_dts(&self) -> Option<u64> { self.dts }
446 pub fn get_duration(&self) -> Option<u64> { self.duration }
447 pub fn get_frame_type(&self) -> FrameType { self.ftype }
448 pub fn is_keyframe(&self) -> bool { self.key }
449 pub fn set_pts(&mut self, pts: Option<u64>) { self.pts = pts; }
450 pub fn set_dts(&mut self, dts: Option<u64>) { self.dts = dts; }
451 pub fn set_duration(&mut self, dur: Option<u64>) { self.duration = dur; }
452 pub fn set_frame_type(&mut self, ftype: FrameType) { self.ftype = ftype; }
453 pub fn set_keyframe(&mut self, key: bool) { self.key = key; }
454
455 pub fn get_buffer(&self) -> NABufferType { self.buffer.clone() }
456 }
457
458 impl fmt::Display for NAFrame {
459 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
460 let mut foo = format!("frame type {}", self.ftype);
461 if let Some(pts) = self.pts { foo = format!("{} pts {}", foo, pts); }
462 if let Some(dts) = self.dts { foo = format!("{} dts {}", foo, dts); }
463 if let Some(dur) = self.duration { foo = format!("{} duration {}", foo, dur); }
464 if self.key { foo = format!("{} kf", foo); }
465 write!(f, "[{}]", foo)
466 }
467 }
468
469 /// Possible stream types.
470 #[derive(Debug,Clone,Copy)]
471 #[allow(dead_code)]
472 pub enum StreamType {
473 /// video stream
474 Video,
475 /// audio stream
476 Audio,
477 /// subtitles
478 Subtitles,
479 /// any data stream (or might be an unrecognized audio/video stream)
480 Data,
481 /// nonexistent stream
482 None,
483 }
484
485 impl fmt::Display for StreamType {
486 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
487 match *self {
488 StreamType::Video => write!(f, "Video"),
489 StreamType::Audio => write!(f, "Audio"),
490 StreamType::Subtitles => write!(f, "Subtitles"),
491 StreamType::Data => write!(f, "Data"),
492 StreamType::None => write!(f, "-"),
493 }
494 }
495 }
496
497 #[allow(dead_code)]
498 #[derive(Clone)]
499 pub struct NAStream {
500 media_type: StreamType,
501 id: u32,
502 num: usize,
503 info: Rc<NACodecInfo>,
504 }
505
506 impl NAStream {
507 pub fn new(mt: StreamType, id: u32, info: NACodecInfo) -> Self {
508 NAStream { media_type: mt, id: id, num: 0, info: Rc::new(info) }
509 }
510 pub fn get_id(&self) -> u32 { self.id }
511 pub fn get_num(&self) -> usize { self.num }
512 pub fn set_num(&mut self, num: usize) { self.num = num; }
513 pub fn get_info(&self) -> Rc<NACodecInfo> { self.info.clone() }
514 }
515
516 impl fmt::Display for NAStream {
517 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
518 write!(f, "({}#{} - {})", self.media_type, self.id, self.info.get_properties())
519 }
520 }
521
522 #[allow(dead_code)]
523 pub struct NAPacket {
524 stream: Rc<NAStream>,
525 pts: Option<u64>,
526 dts: Option<u64>,
527 duration: Option<u64>,
528 buffer: Rc<Vec<u8>>,
529 keyframe: bool,
530 // options: HashMap<String, NAValue<'a>>,
531 }
532
533 impl NAPacket {
534 pub fn new(str: Rc<NAStream>, pts: Option<u64>, dts: Option<u64>, dur: Option<u64>, kf: bool, vec: Vec<u8>) -> Self {
535 // let mut vec: Vec<u8> = Vec::new();
536 // vec.resize(size, 0);
537 NAPacket { stream: str, pts: pts, dts: dts, duration: dur, keyframe: kf, buffer: Rc::new(vec) }
538 }
539 pub fn get_stream(&self) -> Rc<NAStream> { self.stream.clone() }
540 pub fn get_pts(&self) -> Option<u64> { self.pts }
541 pub fn get_dts(&self) -> Option<u64> { self.dts }
542 pub fn get_duration(&self) -> Option<u64> { self.duration }
543 pub fn is_keyframe(&self) -> bool { self.keyframe }
544 pub fn get_buffer(&self) -> Rc<Vec<u8>> { self.buffer.clone() }
545 }
546
547 impl Drop for NAPacket {
548 fn drop(&mut self) {}
549 }
550
551 impl fmt::Display for NAPacket {
552 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
553 let mut foo = format!("[pkt for {} size {}", self.stream, self.buffer.len());
554 if let Some(pts) = self.pts { foo = format!("{} pts {}", foo, pts); }
555 if let Some(dts) = self.dts { foo = format!("{} dts {}", foo, dts); }
556 if let Some(dur) = self.duration { foo = format!("{} duration {}", foo, dur); }
557 if self.keyframe { foo = format!("{} kf", foo); }
558 foo = foo + "]";
559 write!(f, "{}", foo)
560 }
561 }
562
563 pub trait FrameFromPacket {
564 fn new_from_pkt(pkt: &NAPacket, info: Rc<NACodecInfo>, buf: NABufferType) -> NAFrame;
565 fn fill_timestamps(&mut self, pkt: &NAPacket);
566 }
567
568 impl FrameFromPacket for NAFrame {
569 fn new_from_pkt(pkt: &NAPacket, info: Rc<NACodecInfo>, buf: NABufferType) -> NAFrame {
570 NAFrame::new(pkt.pts, pkt.dts, pkt.duration, FrameType::Other, pkt.keyframe, info, HashMap::new(), buf)
571 }
572 fn fill_timestamps(&mut self, pkt: &NAPacket) {
573 self.set_pts(pkt.pts);
574 self.set_dts(pkt.dts);
575 self.set_duration(pkt.duration);
576 }
577 }
578