struct { int aspect_ratio; // check change // public unsigned short cols; // nb of cols unsigned short rows; // nb or rows // private (??) used to compute addr (row,col) unsigned char * start_ptr; // point to the ( row, col ) == ( 0, 0 ) unsigned short height; // in lines unsigned short empty_rows; // in unused lines unsigned short width; // in bytes unsigned short empty_cols; // in unused bytes }viewport;void viewport_init ( );unsigned char * get_viewport_addr ( unsigned int col, unsigned int row );unsigned short get_viewport_luma ( unsigned int col, unsigned int row );unsigned short get_viewport_color ( unsigned int col, unsigned int row );
void viewport_init ( ) { int aspect_ratio; if ( ( aspect_ratio = shooting_get_prop(PROPCASE_ASPECT_RATIO) ) != viewport.aspect_ratio ) { viewport.aspect_ratio = aspect_ratio; viewport.cols = vid_get_viewport_width ( ); // nb of columns, in triplets viewport.rows = vid_get_viewport_height ( ); // nb of rows, in lines viewport.start_ptr = ( ( mode_get () & MODE_MASK ) == MODE_PLAY ) ? vid_get_viewport_fb_d () : ( ( kbd_is_key_pressed ( KEY_SHOOT_HALF ) ) ? vid_get_viewport_fb () : vid_get_viewport_live_fb () ); if ( viewport.start_ptr == NULL ) viewport.start_ptr = vid_get_viewport_fb (); viewport.empty_rows = vid_get_viewport_yoffset ( ); // upon camera aspect ratio, in lines viewport.height = viewport.rows + 2 * viewport.empty_rows; // nb of rows, in lines viewport.empty_cols = vid_get_viewport_xoffset ( ) * 3; // upon camera aspect ratio, in bytes viewport.width = vid_get_viewport_buffer_width ( ) * 3; // upon camera viewport buffer, in bytes viewport.start_ptr += ( viewport.empty_rows * viewport.width ) + viewport.empty_cols; // point to (row,col) == (0,0) } return;}unsigned char * get_viewport_addr ( unsigned int col, unsigned int row ) { row = ( row % viewport.rows ); col = ( col % viewport.cols ); return ( viewport.start_ptr + ( row * viewport.width ) + ( ( col >> 1 ) * 6 ) ); // point to (row, col >> 1) sixplet}unsigned short get_viewport_luma ( unsigned int col, unsigned int row ) { static const unsigned char col2pos [4] = { 1, 3, 5, 4 }; // convert Y position into byte position (Cb, Y1, Cr, Y2, Y4, Y3) unsigned char * addr = get_viewport_addr ( col, row ); unsigned int even_col = ( col % 2 ) << 1; return ( addr [ col2pos [even_col] ] << 8 ) | addr [ col2pos [even_col+1] ]; // ( Y1 << 8 | Y2 ) or ( Y3 << 8 | Y4 );}unsigned short get_viewport_color ( unsigned int col, unsigned int row ) { unsigned char * addr = get_viewport_addr ( col, row ); return ( addr [0] << 8 ) | addr [2]; // Cb << 8 | Cr;}
unsigned char * get_viewport_addr ( unsigned int col, unsigned int row ) { static int previous_aspect_ratio = -1; static unsigned char * start_ptr = NULL; static unsigned int buffer_width; int aspect_ratio; col = col % vid_get_viewport_width ( ); row = row % vid_get_viewport_height ( ); if ( ( aspect_ratio = shooting_get_prop ( PROPCASE_ASPECT_RATIO ) ) != previous_aspect_ratio ) { start_ptr = ( ( mode_get () & MODE_MASK ) == MODE_PLAY ) ? vid_get_viewport_fb_d () : ( ( kbd_is_key_pressed ( KEY_SHOOT_HALF ) ) ? vid_get_viewport_fb () : vid_get_viewport_live_fb () ); if ( start_ptr == NULL ) start_ptr = vid_get_viewport_fb (); buffer_width = ( vid_get_viewport_buffer_width ( ) * 3 ); previous_aspect_ratio = aspect_ratio; }; return ( start_ptr + ( row * buffer_width ) + ( ( col >> 1 ) * 6 ) ); // point to (row, col >> 1) sixplet}
Started by europanorama Microfunguy's Builds
Started by Cortexelus Script Writing
Started by Jeremy McGhie General Discussion and Assistance
Started by rkomar General Discussion and Assistance
Started by reyalp LUA Scripting