]> git.sesse.net Git - vlc/blob - plugins/macosx/vout_macosx.m
Mac OS X-specific :
[vlc] / plugins / macosx / vout_macosx.m
1 /*****************************************************************************
2  * vout_macosx.c: MacOS X video output plugin
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  *
6  * Authors: Colin Delacroix <colin@zoy.org>
7  *          Florian G. Pflug <fgp@phlo.org>
8  *          Jon Lech Johansen <jon-vl@nanocrew.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <stdlib.h>                                                /* free() */
30 #include <string.h>                                            /* strerror() */
31 #include <mach/mach_init.h>
32 #include <mach/task_policy.h>
33 #include <mach/thread_act.h>
34 #include <mach/thread_policy.h>
35 #include <sys/sysctl.h>
36
37 #include <videolan/vlc.h>
38
39 #include "video.h"
40 #include "video_output.h"
41
42 #include "interface.h"
43
44 #include "macosx.h"
45
46 #define QT_MAX_DIRECTBUFFERS 10
47
48 typedef struct picture_sys_s
49 {
50     void *p_info;
51     unsigned int i_size;
52
53     /* When using I420 output */
54     PlanarPixmapInfoYUV420 pixmap_i420;
55
56 } picture_sys_t;
57
58 /*****************************************************************************
59  * Local prototypes
60  *****************************************************************************/
61 static int  vout_Create    ( struct vout_thread_s * );
62 static int  vout_Init      ( struct vout_thread_s * );
63 static void vout_End       ( struct vout_thread_s * );
64 static void vout_Destroy   ( struct vout_thread_s * );
65 static int  vout_Manage    ( struct vout_thread_s * );
66 static void vout_Render    ( struct vout_thread_s *, struct picture_s * );
67 static void vout_Display   ( struct vout_thread_s *, struct picture_s * );
68
69 static int  CoSendRequest      ( struct vout_thread_s *, long i_request );
70 static int  CoCreateWindow     ( struct vout_thread_s * );
71 static int  CoDestroyWindow    ( struct vout_thread_s * );
72 static int  CoToggleFullscreen ( struct vout_thread_s * );
73
74 static void QTScaleMatrix      ( struct vout_thread_s * );
75 static int  QTCreateSequence   ( struct vout_thread_s * );
76 static void QTDestroySequence  ( struct vout_thread_s * );
77 static int  QTNewPicture       ( struct vout_thread_s *, struct picture_s * );
78 static void QTFreePicture      ( struct vout_thread_s *, struct picture_s * );
79
80 /*****************************************************************************
81  * Functions exported as capabilities. They are declared as static so that
82  * we don't pollute the namespace too much.
83  *****************************************************************************/
84 void _M( vout_getfunctions )( function_list_t * p_function_list )
85 {
86     p_function_list->functions.vout.pf_create     = vout_Create;
87     p_function_list->functions.vout.pf_init       = vout_Init;
88     p_function_list->functions.vout.pf_end        = vout_End;
89     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
90     p_function_list->functions.vout.pf_manage     = vout_Manage;
91     p_function_list->functions.vout.pf_render     = vout_Render;
92     p_function_list->functions.vout.pf_display    = vout_Display;
93 }
94
95 /*****************************************************************************
96  * vout_Create: allocates MacOS X video thread output method
97  *****************************************************************************
98  * This function allocates and initializes a MacOS X vout method.
99  *****************************************************************************/
100 static int vout_Create( vout_thread_t *p_vout )
101 {
102     OSErr err;
103
104     if( !p_main->p_intf || !p_main->p_intf->p_module ||
105         strcmp( p_main->p_intf->p_module->psz_name, MODULE_STRING ) != 0 )
106     {
107         intf_ErrMsg( "vout error: MacOS X interface module required" );
108         return( 1 );
109     }
110
111     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
112     if( p_vout->p_sys == NULL )
113     {
114         intf_ErrMsg( "vout error: %s", strerror( ENOMEM ) );
115         return( 1 );
116     }
117
118     memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
119
120     p_vout->p_sys->h_img_descr = 
121         (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) );
122     p_vout->p_sys->p_matrix = (MatrixRecordPtr)malloc( sizeof(MatrixRecord) );
123
124     p_vout->p_sys->b_mouse_pointer_visible = 1;
125
126     /* set window size */
127     p_vout->p_sys->s_rect.size.width = p_vout->i_window_width;
128     p_vout->p_sys->s_rect.size.height = p_vout->i_window_height;
129
130     if( ( err = EnterMovies() ) != noErr )
131     {
132         intf_ErrMsg( "vout error: EnterMovies failed: %d", err );
133         free( p_vout->p_sys->p_matrix );
134         DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
135         free( p_vout->p_sys );
136         return( 1 );
137     } 
138
139     if( vout_ChromaCmp( p_vout->render.i_chroma, FOURCC_I420 ) )
140     {
141         err = FindCodec( kYUV420CodecType, bestSpeedCodec,
142                          nil, &p_vout->p_sys->img_dc );
143         if( err == noErr && p_vout->p_sys->img_dc != 0 )
144         {
145             p_vout->output.i_chroma = FOURCC_I420;
146             p_vout->p_sys->i_codec = kYUV420CodecType;
147         }
148         else
149         {
150             intf_ErrMsg( "vout error: failed to find an appropriate codec" );
151         }
152     }
153     else
154     {
155         intf_ErrMsg( "vout error: chroma 0x%08x not supported",
156                      p_vout->render.i_chroma );
157     }
158
159     if( p_vout->p_sys->img_dc == 0 )
160     {
161         free( p_vout->p_sys->p_matrix );
162         DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
163         free( p_vout->p_sys );
164         return( 1 );        
165     }
166
167     if( CoCreateWindow( p_vout ) )
168     {
169         intf_ErrMsg( "vout error: unable to create window" );
170         free( p_vout->p_sys->p_matrix );
171         DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
172         free( p_vout->p_sys ); 
173         return( 1 );
174     }
175
176     return( 0 );
177 }
178
179 /*****************************************************************************
180  * vout_Init: initialize video thread output method
181  *****************************************************************************/
182 static int vout_Init( vout_thread_t *p_vout )
183 {
184     int i_index;
185     picture_t *p_pic;
186
187     I_OUTPUTPICTURES = 0;
188
189     /* Initialize the output structure; we already found a codec,
190      * and the corresponding chroma we will be using. Since we can
191      * arbitrary scale, stick to the coordinates and aspect. */
192     p_vout->output.i_width  = p_vout->render.i_width;
193     p_vout->output.i_height = p_vout->render.i_height;
194     p_vout->output.i_aspect = p_vout->render.i_aspect;
195
196     SetPort( p_vout->p_sys->p_qdport );
197     QTScaleMatrix( p_vout );
198
199     if( QTCreateSequence( p_vout ) )
200     {
201         intf_ErrMsg( "vout error: unable to create sequence" );
202         return( 1 );
203     }
204
205     /* Try to initialize up to QT_MAX_DIRECTBUFFERS direct buffers */
206     while( I_OUTPUTPICTURES < QT_MAX_DIRECTBUFFERS )
207     {
208         p_pic = NULL;
209
210         /* Find an empty picture slot */
211         for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
212         {
213             if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
214             {
215                 p_pic = p_vout->p_picture + i_index;
216                 break;
217             }
218         }
219
220         /* Allocate the picture */
221         if( p_pic == NULL || QTNewPicture( p_vout, p_pic ) )
222         {
223             break;
224         }
225
226         p_pic->i_status = DESTROYED_PICTURE;
227         p_pic->i_type   = DIRECT_PICTURE;
228
229         PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
230
231         I_OUTPUTPICTURES++;
232     }
233
234     return( 0 );
235 }
236
237 /*****************************************************************************
238  * vout_End: terminate video thread output method
239  *****************************************************************************/
240 static void vout_End( vout_thread_t *p_vout )
241 {
242     int i_index;
243
244     QTDestroySequence( p_vout );
245
246     /* Free the direct buffers we allocated */
247     for( i_index = I_OUTPUTPICTURES; i_index; )
248     {
249         i_index--;
250         QTFreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );
251     }
252 }
253
254 /*****************************************************************************
255  * vout_Destroy: destroy video thread output method
256  *****************************************************************************/
257 static void vout_Destroy( vout_thread_t *p_vout )
258 {
259     if( CoDestroyWindow( p_vout ) )
260     {
261         intf_ErrMsg( "vout error: unable to destroy window" );
262     }
263
264     ExitMovies();
265
266     free( p_vout->p_sys->p_matrix );
267     DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
268     free( p_vout->p_sys );
269 }
270
271 /*****************************************************************************
272  * vout_Manage: handle events
273  *****************************************************************************
274  * This function should be called regularly by video output thread. It manages
275  * console events. It returns a non null value on error.
276  *****************************************************************************/
277 static int vout_Manage( vout_thread_t *p_vout )
278 {    
279     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
280     {
281         if( CoToggleFullscreen( p_vout ) )  
282         {
283             return( 1 );
284         }
285
286         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
287     }
288
289     if( p_vout->i_changes & VOUT_SIZE_CHANGE ) 
290     {
291         QTScaleMatrix( p_vout );
292         SetDSequenceMatrix( p_vout->p_sys->i_seq, 
293                             p_vout->p_sys->p_matrix );
294  
295         p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
296     }
297
298     /* hide/show mouse cursor */
299     if( p_vout->p_sys->b_mouse_moved ||
300         p_vout->p_sys->i_time_mouse_last_moved )
301     {
302         boolean_t b_change = 0;
303
304         if( !p_vout->p_sys->b_mouse_pointer_visible )
305         {
306             CGDisplayShowCursor( kCGDirectMainDisplay );
307             b_change = 1;
308         }
309 #if 0
310         else if( !p_vout->p_sys->b_mouse_moved && 
311             mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 &&
312             p_vout->p_sys->b_mouse_pointer_visible )
313         {
314             CGDisplayHideCursor( kCGDirectMainDisplay );
315             b_change = 1;
316         }
317 #endif
318
319         if( b_change )
320         {
321             p_vout->p_sys->i_time_mouse_last_moved = 0;
322             p_vout->p_sys->b_mouse_moved = 0;
323             p_vout->p_sys->b_mouse_pointer_visible =
324                 !p_vout->p_sys->b_mouse_pointer_visible;
325         }
326     }
327
328     return( 0 );
329 }
330
331 /*****************************************************************************
332  * vout_Render: render previously calculated output
333  *****************************************************************************/
334 static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
335 {
336     ;
337 }
338
339 /*****************************************************************************
340  * vout_Display: displays previously rendered output
341  *****************************************************************************
342  * This function sends the currently rendered image to the display.
343  *****************************************************************************/
344 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
345 {
346     OSErr err;
347     CodecFlags flags;
348
349     if( ( err = DecompressSequenceFrameS( 
350                     p_vout->p_sys->i_seq,
351                     p_pic->p_sys->p_info,
352                     p_pic->p_sys->i_size,                    
353                     codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
354     {
355         intf_ErrMsg( "DecompressSequenceFrameS failed: %d", err );
356     }
357 }
358
359 /*****************************************************************************
360  * CoSendRequest: send request to interface thread
361  *****************************************************************************
362  * Returns 0 on success, 1 otherwise
363  *****************************************************************************/
364 static int CoSendRequest( vout_thread_t *p_vout, long i_request )
365 {
366     NSArray *o_array;
367     NSPortMessage *o_msg;
368     struct vout_req_s req;
369     struct vout_req_s *p_req = &req;
370     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
371     NSPort *recvPort = [[NSPort port] retain];
372
373     memset( &req, 0, sizeof(req) );
374     req.i_type = i_request;
375     req.p_vout = p_vout;
376
377     req.o_lock = [[NSConditionLock alloc] initWithCondition: 0];
378
379     o_array = [NSArray arrayWithObject:
380         [NSData dataWithBytes: &p_req length: sizeof(void *)]];
381     o_msg = [[NSPortMessage alloc]
382         initWithSendPort: p_main->p_intf->p_sys->o_port
383         receivePort: recvPort
384         components: o_array];
385
386     [o_msg sendBeforeDate: [NSDate distantPast]];
387     [req.o_lock lockWhenCondition: 1];
388     [req.o_lock unlock];
389
390     [o_msg release];
391     [req.o_lock release];
392
393     [recvPort release];
394     [o_pool release];
395
396     return( !req.i_result );
397 }
398
399 /*****************************************************************************
400  * CoCreateWindow: create new window 
401  *****************************************************************************
402  * Returns 0 on success, 1 otherwise
403  *****************************************************************************/
404 static int CoCreateWindow( vout_thread_t *p_vout )
405 {
406     if( CoSendRequest( p_vout, VOUT_REQ_CREATE_WINDOW ) )
407     {
408         intf_ErrMsg( "CoSendRequest (CREATE_WINDOW) failed" );
409         return( 1 );
410     }
411
412     return( 0 );
413 }
414
415 /*****************************************************************************
416  * CoDestroyWindow: destroy window 
417  *****************************************************************************
418  * Returns 0 on success, 1 otherwise
419  *****************************************************************************/
420 static int CoDestroyWindow( vout_thread_t *p_vout )
421 {
422     if( !p_vout->p_sys->b_mouse_pointer_visible )
423     {
424         CGDisplayShowCursor( kCGDirectMainDisplay );
425         p_vout->p_sys->b_mouse_pointer_visible = 1;
426     }
427
428     if( CoSendRequest( p_vout, VOUT_REQ_DESTROY_WINDOW ) )
429     {
430         intf_ErrMsg( "CoSendRequest (DESTROY_WINDOW) failed" );
431         return( 1 );
432     }
433
434     return( 0 );
435 }
436
437 /*****************************************************************************
438  * CoToggleFullscreen: toggle fullscreen 
439  *****************************************************************************
440  * Returns 0 on success, 1 otherwise
441  *****************************************************************************/
442 static int CoToggleFullscreen( vout_thread_t *p_vout )
443 {
444     QTDestroySequence( p_vout );
445
446     if( CoDestroyWindow( p_vout ) )
447     {
448         intf_ErrMsg( "vout error: unable to destroy window" );
449         return( 1 );
450     }
451     
452     p_vout->b_fullscreen = !p_vout->b_fullscreen;
453
454     if( CoCreateWindow( p_vout ) )
455     {
456         intf_ErrMsg( "vout error: unable to create window" );
457         return( 1 );
458     }
459
460     SetPort( p_vout->p_sys->p_qdport );
461     QTScaleMatrix( p_vout );
462
463     if( QTCreateSequence( p_vout ) )
464     {
465         intf_ErrMsg( "vout error: unable to create sequence" );
466         return( 1 ); 
467     } 
468
469     return( 0 );
470 }
471
472 /*****************************************************************************
473  * QTScaleMatrix: scale matrix 
474  *****************************************************************************/
475 static void QTScaleMatrix( vout_thread_t *p_vout )
476 {
477     Rect s_rect;
478     int i_width, i_height;
479     Fixed factor_x, factor_y;
480     int i_offset_x = 0;
481     int i_offset_y = 0;
482
483     GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
484
485     i_width = s_rect.right - s_rect.left;
486     i_height = s_rect.bottom - s_rect.top;
487
488     if( i_height * p_vout->output.i_aspect < i_width * VOUT_ASPECT_FACTOR )
489     {
490         int i_adj_width = i_height * p_vout->output.i_aspect /
491                           VOUT_ASPECT_FACTOR;
492
493         factor_x = FixDiv( Long2Fix( i_adj_width ),
494                            Long2Fix( p_vout->output.i_width ) );
495         factor_y = FixDiv( Long2Fix( i_height ),
496                            Long2Fix( p_vout->output.i_height ) );
497
498         i_offset_x = (i_width - i_adj_width) / 2;
499     }
500     else
501     {
502         int i_adj_height = i_width * VOUT_ASPECT_FACTOR /
503                            p_vout->output.i_aspect;
504
505         factor_x = FixDiv( Long2Fix( i_width ),
506                            Long2Fix( p_vout->output.i_width ) );
507         factor_y = FixDiv( Long2Fix( i_adj_height ),
508                            Long2Fix( p_vout->output.i_height ) );
509
510         i_offset_y = (i_height - i_adj_height) / 2;
511     }
512
513     SetIdentityMatrix( p_vout->p_sys->p_matrix );
514
515     ScaleMatrix( p_vout->p_sys->p_matrix,
516                  factor_x, factor_y,
517                  Long2Fix(0), Long2Fix(0) );            
518
519     TranslateMatrix( p_vout->p_sys->p_matrix, 
520                      Long2Fix(i_offset_x), 
521                      Long2Fix(i_offset_y) );
522 }
523
524 /*****************************************************************************
525  * QTCreateSequence: create a new sequence 
526  *****************************************************************************
527  * Returns 0 on success, 1 otherwise
528  *****************************************************************************/
529 static int QTCreateSequence( vout_thread_t *p_vout )
530 {
531     OSErr err;
532     ImageDescriptionPtr p_descr;
533
534     HLock( (Handle)p_vout->p_sys->h_img_descr );
535     p_descr = *p_vout->p_sys->h_img_descr;
536
537     p_descr->idSize = sizeof(ImageDescription);
538     p_descr->cType = p_vout->p_sys->i_codec;
539     p_descr->version = 1;
540     p_descr->revisionLevel = 0;
541     p_descr->vendor = 'appl';
542     p_descr->width = p_vout->output.i_width;
543     p_descr->height = p_vout->output.i_height;
544     p_descr->hRes = Long2Fix(72);
545     p_descr->vRes = Long2Fix(72);
546     p_descr->spatialQuality = codecLosslessQuality;
547     p_descr->frameCount = 1;
548     p_descr->clutID = -1;
549     p_descr->dataSize = 0;
550     p_descr->depth = 12;
551
552     HUnlock( (Handle)p_vout->p_sys->h_img_descr );
553
554     if( ( err = DecompressSequenceBeginS( 
555                               &p_vout->p_sys->i_seq,
556                               p_vout->p_sys->h_img_descr,
557                               NULL, 0,
558                               p_vout->p_sys->p_qdport,
559                               NULL, NULL,
560                               p_vout->p_sys->p_matrix,
561                               0, NULL,
562                               codecFlagUseImageBuffer,
563                               codecLosslessQuality,
564                               p_vout->p_sys->img_dc ) ) )
565     {
566         intf_ErrMsg( "DecompressSequenceBeginS failed: %d", err );
567         return( 1 );
568     }
569
570     return( 0 );
571 }
572
573 /*****************************************************************************
574  * QTDestroySequence: destroy sequence 
575  *****************************************************************************/
576 static void QTDestroySequence( vout_thread_t *p_vout )
577 {
578     CDSequenceEnd( p_vout->p_sys->i_seq );
579 }
580
581 /*****************************************************************************
582  * QTNewPicture: allocate a picture
583  *****************************************************************************
584  * Returns 0 on success, 1 otherwise
585  *****************************************************************************/
586 static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
587 {
588     int i_width  = p_vout->output.i_width;
589     int i_height = p_vout->output.i_height;
590
591     /* We know the chroma, allocate a buffer which will be used
592      * directly by the decoder */
593     p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
594
595     if( p_pic->p_sys == NULL )
596     {
597         return( -1 );
598     }
599
600     switch( p_vout->output.i_chroma )
601     {
602         case FOURCC_I420:
603
604             p_pic->p_sys->p_info = (void *)&p_pic->p_sys->pixmap_i420;
605             p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);
606
607             /* Allocate the memory buffer */
608             p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
609                                           16, i_width * i_height * 3 / 2 );
610
611             /* Y buffer */
612             p_pic->Y_PIXELS = p_pic->p_data; 
613             p_pic->p[Y_PLANE].i_lines = i_height;
614             p_pic->p[Y_PLANE].i_pitch = i_width;
615             p_pic->p[Y_PLANE].i_pixel_bytes = 1;
616             p_pic->p[Y_PLANE].b_margin = 0;
617
618             /* U buffer */
619             p_pic->U_PIXELS = p_pic->Y_PIXELS + i_height * i_width;
620             p_pic->p[U_PLANE].i_lines = i_height / 2;
621             p_pic->p[U_PLANE].i_pitch = i_width / 2;
622             p_pic->p[U_PLANE].i_pixel_bytes = 1;
623             p_pic->p[U_PLANE].b_margin = 0;
624
625             /* V buffer */
626             p_pic->V_PIXELS = p_pic->U_PIXELS + i_height * i_width / 4;
627             p_pic->p[V_PLANE].i_lines = i_height / 2;
628             p_pic->p[V_PLANE].i_pitch = i_width / 2;
629             p_pic->p[V_PLANE].i_pixel_bytes = 1;
630             p_pic->p[V_PLANE].b_margin = 0;
631
632             /* We allocated 3 planes */
633             p_pic->i_planes = 3;
634
635 #define P p_pic->p_sys->pixmap_i420
636             P.componentInfoY.offset = (void *)p_pic->Y_PIXELS
637                                        - p_pic->p_sys->p_info;
638             P.componentInfoCb.offset = (void *)p_pic->U_PIXELS
639                                         - p_pic->p_sys->p_info;
640             P.componentInfoCr.offset = (void *)p_pic->V_PIXELS
641                                         - p_pic->p_sys->p_info;
642
643             P.componentInfoY.rowBytes = i_width;
644             P.componentInfoCb.rowBytes = i_width / 2;
645             P.componentInfoCr.rowBytes = i_width / 2;
646 #undef P
647
648             break;
649
650     default:
651         /* Unknown chroma, tell the guy to get lost */
652         free( p_pic->p_sys );
653         intf_ErrMsg( "vout error: never heard of chroma 0x%.8x (%4.4s)",
654                      p_vout->output.i_chroma, 
655                      (char*)&p_vout->output.i_chroma );
656         p_pic->i_planes = 0;
657         return( -1 );
658     }
659
660     return( 0 );
661 }
662
663 /*****************************************************************************
664  * QTFreePicture: destroy a picture allocated with QTNewPicture
665  *****************************************************************************/
666 static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
667 {
668     switch( p_vout->output.i_chroma )
669     {
670         case FOURCC_I420:
671             free( p_pic->p_data_orig );
672             break;
673     }
674
675     free( p_pic->p_sys );
676 }
677