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

📄 vout_pictures.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 3 页
字号:
                return PP_OUTPUTPICTURE[0];            }            /* No subtitles, picture is in a directbuffer so             * we can display it directly even if it is still             * in use. */            return p_pic;        }        /* Picture is in a direct buffer but isn't used by the         * decoder. We can safely render subtitles on it and         * display it. */        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out, p_pic, p_pic,                               p_subpic, i_scale_width, i_scale_height );        return p_pic;    }    /* Not a direct buffer. We either need to copy it to a direct buffer,     * or render it if the chroma isn't the same. */    if( p_vout->b_direct )    {        /* Picture is not in a direct buffer, but is exactly the         * same size as the direct buffers. A memcpy() is enough,         * then render the subtitles. */        if( PP_OUTPUTPICTURE[0]->pf_lock )            if( PP_OUTPUTPICTURE[0]->pf_lock( p_vout, PP_OUTPUTPICTURE[0] ) )                return NULL;        vout_CopyPicture( p_vout, PP_OUTPUTPICTURE[0], p_pic );        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out,                               PP_OUTPUTPICTURE[0], p_pic,                               p_subpic, i_scale_width, i_scale_height );        if( PP_OUTPUTPICTURE[0]->pf_unlock )            PP_OUTPUTPICTURE[0]->pf_unlock( p_vout, PP_OUTPUTPICTURE[0] );        return PP_OUTPUTPICTURE[0];    }    /* Picture is not in a direct buffer, and needs to be converted to     * another size/chroma. Then the subtitles need to be rendered as     * well. This usually means software YUV, or hardware YUV with a     * different chroma. */    if( p_subpic != NULL && p_vout->p_picture[0].b_slow )    {        /* The picture buffer is in slow memory. We'll use         * the "2 * VOUT_MAX_PICTURES + 1" picture as a temporary         * one for subpictures rendering. */        picture_t *p_tmp_pic = &p_vout->p_picture[2 * VOUT_MAX_PICTURES];        if( p_tmp_pic->i_status == FREE_PICTURE )        {            vout_AllocatePicture( VLC_OBJECT(p_vout),                                  p_tmp_pic, p_vout->fmt_out.i_chroma,                                  p_vout->fmt_out.i_width,                                  p_vout->fmt_out.i_height,                                  p_vout->fmt_out.i_aspect );            p_tmp_pic->i_type = MEMORY_PICTURE;            p_tmp_pic->i_status = RESERVED_PICTURE;        }        /* Convert image to the first direct buffer */        p_vout->chroma.pf_convert( p_vout, p_pic, p_tmp_pic );        /* Render subpictures on the first direct buffer */        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out, p_tmp_pic,                               p_tmp_pic, p_subpic,                               i_scale_width, i_scale_height );        if( p_vout->p_picture[0].pf_lock )            if( p_vout->p_picture[0].pf_lock( p_vout, &p_vout->p_picture[0] ) )                return NULL;        vout_CopyPicture( p_vout, &p_vout->p_picture[0], p_tmp_pic );    }    else    {        if( p_vout->p_picture[0].pf_lock )            if( p_vout->p_picture[0].pf_lock( p_vout, &p_vout->p_picture[0] ) )                return NULL;        /* Convert image to the first direct buffer */        p_vout->chroma.pf_convert( p_vout, p_pic, &p_vout->p_picture[0] );        /* Render subpictures on the first direct buffer */        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out,                               &p_vout->p_picture[0], &p_vout->p_picture[0],                               p_subpic, i_scale_width, i_scale_height );    }    if( p_vout->p_picture[0].pf_unlock )        p_vout->p_picture[0].pf_unlock( p_vout, &p_vout->p_picture[0] );    return &p_vout->p_picture[0];}/** * Calculate image window coordinates * * This function will be accessed by plugins. It calculates the relative * position of the output window and the image window. */void vout_PlacePicture( vout_thread_t *p_vout,                        unsigned int i_width, unsigned int i_height,                        unsigned int *pi_x, unsigned int *pi_y,                        unsigned int *pi_width, unsigned int *pi_height ){    if( (i_width <= 0) || (i_height <=0) )    {        *pi_width = *pi_height = *pi_x = *pi_y = 0;        return;    }    if( p_vout->b_scale )    {        *pi_width = i_width;        *pi_height = i_height;    }    else    {        *pi_width = __MIN( i_width, p_vout->render.i_width );        *pi_height = __MIN( i_height, p_vout->render.i_height );    }    if( VOUT_ASPECT_FACTOR * *pi_width / *pi_height < p_vout->render.i_aspect )    {        *pi_width = *pi_height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;    }    else    {        *pi_height = *pi_width * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;    }    if( *pi_width > i_width )    {        *pi_width = i_width;        *pi_height = VOUT_ASPECT_FACTOR * *pi_width / p_vout->render.i_aspect;    }    if( *pi_height > i_height )    {        *pi_height = i_height;        *pi_width = *pi_height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;    }    switch( p_vout->i_alignment & VOUT_ALIGN_HMASK )    {    case VOUT_ALIGN_LEFT:        *pi_x = 0;        break;    case VOUT_ALIGN_RIGHT:        *pi_x = i_width - *pi_width;        break;    default:        *pi_x = ( i_width - *pi_width ) / 2;    }    switch( p_vout->i_alignment & VOUT_ALIGN_VMASK )    {    case VOUT_ALIGN_TOP:        *pi_y = 0;        break;    case VOUT_ALIGN_BOTTOM:        *pi_y = i_height - *pi_height;        break;    default:        *pi_y = ( i_height - *pi_height ) / 2;    }}/** * Allocate a new picture in the heap. * * This function allocates a fake direct buffer in memory, which can be * used exactly like a video buffer. The video output thread then manages * how it gets displayed. */int __vout_AllocatePicture( vlc_object_t *p_this, picture_t *p_pic,                            vlc_fourcc_t i_chroma,                            int i_width, int i_height, int i_aspect ){    int i_bytes, i_index, i_width_aligned, i_height_aligned;    /* Make sure the real dimensions are a multiple of 16 */    i_width_aligned = (i_width + 15) >> 4 << 4;    i_height_aligned = (i_height + 15) >> 4 << 4;    if( vout_InitPicture( p_this, p_pic, i_chroma,                          i_width, i_height, i_aspect ) != VLC_SUCCESS )    {        p_pic->i_planes = 0;        return VLC_EGENERIC;    }    /* Calculate how big the new image should be */    i_bytes = p_pic->format.i_bits_per_pixel *        i_width_aligned * i_height_aligned / 8;    p_pic->p_data = vlc_memalign( &p_pic->p_data_orig, 16, i_bytes );    if( p_pic->p_data == NULL )    {        p_pic->i_planes = 0;        return VLC_EGENERIC;    }    /* Fill the p_pixels field for each plane */    p_pic->p[ 0 ].p_pixels = p_pic->p_data;    for( i_index = 1; i_index < p_pic->i_planes; i_index++ )    {        p_pic->p[i_index].p_pixels = p_pic->p[i_index-1].p_pixels +            p_pic->p[i_index-1].i_lines * p_pic->p[i_index-1].i_pitch;    }    return VLC_SUCCESS;}/** * Initialise the video format fields given chroma/size. * * This function initializes all the video_frame_format_t fields given the * static properties of a picture (chroma and size). * \param p_format Pointer to the format structure to initialize * \param i_chroma Chroma to set * \param i_width Width to set * \param i_height Height to set * \param i_aspect Aspect ratio */void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,                      int i_width, int i_height, int i_aspect ){    p_format->i_chroma   = i_chroma;    p_format->i_width    = p_format->i_visible_width  = i_width;    p_format->i_height   = p_format->i_visible_height = i_height;    p_format->i_x_offset = p_format->i_y_offset = 0;    p_format->i_aspect   = i_aspect;#if 0    /* Assume we have square pixels */    if( i_width && i_height )        p_format->i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height;    else        p_format->i_aspect = 0;#endif    switch( i_chroma )    {        case FOURCC_YUVA:            p_format->i_bits_per_pixel = 32;            break;        case FOURCC_I444:        case FOURCC_J444:            p_format->i_bits_per_pixel = 24;            break;        case FOURCC_I422:        case FOURCC_YUY2:        case FOURCC_UYVY:        case FOURCC_J422:            p_format->i_bits_per_pixel = 16;            p_format->i_bits_per_pixel = 16;            break;        case FOURCC_I411:        case FOURCC_YV12:        case FOURCC_I420:        case FOURCC_J420:        case FOURCC_IYUV:            p_format->i_bits_per_pixel = 12;            break;        case FOURCC_I410:        case FOURCC_YVU9:            p_format->i_bits_per_pixel = 9;            break;        case FOURCC_Y211:            p_format->i_bits_per_pixel = 8;            break;        case FOURCC_YUVP:            p_format->i_bits_per_pixel = 8;            break;        case FOURCC_RV32:            p_format->i_bits_per_pixel = 32;            break;        case FOURCC_RV24:            p_format->i_bits_per_pixel = 24;            break;        case FOURCC_RV15:        case FOURCC_RV16:            p_format->i_bits_per_pixel = 16;            break;        case FOURCC_RGB2:            p_format->i_bits_per_pixel = 8;            break;        default:            p_format->i_bits_per_pixel = 0;            break;    }}/** * Initialise the picture_t fields given chroma/size. * * This function initializes most of the picture_t fields given a chroma and * size. It makes the assumption that stride == width. * \param p_this The calling object * \param p_pic Pointer to the picture to initialize * \param i_chroma The chroma fourcc to set * \param i_width The width of the picture * \param i_height The height of the picture * \param i_aspect The aspect ratio of the picture */int __vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,                        vlc_fourcc_t i_chroma,                        int i_width, int i_height, int i_aspect ){    int i_index, i_width_aligned, i_height_aligned;

⌨️ 快捷键说明

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