dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/color Makefile.am Makefile.in colorspace.cc colorspace.hh

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:39 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/color
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/color

Added Files:
	Makefile.am Makefile.in colorspace.cc colorspace.hh 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: colorspace.hh ---
/*********************************************************************
  color/colorspace.hh

  purpose:
    Routines for chroma format and colorspace convertions.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de
     University Mannheim, Dept. Circuitry and Simulation
     B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany

  modifications:
    30.Nov.1999 - Dirk Farin - implemented RGB2YUV_444()
    03/Aug/1999 - Dirk Farin - new functions: - TrTo???_DupSub()
                                              - Grey2RGB_Inplace()
    20/Jul/1999 - Dirk Farin - complete rewrite
 *********************************************************************/

#ifndef LIBVIDEOGFX_GRAPHICS_COLOR_COLORSPACE_HH
#define LIBVIDEOGFX_GRAPHICS_COLOR_COLORSPACE_HH

#include "libvideogfx/graphics/basic/image.hh"


/* Apply interpolation filter with the kernel (1 3 3 1)//4 .
 * 'src' and 'dst' may be the same.
 */
void InterpolateH_Tap4(const Pixel*const* src,Pixel*const* dst,int dst_width,int height);
void InterpolateV_Tap4(const Pixel*const* src,Pixel*const* dst,int width,int dst_height);

void Tr420To444_Duplicate(Image_YUV<Pixel>& img);
void Tr420To422_Duplicate(Image_YUV<Pixel>& img);
void Tr422To444_Duplicate(Image_YUV<Pixel>& img);

void Tr422To420_Subsample(Image_YUV<Pixel>& img);
void Tr444To420_Subsample(Image_YUV<Pixel>& img);
void Tr444To422_Subsample(Image_YUV<Pixel>& img);

/* Transform any chroma format to the specified one (using simple pixel duplication/subsampling). */
void TrTo420_DupSub(Image_YUV<Pixel>& img);
void TrTo422_DupSub(Image_YUV<Pixel>& img);
void TrTo444_DupSub(Image_YUV<Pixel>& img);

void Tr422To444_Tap4(Image_YUV<Pixel>& img);


void YUV2RGB_444(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst); // src and dst may be the same image.
void YUV2RGB_422(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst); // src and dst may be the same image.
void YUV2RGB_420(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst); // src and dst may be the same image.
void RGB2YUV_444(const Image_RGB<Pixel>& src,Image_YUV<Pixel>& dst); // src and dst may be the same image.

/* Transfer the bitmaps between the image types.
   Be extremely careful when using these functions as they do nothing except
   the bitmap transfer. Image size and the like must be adjusted by hand.
   For experienced users only!
*/
void TransferBitmapsRGB2YUV(Image_RGB<Pixel>&,Image_YUV<Pixel>&);
void TransferBitmapsYUV2RGB(Image_YUV<Pixel>&,Image_RGB<Pixel>&);

/* This also does colorspace convertion, but does some hacking to transfer the YUV-image bitmaps
   to the RGB-image. Thus the RGB image does not need to be initialized and the bitmaps in the YUV image
   will be removed from the image.
   The advantage of this function is that it is faster in some systems and does not require as much
   memory as the convertion is calculated "in place".

   Note that inplace calculation can be slower when you throw the bitmaps away after use.
   If you do not need them anymore it is perhaps a good idea to transfer them back to the YUV image.
*/
void YUV2RGB_444_Inplace(Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst);

/* Convert greyscale YUV image to RGB.
   This function is VERY fast as no image data is actually being copied.
*/
void Grey2RGB_Inplace(Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst);



void HSB2RGB(double h,double s,double b, double& r,double& g,double& b);  // input/output range: 0..1 
void RGB2YUV(uint8 r,uint8 g,uint8 b, uint8& y,uint8& u,uint8& v);


#if 0
class ColorConverter_RGB_YUV
{
public:
  ~ColorConverter_RGB_YUV() { }

  void SetCoefficients(...);

private:
  
};
#endif


#endif

--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ../../..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@

noinst_LTLIBRARIES = libvideogfx-graphics-color.la

