Exemplo n.º 1
0
Arquivo: swscale.c Projeto: Tilka/vlc
static void Convert( filter_t *p_filter, struct SwsContext *ctx,
                     picture_t *p_dst, picture_t *p_src, int i_height, int i_plane_start, int i_plane_count,
                     bool b_swap_uvi, bool b_swap_uvo )
{
    uint8_t palette[AVPALETTE_SIZE];

    uint8_t *src[4]; int src_stride[4];
    uint8_t *dst[4]; int dst_stride[4];

    GetPixels( src, src_stride, p_src, i_plane_start, i_plane_count, b_swap_uvi );
    if( p_filter->fmt_in.video.i_chroma == VLC_CODEC_RGBP )
    {
        memset( palette, 0, sizeof(palette) );
        if( p_filter->fmt_in.video.p_palette )
            memcpy( palette, p_filter->fmt_in.video.p_palette->palette,
                    __MIN( sizeof(video_palette_t), AVPALETTE_SIZE ) );
        src[1] = palette;
        src_stride[1] = 4;
    }

    GetPixels( dst, dst_stride, p_dst, i_plane_start, i_plane_count, b_swap_uvo );

#if LIBSWSCALE_VERSION_INT  >= ((0<<16)+(5<<8)+0)
    sws_scale( ctx, src, src_stride, 0, i_height,
               dst, dst_stride );
#else
    sws_scale_ordered( ctx, src, src_stride, 0, i_height,
                       dst, dst_stride );
#endif
}
Exemplo n.º 2
0
static void draw_slice(struct vf_instance_s* vf,
        unsigned char** src, int* stride, int w,int h, int x, int y){
    if (vf->priv->store_slices) {
	uint8_t *dst[3];
	int dst_stride[3];
	dst_stride[0] = vf->priv->stride;
	dst_stride[1] = dst_stride[2] = 0;
	dst[0] = vf->priv->buffer;
	dst[1] = dst[2] = 0;
	sws_scale_ordered(vf->priv->ctx, src, stride, y, h, dst, dst_stride);
    }
    vf_next_draw_slice(vf,src,stride,w,h,x,y);
}
Exemplo n.º 3
0
static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
{
    uint8_t *dst[3];
    int dst_stride[3];
	
    dst_stride[0] = priv->stride;
    dst_stride[1] = dst_stride[2] = 0;
    if (!priv->buffer)
	priv->buffer = (uint8_t*)memalign(16, dst_stride[0]*priv->dh);

    dst[0] = priv->buffer;
    dst[1] = dst[2] = 0;
    sws_scale_ordered(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
}
Exemplo n.º 4
0
static int draw_slice(uint8_t * src[], int stride[], int w, int h,
                           int x, int y)
{
    uint8_t *dst[MP_MAX_PLANES] = {NULL};
    int dstStride[MP_MAX_PLANES] = {0};

    if ((old_vo_dwidth != vo_dwidth
         || old_vo_dheight != vo_dheight) /*&& y==0 */  && zoomFlag)
    {
        int newW = vo_dwidth;
        int newH = vo_dheight;
        struct SwsContext *oldContext = swsContext;

        old_vo_dwidth = vo_dwidth;
        old_vo_dheight = vo_dheight;

        if (vo_fs)
            aspect(&newW, &newH, A_ZOOM);
        if (sws_flags == 0)
            newW &= (~31);      // not needed but, if the user wants the FAST_BILINEAR SCALER, then its needed

        swsContext = sws_getContextFromCmdLine(srcW, srcH, in_format,
                                               newW, newH, out_format);
        if (swsContext)
        {
            image_width = (newW + 7) & (~7);
            image_height = newH;

            freeMyXImage();
            getMyXImage();
            sws_freeContext(oldContext);
        } else
        {
            swsContext = oldContext;
        }
        dst_width = newW;
    }

    dstStride[0] = image_width * ((bpp + 7) / 8);
    dst[0] = ImageData;
    if (Flip_Flag)
    {
        dst[0] += dstStride[0] * (image_height - 1);
        dstStride[0] = -dstStride[0];
    }
    sws_scale_ordered(swsContext, src, stride, y, h, dst, dstStride);
    return 0;
}
Exemplo n.º 5
0
/// ResizeRGB24
uint32_t CVideoResize::ResizeRGB24(const char* pInFrame, uint32_t nInFrameSize, 
	char* pOutFrame, uint32_t nOutFrameSize)
{
	// 参数检查
	if(NULL == pInFrame || NULL == pOutFrame 
		|| 0 == nInFrameSize || 0 == nOutFrameSize)
	{
		return 0;
	}

	// 缓冲区长度检查
	if((m_nSrcWidth * m_nSrcHeight * 3) > nInFrameSize 
		|| (m_nDstWidth * m_nDstHeight * 3) > nOutFrameSize)
	{
		return 0;
	}

	BYTE* srcImage[3];
	srcImage[0] = (BYTE*)pInFrame;
	srcImage[1] = NULL;
	srcImage[2] = NULL;

	int srcStride[3];
	srcStride[0] = m_nSrcWidth * 3;
	srcStride[1] = 0;
	srcStride[2] = 0;

	BYTE* dstImage[3];
	dstImage[0] = (BYTE*)pOutFrame;
	dstImage[1] = NULL;
	dstImage[2] = NULL;

	int dstStride[3];
	dstStride[0] = m_nDstWidth * 3;
	dstStride[1] = 0;
	dstStride[2] = 0;

	uint32_t nResult = 0;
	if(sws_scale_ordered(m_hContext, srcImage, srcStride, 0, m_nSrcHeight, dstImage, dstStride)>0)
	{
		nResult = m_nDstWidth * m_nDstHeight * 3;
	}

	// 不知道为什么libmplayer始终返回0,所以在这里重新计算了返回值
	nResult = m_nDstWidth * m_nDstHeight * 3;
	return nResult;
}