[Ffmpeg-devel] [PATCH, RFC] 16-bit grayscale depth support suite

Michael Niedermayer michaelni
Sun Oct 22 23:17:51 CEST 2006


Hi

On Sun, Oct 22, 2006 at 08:06:34PM +0300, Kostya wrote:
[...]
> Here is corrected patch for imgconvert and SWS implementation. While conversion
> is working fine when specified (gray16 -> gray, gray16 -> yuv),
> gray16 -> rgb24 works strange. Can somebody give any hints on this?

hmm, look at hyscale() did you implement gray16* -> gray8 there?

also optional/alternative if you write a gray16 hScale() (only the small
c loop at the end matters) then the swscaler should with some luck (maybe
some if(mmx) will need to be changed to if(mmx && !gray16)) be able to
actually use 15 of the 16 bits of gray16* in the horizontal scaling
and the vertical too if SWS_ACCURATE_RND is set or the c scaler is
used


[...]
> +static void gray16be_to_gray(AVPicture *dst, const AVPicture *src,
> +                              int width, int height)
> +{
> +    int x, y, src_wrap, dst_wrap;
> +    uint8_t *s, *d;
> +    s = src->data[0];
> +    src_wrap = src->linesize[0] - width * 2;
> +    d = dst->data[0];
> +    dst_wrap = dst->linesize[0] - width;
> +    for(y=0; y<height; y++){
> +        for(x=0; x<width; x++){
> +            *d++ = *s++;
> +            s++;
> +        }
> +        s += src_wrap;
> +        d += dst_wrap;
> +    }
> +}
> +
> +static void gray16le_to_gray(AVPicture *dst, const AVPicture *src,
> +                              int width, int height)
> +{
> +    int x, y, src_wrap, dst_wrap;
> +    uint8_t *s, *d;
> +    s = src->data[0];
> +    src_wrap = src->linesize[0] - width * 2;
> +    d = dst->data[0];
> +    dst_wrap = dst->linesize[0] - width;
> +    for(y=0; y<height; y++){
> +        for(x=0; x<width; x++){
> +            s++;
> +            *d++ = *s++;
> +        }
> +        s += src_wrap;
> +        d += dst_wrap;
> +    }
> +}

isnt that the same as gray16be_to_gray except a s++ before both loops?


[...]
> +static int gray16betogray(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
> +             int srcSliceH, uint8_t* dst[], int dstStride[]){
> +
> +	int length= c->srcW;
> +	int y=      srcSliceY;
> +	int height= srcSliceH;
> +	int i, j;
> +	uint8_t *srcPtr= src[0];
> +	uint8_t *dstPtr= dst[0] + dstStride[0]*y;
> +
> +	if(!isGray(c->dstFormat)){
> +		int height= -((-srcSliceH)>>c->chrDstVSubSample);
> +		memset(dst[1], 128, dstStride[1]*height);
> +		memset(dst[2], 128, dstStride[2]*height);
> +	}
> +	for(i=0; i<height; i++)
> +	{
> +		for(j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];
> +		srcPtr+= srcStride[0];
> +		dstPtr+= dstStride[0];
> +	}
> +	return srcSliceH;
> +}
> +
> +static int gray16letogray(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
> +             int srcSliceH, uint8_t* dst[], int dstStride[]){
> +
> +	int length= c->srcW;
> +	int y=      srcSliceY;
> +	int height= srcSliceH;
> +	int i, j;
> +	uint8_t *srcPtr= src[0];
> +	uint8_t *dstPtr= dst[0] + dstStride[0]*y;
> +	if(!isGray(c->dstFormat)){
> +		int height= -((-srcSliceH)>>c->chrDstVSubSample);
> +		memset(dst[1], 128, dstStride[1]*height);
> +		memset(dst[2], 128, dstStride[2]*height);
> +	}
> +	for(i=0; i<height; i++)
> +	{
> +		for(j=0; j<length; j++) dstPtr[j] = srcPtr[(j<<1) + 1];
> +		srcPtr+= srcStride[0];
> +		dstPtr+= dstStride[0];
> +	}
> +	return srcSliceH;
> +}

same simplification possible as in imgconvert (check be/le and srcPtr++)
and maybe yuy2ToY()/uyvyToY() could be used, they are mmx optimized ...


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list