libvideogfx_graphics_color_la_SOURCES =  	colorspace.cc		colorspace.hh


INCLUDES =  	-I$(top_srcdir)

mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../../config.h
CONFIG_CLEAN_FILES = 
LTLIBRARIES =  $(noinst_LTLIBRARIES)


DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_graphics_color_la_LDFLAGS = 
libvideogfx_graphics_color_la_LIBADD = 
libvideogfx_graphics_color_la_OBJECTS =  colorspace.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON =  Makefile.am Makefile.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar
GZIP_ENV = --best
DEP_FILES =  .deps/colorspace.P
SOURCES = $(libvideogfx_graphics_color_la_SOURCES)
OBJECTS = $(libvideogfx_graphics_color_la_OBJECTS)

all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
	cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/graphics/color/Makefile

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


mostlyclean-noinstLTLIBRARIES:

clean-noinstLTLIBRARIES:
	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)

distclean-noinstLTLIBRARIES:

maintainer-clean-noinstLTLIBRARIES:

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

mostlyclean-compile:
	-rm -f *.o core *.core

clean-compile:

distclean-compile:
	-rm -f *.tab.c

maintainer-clean-compile:

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

distclean-libtool:

maintainer-clean-libtool:

libvideogfx-graphics-color.la: $(libvideogfx_graphics_color_la_OBJECTS) $(libvideogfx_graphics_color_la_DEPENDENCIES)
	$(CXXLINK)  $(libvideogfx_graphics_color_la_LDFLAGS) $(libvideogfx_graphics_color_la_OBJECTS) $(libvideogfx_graphics_color_la_LIBADD) $(LIBS)
.cc.o:
	$(CXXCOMPILE) -c $<
.cc.lo:
	$(LTCXXCOMPILE) -c $<

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	here=`pwd` && cd $(srcdir) \
	  && mkid -f$$here/ID $$unique $(LISP)

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags:
	-rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = libvideogfx/graphics/color

distdir: $(DISTFILES)
	here=`cd $(top_builddir) && pwd`; \
	top_distdir=`cd $(top_distdir) && pwd`; \
	distdir=`cd $(distdir) && pwd`; \
	cd $(top_srcdir) \
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/graphics/color/Makefile
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$d/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

-include $(DEP_FILES)

mostlyclean-depend:

clean-depend:

distclean-depend:
	-rm -rf .deps

maintainer-clean-depend:

%.o: %.c
	@echo '$(COMPILE) -c $<'; \
	$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.c
	@echo '$(LTCOMPILE) -c $<'; \
	$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp

%.o: %.cc
	@echo '$(CXXCOMPILE) -c $<'; \
	$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.cc
	@echo '$(LTCXXCOMPILE) -c $<'; \
	$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am

install-data-am:
install-data: install-data-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:


mostlyclean-generic:

clean-generic:

distclean-generic:
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
		mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
		mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-noinstLTLIBRARIES clean-compile clean-libtool \
		clean-tags clean-depend clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-noinstLTLIBRARIES distclean-compile \
		distclean-libtool distclean-tags distclean-depend \
		distclean-generic clean-am
	-rm -f libtool

distclean: distclean-am

maintainer-clean-am:  maintainer-clean-noinstLTLIBRARIES \
		maintainer-clean-compile maintainer-clean-libtool \
		maintainer-clean-tags maintainer-clean-depend \
		maintainer-clean-generic distclean-am
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean


.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

--- NEW FILE: colorspace.cc ---
/*
 *  colorspace.cc
 */

#include "colorspace.hh"


void InterpolateH_Tap4(const Pixel*const* src,Pixel*const* dst,int dst_width,int height)
{
  int src_width = (dst_width+1)/2;

  // Create a chroma-line buffer in the range [-1 .. cw]
  Pixel* line = new Pixel[src_width+2];
  Pixel* linep = &line[1];

  // Process interpolation filter
  for (int y=0;y<height;y++)
    {
      // copy line and duplicate pixels at the end
      for (int x=0;x<src_width;x++)
	linep[x] = src[y][x];
      linep[-1]        = linep[0];
      linep[src_width] = linep[src_width-1];

      // Apply filter (1 3 3 1)//4
      for (int x=0;x<src_width;x++)
	{
	  dst[y][2*x  ] = (linep[x]*3 + linep[x-1]+2)/4;
	  dst[y][2*x+1] = (linep[x]*3 + linep[x+1]+2)/4;
	}
    }

  delete[] line;
}


void InterpolateV_Tap4(const Pixel*const* src,Pixel*const* dst,int width,int dst_height)
{
  int src_height = (dst_height+1)/2;

  // Create a chroma-line buffer in the range [-1 .. cw]
  Pixel* line = new Pixel[src_height+2];
  Pixel* linep = &line[1];

  // Process interpolation filter
  for (int x=0;x<width;x++)
    {
      // copy line and duplicate pixels at the end
      for (int y=0;y<src_height;y++)
	linep[y] = src[y][x];
      linep[-1]         = linep[0];
      linep[src_height] = linep[src_height-1];

      // Apply filter (1 3 3 1)//4
      for (int y=0;y<src_height;y++)
	{
	  dst[2*y  ][x] = (linep[y]*3 + linep[y-1]+2)/4;
	  dst[2*y+1][x] = (linep[y]*3 + linep[y+1]+2)/4;
	}
    }

  delete[] line;
}




void Tr420To444_Duplicate(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma420);
  assert(!param.reduced_chroma_size);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=(param.height+1)/2-1;y>=0;y--)
    for (int x=(param.width+1)/2-1;x>=0;x--)
      {
	up[2*y  ][2*x  ] =
	up[2*y  ][2*x+1] =
	up[2*y+1][2*x  ] =
	up[2*y+1][2*x+1] = up[y][x];
	vp[2*y  ][2*x  ] =
	vp[2*y  ][2*x+1] =
	vp[2*y+1][2*x  ] =
	vp[2*y+1][2*x+1] = vp[y][x];
      }

  img.SetChromaFormat(Chroma444);
}


void Tr420To422_Duplicate(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma420);
  assert(!param.reduced_chroma_size);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=(param.height+1)/2-1;y>=0;y--)
    for (int x=0;x<param.width;x++)
      {
	up[2*y  ][x] =
	up[2*y+1][x] = up[y][x];
	vp[2*y  ][x] =
	vp[2*y+1][x] = vp[y][x];
      }

  img.SetChromaFormat(Chroma422);
}


void Tr422To444_Duplicate(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma422);
  assert(!param.reduced_chroma_size);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=0;y<param.height;y++)
    for (int x=(param.width+1)/2-1;x>=0;x--)
      {
	up[y][2*x  ] =
	up[y][2*x+1] = up[y][x];
	vp[y][2*x  ] =
	vp[y][2*x+1] = vp[y][x];
      }

  img.SetChromaFormat(Chroma444);
}


void Tr422To420_Subsample(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma422);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=0;y<(param.height+1)/2-1;y++)
    for (int x=0;x<param.width;x++)
      {
	up[y][x] = up[2*y][x];
	vp[y][x] = vp[2*y][x];
      }

  int ch = (param.height+1)/2;

  img.AskBitmap(Image<Pixel>::Bitmap_U).SetSize(param.width,ch);
  img.AskBitmap(Image<Pixel>::Bitmap_V).SetSize(param.width,ch);

  img.SetChromaFormat(Chroma420);
}


void Tr444To420_Subsample(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma444);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=0;y<(param.height+1)/2-1;y++)
    for (int x=0;x<(param.width+1)/2-1;x++)
      {
	up[y][x] = up[2*y][2*x];
	vp[y][x] = vp[2*y][2*x];
      }

  int cw = (param.width +1)/2;
  int ch = (param.height+1)/2;

  img.AskBitmap(Image<Pixel>::Bitmap_U).SetSize(cw,ch);
  img.AskBitmap(Image<Pixel>::Bitmap_V).SetSize(cw,ch);

  img.SetChromaFormat(Chroma420);
}

void Tr444To422_Subsample(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  assert(param.chroma==Chroma444);

  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  for (int y=0;y<param.height;y++)
    for (int x=0;x<(param.width+1)/2-1;x++)
      {
	up[y][x] = up[y][2*x];
	vp[y][x] = vp[y][2*x];
      }

  int cw = (param.width+1)/2;

  img.AskBitmap(Image<Pixel>::Bitmap_U).SetSize(cw,param.height);
  img.AskBitmap(Image<Pixel>::Bitmap_V).SetSize(cw,param.height);

  img.SetChromaFormat(Chroma422);
}




void Tr422To444_Tap4(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  // Check that we have enough memory space available.
  assert(!param.reduced_chroma_size);
  assert(param.chroma==Chroma422);

  // Process interpolation filter on U and V components.
  Pixel*const* up = img.AskFrameU();
  Pixel*const* vp = img.AskFrameV();

  InterpolateH_Tap4(up,up,param.width,param.height);
  InterpolateH_Tap4(vp,vp,param.width,param.height);

  img.SetChromaFormat(Chroma444);
}



inline int Clip(int x) { if (x<0) return 0; if (x>255) return 255; return x; }

void YUV2RGB_444(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  ImageSpec spec;
  src.Image<Pixel>::GetParam(spec);

  dst.Create(spec);

  ImageParam_YUV param;
  src.GetParam(param);

  assert(param.chroma == Chroma444);

  Pixel*const* rd = dst.AskFrameR();
  Pixel*const* gd = dst.AskFrameG();
  Pixel*const* bd = dst.AskFrameB();

  const Pixel*const* ys = src.AskFrameY_const();
  const Pixel*const* us = src.AskFrameU_const();
  const Pixel*const* vs = src.AskFrameV_const();

  for (int y=0;y<param.height;y++)
    for (int x=0;x<param.width;x++)
      {
	int yy = ((int)ys[y][x]) -16;
	int u  = ((int)us[y][x]) -128;
	int v  = ((int)vs[y][x]) -128;

	rd[y][x] = Clip((         409*v + 298*yy)>>8);
	gd[y][x] = Clip((-100*u - 208*v + 298*yy)>>8);
	bd[y][x] = Clip(( 516*u         + 298*yy)>>8);
      }
}

void YUV2RGB_422(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  ImageSpec spec;
  src.Image<Pixel>::GetParam(spec);

  dst.Create(spec);

  ImageParam_YUV param;
  src.GetParam(param);

  assert(param.chroma == Chroma422);

  Pixel*const* rd = dst.AskFrameR();
  Pixel*const* gd = dst.AskFrameG();
  Pixel*const* bd = dst.AskFrameB();

  const Pixel*const* ys = src.AskFrameY_const();
  const Pixel*const* us = src.AskFrameU_const();
  const Pixel*const* vs = src.AskFrameV_const();

  for (int y=0;y<param.height;y++)
    for (int x=0;x<param.width;x++)
      {
	int yy = ((int)ys[y][x]) -16;
	int u  = ((int)us[y][x/2]) -128;
	int v  = ((int)vs[y][x/2]) -128;

	rd[y][x] = Clip((         409*v + 298*yy)>>8);
	gd[y][x] = Clip((-100*u - 208*v + 298*yy)>>8);
	bd[y][x] = Clip(( 516*u         + 298*yy)>>8);
      }
}


void YUV2RGB_420(const Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  ImageSpec spec;
  src.Image<Pixel>::GetParam(spec);

  dst.Create(spec);

  ImageParam_YUV param;
  src.GetParam(param);

  assert(param.chroma == Chroma420);

  Pixel*const* rd = dst.AskFrameR();
  Pixel*const* gd = dst.AskFrameG();
  Pixel*const* bd = dst.AskFrameB();

  const Pixel*const* ys = src.AskFrameY_const();
  const Pixel*const* us = src.AskFrameU_const();
  const Pixel*const* vs = src.AskFrameV_const();

  for (int y=0;y<param.height;y++)
    for (int x=0;x<param.width;x++)
      {
	int yy = ((int)ys[y][x]) -16;
	int u  = ((int)us[y/2][x/2]) -128;
	int v  = ((int)vs[y/2][x/2]) -128;

	rd[y][x] = Clip((         409*v + 298*yy)>>8);
	gd[y][x] = Clip((-100*u - 208*v + 298*yy)>>8);
	bd[y][x] = Clip(( 516*u         + 298*yy)>>8);
      }
}


void RGB2YUV_444(const Image_RGB<Pixel>& src,Image_YUV<Pixel>& dst)
{
  ImageSpec_YUV spec;
  src.Image<Pixel>::GetParam(spec);
  spec.chroma=Chroma444;

  dst.Create(spec);

  ImageParam param;
  src.GetParam(param);

  const Pixel*const* rs = src.AskFrameR_const();
  const Pixel*const* gs = src.AskFrameG_const();
  const Pixel*const* bs = src.AskFrameB_const();

  Pixel*const* yd = dst.AskFrameY();
  Pixel*const* ud = dst.AskFrameU();
  Pixel*const* vd = dst.AskFrameV();

  for (int y=0;y<param.height;y++)
    for (int x=0;x<param.width;x++)
      {
	int r = ((int)rs[y][x]);
	int g = ((int)gs[y][x]);
	int b = ((int)bs[y][x]);

	yd[y][x] = Clip((( 65*r +  129*g +  24*b)>>8)+16);
	ud[y][x] = Clip(((-37*r +  -74*g + 112*b)>>8)+128);
	vd[y][x] = Clip(((112*r +  -93*g + -18*b)>>8)+128);
      }
}


void TransferBitmapsRGB2YUV(Image_RGB<Pixel>& src,Image_YUV<Pixel>& dst)
{
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Y     , src.AskBitmap(Image<Pixel>::Bitmap_Red  ) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_U     , src.AskBitmap(Image<Pixel>::Bitmap_Green) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_V     , src.AskBitmap(Image<Pixel>::Bitmap_Blue ) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , src.AskBitmap(Image<Pixel>::Bitmap_Alpha) );
}

void TransferBitmapsYUV2RGB(Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Red   , src.AskBitmap(Image<Pixel>::Bitmap_Y) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Green , src.AskBitmap(Image<Pixel>::Bitmap_U) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Blue  , src.AskBitmap(Image<Pixel>::Bitmap_V) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , src.AskBitmap(Image<Pixel>::Bitmap_Alpha) );
}

void YUV2RGB_444_Inplace(Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  // --- Transfer all YUV image bitmaps to the RGB image. ---

  // Transfer bitmaps

  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Red   , src.AskBitmap(Image<Pixel>::Bitmap_Y) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Green , src.AskBitmap(Image<Pixel>::Bitmap_U) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Blue  , src.AskBitmap(Image<Pixel>::Bitmap_V) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , src.AskBitmap(Image<Pixel>::Bitmap_Alpha) );

  // Adjust parameters of RGB image.

  ImageParam_YUV param;
  src.GetParam(param);
  assert(param.chroma == Chroma444);
  dst.SetParam(param);

  // Remove bitmaps from YUV image.

  Bitmap<Pixel> emptybm;
  src.ReplaceBitmap(Image<Pixel>::Bitmap_Y     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_U     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_V     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , emptybm);


  // --- Now do the conversion ---

  Pixel*const* rd = dst.AskFrameR();
  Pixel*const* gd = dst.AskFrameG();
  Pixel*const* bd = dst.AskFrameB();

  const Pixel*const* ys = rd;
  const Pixel*const* us = gd;
  const Pixel*const* vs = bd;

  for (int y=0;y<param.height;y++)
    for (int x=0;x<param.width;x++)
      {
	int yy = ((int)ys[y][x]) -16;
	int u  = ((int)us[y][x]) -128;
	int v  = ((int)vs[y][x]) -128;

	rd[y][x] = Clip((         409*v + 298*yy)>>8);
	gd[y][x] = Clip((-100*u - 208*v + 298*yy)>>8);
	bd[y][x] = Clip(( 516*u         + 298*yy)>>8);
      }
}


