⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voutqt.m

📁 VLC Player Source Code
💻 M
📖 第 1 页 / 共 3 页
字号:
    }    else    {        int i_adj_height = i_width * p_vout->fmt_in.i_visible_height *                           p_vout->fmt_in.i_sar_den /                           ( p_vout->fmt_in.i_sar_num *                             p_vout->fmt_in.i_visible_width );        factor_x = FixDiv( Long2Fix( i_width ),                           Long2Fix( p_vout->fmt_in.i_visible_width ) );        factor_y = FixDiv( Long2Fix( i_adj_height ),                           Long2Fix( p_vout->fmt_in.i_visible_height ) );        i_offset_y = (i_height - i_adj_height) / 2;    }    SetIdentityMatrix( p_vout->p_sys->p_matrix );    ScaleMatrix( p_vout->p_sys->p_matrix,                 factor_x, factor_y,                 Long2Fix(0), Long2Fix(0) );    TranslateMatrix( p_vout->p_sys->p_matrix,                 Long2Fix(i_offset_x), Long2Fix(i_offset_y) );}/***************************************************************************** * QTCreateSequence: create a new sequence ***************************************************************************** * Returns 0 on success, 1 otherwise *****************************************************************************/static int QTCreateSequence( vout_thread_t *p_vout ){    OSErr err;    ImageDescriptionPtr p_descr;    HLock( (Handle)p_vout->p_sys->h_img_descr );    p_descr = *p_vout->p_sys->h_img_descr;    p_descr->idSize = sizeof(ImageDescription);    p_descr->cType = p_vout->p_sys->i_codec;    p_descr->version = 2;    p_descr->revisionLevel = 0;    p_descr->vendor = 'mpla';    p_descr->width = p_vout->output.i_width;    p_descr->height = p_vout->output.i_height;    p_descr->hRes = Long2Fix(72);    p_descr->vRes = Long2Fix(72);    p_descr->spatialQuality = codecLosslessQuality;    p_descr->frameCount = 1;    p_descr->clutID = -1;    p_descr->dataSize = 0;    p_descr->depth = 24;    HUnlock( (Handle)p_vout->p_sys->h_img_descr );    if( ( err = DecompressSequenceBeginS(                              &p_vout->p_sys->i_seq,                              p_vout->p_sys->h_img_descr,                              NULL,                              (p_descr->width * p_descr->height * 16) / 8,                              p_vout->p_sys->p_qdport,                              NULL, NULL,                              p_vout->p_sys->p_matrix,                              srcCopy, p_vout->p_sys->clip_mask,                              codecFlagUseImageBuffer,                              codecLosslessQuality,                              bestSpeedCodec ) ) )    {        msg_Err( p_vout, "Failed to initialize QT: DecompressSequenceBeginS failed: %d", err );        return( 1 );    }    return( 0 );}/***************************************************************************** * QTDestroySequence: destroy sequence *****************************************************************************/static void QTDestroySequence( vout_thread_t *p_vout ){    CDSequenceEnd( p_vout->p_sys->i_seq );}/***************************************************************************** * QTNewPicture: allocate a picture ***************************************************************************** * Returns 0 on success, 1 otherwise *****************************************************************************/static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic ){    /* We know the chroma, allocate a buffer which will be used     * directly by the decoder */    p_pic->p_sys = malloc( sizeof( picture_sys_t ) );    if( p_pic->p_sys == NULL )    {        return( -1 );    }    vout_InitPicture( VLC_OBJECT( p_vout), p_pic, p_vout->output.i_chroma,                      p_vout->output.i_width, p_vout->output.i_height,                      p_vout->output.i_aspect );    switch( p_vout->output.i_chroma )    {        case VLC_FOURCC('Y','U','Y','2'):            p_pic->p_sys->i_size = p_vout->output.i_width * p_vout->output.i_height * 2;            /* Allocate the memory buffer */            p_pic->p_data_orig = p_pic->p_data = malloc( p_pic->p_sys->i_size );            /* Memory is always 16-bytes aligned on OSX, so it does not             * posix_memalign() */            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );            p_pic->p[0].p_pixels = p_pic->p_data;            p_pic->p[0].i_lines = p_vout->output.i_height;            p_pic->p[0].i_visible_lines = p_vout->output.i_height;            p_pic->p[0].i_pitch = p_vout->output.i_width * 2;            p_pic->p[0].i_pixel_pitch = 1;            p_pic->p[0].i_visible_pitch = p_vout->output.i_width * 2;            p_pic->i_planes = 1;            p_pic->p_sys->p_data = (void *)p_pic->p[0].p_pixels;            break;         case VLC_FOURCC('I','4','2','0'):            p_pic->p_sys->p_data = (void *)&p_pic->p_sys->pixmap_i420;            p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);             /* Allocate the memory buffer */            p_pic->p_data_orig = p_pic->p_data = malloc( p_vout->output.i_width                                     * p_vout->output.i_height * 3 / 2 );            /* Memory is always 16-bytes aligned on OSX, so it does not             * posix_memalign() */            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );            /* Y buffer */            p_pic->Y_PIXELS = p_pic->p_data;            p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;            p_pic->p[Y_PLANE].i_visible_lines = p_vout->output.i_height;            p_pic->p[Y_PLANE].i_pitch = p_vout->output.i_width;            p_pic->p[Y_PLANE].i_pixel_pitch = 1;            p_pic->p[Y_PLANE].i_visible_pitch = p_vout->output.i_width;            /* U buffer */            p_pic->U_PIXELS = p_pic->Y_PIXELS + p_vout->output.i_height * p_vout->output.i_width;            p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;            p_pic->p[U_PLANE].i_visible_lines = p_vout->output.i_height / 2;            p_pic->p[U_PLANE].i_pitch = p_vout->output.i_width / 2;            p_pic->p[U_PLANE].i_pixel_pitch = 1;            p_pic->p[U_PLANE].i_visible_pitch = p_vout->output.i_width / 2;            /* V buffer */            p_pic->V_PIXELS = p_pic->U_PIXELS + p_vout->output.i_height * p_vout->output.i_width / 4;            p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;            p_pic->p[V_PLANE].i_visible_lines = p_vout->output.i_height / 2;            p_pic->p[V_PLANE].i_pitch = p_vout->output.i_width / 2;            p_pic->p[V_PLANE].i_pixel_pitch = 1;            p_pic->p[V_PLANE].i_visible_pitch = p_vout->output.i_width / 2;            /* We allocated 3 planes */            p_pic->i_planes = 3;#define P p_pic->p_sys->pixmap_i420            P.componentInfoY.offset = (void *)p_pic->Y_PIXELS                                       - p_pic->p_sys->p_data;            P.componentInfoCb.offset = (void *)p_pic->U_PIXELS                                        - p_pic->p_sys->p_data;            P.componentInfoCr.offset = (void *)p_pic->V_PIXELS                                        - p_pic->p_sys->p_data;            P.componentInfoY.rowBytes = p_vout->output.i_width;            P.componentInfoCb.rowBytes = p_vout->output.i_width / 2;            P.componentInfoCr.rowBytes = p_vout->output.i_width / 2;#undef P            break;         default:            /* Unknown chroma, tell the guy to get lost */            free( p_pic->p_sys );            msg_Err( p_vout, "Unknown chroma format 0x%.8x (%4.4s)",                     p_vout->output.i_chroma, (char*)&p_vout->output.i_chroma );            p_pic->i_planes = 0;            return( -1 );    }    return( 0 );}/***************************************************************************** * QTFreePicture: destroy a picture allocated with QTNewPicture *****************************************************************************/static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ){    switch( p_vout->output.i_chroma )    {        case VLC_FOURCC('I','4','2','0'):            free( p_pic->p_data_orig );            break;    }    free( p_pic->p_sys );}/***************************************************************************** * VLCQTView implementation *****************************************************************************/@implementation VLCQTView/* This function will reset the o_vout_view. It's useful to go fullscreen. */+ (void)resetVout: (vout_thread_t *)p_vout{    QTDestroySequence( p_vout );    if( p_vout->b_fullscreen )    {    if( !p_vout->p_sys->b_embedded )    {        /* Save window size and position */        p_vout->p_sys->s_frame.size =        [p_vout->p_sys->o_vout_view frame].size;        p_vout->p_sys->s_frame.origin =        [[p_vout->p_sys->o_vout_view getWindow] frame].origin;        p_vout->p_sys->b_saved_frame = true;    }        else        {            var_DelCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);            DisposeRgn(p_vout->p_sys->clip_mask);        }    }    if( p_vout->b_fullscreen || !p_vout->p_sys->b_embedded )    {    Rect s_rect;        p_vout->p_sys->clip_mask = NULL;#define o_qtview p_vout->p_sys->o_qtview    o_qtview = [[VLCQTView alloc] initWithVout: p_vout];    [o_qtview autorelease];        if( p_vout->p_sys->b_saved_frame )    {        p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout        subView: o_qtview        frame: &p_vout->p_sys->s_frame];    }    else    {        p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout        subView: o_qtview frame: nil];    }    /* Retrieve the QuickDraw port */    [o_qtview lockFocus];    p_vout->p_sys->p_qdport = [o_qtview qdPort];    [o_qtview unlockFocus];#undef o_qtview    GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );    p_vout->p_sys->i_origx = s_rect.left;    p_vout->p_sys->i_origy = s_rect.top;    p_vout->p_sys->i_width = s_rect.right - s_rect.left;    p_vout->p_sys->i_height = s_rect.bottom - s_rect.top;    }    else    {        /* Create the clipping mask */        p_vout->p_sys->clip_mask = NewRgn();    UpdateEmbeddedGeometry(p_vout);    var_AddCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);    }    QTScaleMatrix( p_vout );    if( QTCreateSequence( p_vout ) )    {        msg_Err( p_vout, "unable to initialize QT: QTCreateSequence failed" );        return;    }}- (id) initWithVout:(vout_thread_t *)_p_vout{    p_vout = _p_vout;    return [super init];}- (void)drawRect:(NSRect)rect{    [[NSColor blackColor] set];    NSRectFill( rect );    [super drawRect: rect];    p_vout->i_changes |= VOUT_SIZE_CHANGE;}@end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -