[FFmpeg-devel] [PATCH] fix gray/pal range in libswscale

Michael Niedermayer michaelni
Sat Dec 25 21:00:06 CET 2010


On Sat, Jun 05, 2010 at 07:34:30PM -0700, Baptiste Coudurier wrote:
> Hi
>
> gray/16/pal use full range so set jpeg range and disable unscaled gray  
> -> yuv func since it won't convert the range.
>
> -- 
> Baptiste COUDURIER
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> FFmpeg maintainer                                  http://www.ffmpeg.org

>  swscale.c          |    2 --
>  swscale_template.c |    5 +++--
>  utils.c            |    3 +++
>  3 files changed, 6 insertions(+), 4 deletions(-)
> 0e2045b13fd3a20dd053ab82e158d62a826ced0d  fix_gray_range.patch
> Index: libswscale/utils.c
> ===================================================================
> --- libswscale/utils.c	(revision 31332)
> +++ libswscale/utils.c	(working copy)
> @@ -710,6 +711,9 @@ int sws_getColorspaceDetails(SwsContext *c, int **
>  
>  static int handle_jpeg(enum PixelFormat *format)
>  {
> +    if (isGray(*format) || usePal(*format))
> +        return 1;
> +
>      switch (*format) {
>      case PIX_FMT_YUVJ420P: *format = PIX_FMT_YUV420P; return 1;
>      case PIX_FMT_YUVJ422P: *format = PIX_FMT_YUV422P; return 1;

> Index: libswscale/swscale.c
> ===================================================================
> --- libswscale/swscale.c	(revision 31332)
> +++ libswscale/swscale.c	(working copy)
> @@ -1793,8 +1839,6 @@ void ff_get_unscaled_swscale(SwsContext *c)
>      if (  srcFormat == dstFormat
>          || (srcFormat == PIX_FMT_YUVA420P && dstFormat == PIX_FMT_YUV420P)
>          || (srcFormat == PIX_FMT_YUV420P && dstFormat == PIX_FMT_YUVA420P)

> -        || (isPlanarYUV(srcFormat) && isGray(dstFormat))
> -        || (isPlanarYUV(dstFormat) && isGray(srcFormat))

It still can be used for jpeg<->gray, do we loose that?


>          || (isGray(dstFormat) && isGray(srcFormat))
>          || (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat)
>              && c->chrDstHSubSample == c->chrSrcHSubSample
> Index: libswscale/swscale_template.c
> ===================================================================
> --- libswscale/swscale_template.c	(revision 31332)
> +++ libswscale/swscale_template.c	(working copy)
> @@ -2212,7 +2212,6 @@ static inline void RENAME(hScale)(int16_t *dst, in
>  #endif /* COMPILE_MMX */
>  }
>  
> -//FIXME all pal and rgb srcFormats could do this convertion as well
>  //FIXME all scalers more complex than bilinear could do half of this transform
>  static void RENAME(chrRangeToJpeg)(uint16_t *dst, int width)
>  {
> @@ -3050,7 +3054,9 @@ static void RENAME(sws_init_swScale)(SwsContext *c
>          break;
>      }
>  
> -    if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
> +    if (c->srcRange != c->dstRange &&
> +        !isAnyRGB(c->dstFormat) &&
> +        !(isAnyRGB(c->srcFormat && dst->Range == 1))) { // RGB does not set range

"isAnyRGB(c->srcFormat && dst->Range == 1)"
looks wrong
also rgb<->yuv can change the range by changing some coefficients so these
functions here should not be needed for that


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101225/4767cad1/attachment.pgp>



More information about the ffmpeg-devel mailing list