void Grey2RGB_Inplace(Image_YUV<Pixel>& src,Image_RGB<Pixel>& dst)
{
  // --- Transfer all YUV image bitmaps to the RGB image. ---

  // Transfer bitmaps. The trick is here that all RGB channels are set to the same bitmap.

  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Red   , src.AskBitmap(Image<Pixel>::Bitmap_Y) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Green , src.AskBitmap(Image<Pixel>::Bitmap_Y) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Blue  , src.AskBitmap(Image<Pixel>::Bitmap_Y) );
  dst.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , src.AskBitmap(Image<Pixel>::Bitmap_Alpha) );

  // Adjust parameters of RGB image.

  ImageParam_YUV param;
  src.GetParam(param);
  param.nocolor = true;
  dst.SetParam(param);


  // Remove bitmaps from YUV image.

  Bitmap<Pixel> emptybm;
  src.ReplaceBitmap(Image<Pixel>::Bitmap_Y     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_U     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_V     , emptybm);
  src.ReplaceBitmap(Image<Pixel>::Bitmap_Alpha , emptybm);
}


void TrTo420_DupSub(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  switch (param.chroma)
    {
    case Chroma420: break;
    case Chroma422: Tr422To420_Subsample(img); break;
    case Chroma444: Tr444To420_Subsample(img); break;
    }
}


void TrTo422_DupSub(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  switch (param.chroma)
    {
    case Chroma420: Tr420To422_Duplicate(img); break;
    case Chroma422: break;
    case Chroma444: Tr444To422_Subsample(img); break;
    }
}


void TrTo444_DupSub(Image_YUV<Pixel>& img)
{
  ImageParam_YUV param;
  img.GetParam(param);

  switch (param.chroma)
    {
    case Chroma420: Tr420To444_Duplicate(img); break;
    case Chroma422: Tr422To444_Duplicate(img); break;
    case Chroma444: break;
    }
}


void HSB2RGB(double h,double s,double br, double& red,double& green,double& blue)
{
  double hue = h;
  double saturation = s;
  double brightness = br;

  if (brightness == 0.0) { red   = green = blue  = 0.0;        return; }
  if (saturation == 0.0) { red   = green = blue  = brightness; return; }

  double offs;   // hue mod 1/6
  if (hue < 1.0/6)
    {   // red domain; green ascends
      offs = hue;
      red   = brightness;
      blue  = brightness * (1.0 - saturation);
      green = blue + (brightness - blue) * offs * 6;
    }
  else if (hue < 2.0/6)
    { // yellow domain; red descends
      offs = hue - 1.0/6;
      green = brightness;
      blue  = brightness * (1.0 - saturation);
      red   = green - (brightness - blue) * offs * 6;
    }
  else if (hue < 3.0/6)
    { // green domain; blue ascends
      offs = hue - 2.0/6;
      green = brightness;
      red   = brightness * (1.0 - saturation);
      blue  = red + (brightness - red) * offs * 6;
    }
  else if (hue < 4.0/6)
    { // cyan domain; green descends
      offs = hue - 3.0/6;
      blue  = brightness;
      red   = brightness * (1.0 - saturation);
      green = blue - (brightness - red) * offs * 6;
    }
  else if (hue < 5.0/6)
    { // blue domain; red ascends
      offs = hue - 4.0/6;
      blue  = brightness;
      green = brightness * (1.0 - saturation);
      red   = green + (brightness - green) * offs * 6;
    }
  else
    { // magenta domain; blue descends
      offs = hue - 5.0/6;
      red   = brightness;
      green = brightness * (1.0 - saturation);
      blue  = red - (brightness - green) * offs * 6;
    }
}


void RGB2YUV(uint8 r,uint8 g,uint8 b, uint8& y,uint8& u,uint8& v)
{
  y = Clip((( 65*r +  129*g +  24*b)>>8)+16);
  u = Clip(((-37*r +  -74*g + 112*b)>>8)+128);
  v = Clip(((112*r +  -93*g + -18*b)>>8)+128);
}

--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/graphics/color

noinst_LTLIBRARIES = libvideogfx-graphics-color.la

libvideogfx_graphics_color_la_SOURCES = \
	colorspace.cc	\
	colorspace.hh

INCLUDES = \
	-I$(top_srcdir)

.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done




More information about the dslinux-commit mailing list