cog: remove cog plugin

Everything has been merged into other elements.
This commit is contained in:
David Schleef 2013-02-11 12:25:05 -08:00
parent dee6536421
commit 3cddc007cb
21 changed files with 1 additions and 22613 deletions

View file

@ -324,7 +324,7 @@ GST_PLUGINS_NONPORTED=" aiff \
sdi stereo tta videofilters \
videomeasure videosignal vmnc \
decklink fbdev linsys vcd \
apexsink cdaudio cog dc1394 dirac directfb \
apexsink cdaudio dc1394 dirac directfb \
gsettings ladspa \
musepack musicbrainz nas neon ofa openal rsvg sdl sndfile timidity \
directdraw direct3d9 acm wininet \
@ -974,16 +974,6 @@ AG_GST_CHECK_FEATURE(CHROMAPRINT, [chromaprint], chromaprint, [
AC_SUBST(CHROMAPRINT_LIBS)
])
dnl *** Cog ***
translit(dnm, m, l) AM_CONDITIONAL(USE_COG, true)
AG_GST_CHECK_FEATURE(COG, [Cog plugin], cog, [
PKG_CHECK_MODULES(COG, libpng >= 1.2, HAVE_COG="yes", [
HAVE_COG="no"
])
AC_SUBST(COG_CFLAGS)
AC_SUBST(COG_LIBS)
])
dnl *** Curl ***
translit(dnm, m, l) AM_CONDITIONAL(USE_CURL, true)
AG_GST_CHECK_FEATURE(CURL, [Curl plugin], curl, [
@ -2316,7 +2306,6 @@ ext/bz2/Makefile
ext/cdaudio/Makefile
ext/celt/Makefile
ext/chromaprint/Makefile
ext/cog/Makefile
ext/curl/Makefile
ext/dc1394/Makefile
ext/dirac/Makefile

View file

@ -46,12 +46,6 @@ else
CHROMAPRINT_DIR=
endif
if USE_COG
COG_DIR=cog
else
COG_DIR=
endif
if USE_CURL
CURL_DIR=curl
else
@ -436,7 +430,6 @@ DIST_SUBDIRS = \
cdaudio \
celt \
chromaprint \
cog \
curl \
dc1394 \
dirac \

View file

@ -1,46 +0,0 @@
plugin_LTLIBRARIES = libgstcog.la
ORC_SOURCE=gstcogorc
include $(top_srcdir)/common/orc.mak
libgstcog_la_CFLAGS = \
-DCOG_ENABLE_UNSTABLE_API \
$(GST_PLUGINS_BAD_CFLAGS) \
-I$(srcdir)/.. \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(ORC_CFLAGS) \
$(COG_CFLAGS)
libgstcog_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(ORC_LIBS) \
$(COG_LIBS)
libgstcog_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(LIBM)
libgstcog_la_LIBTOOLFLAGS = --tag=disable-static
libgstcog_la_SOURCES = \
cog.h \
cogframe.c \
cogframe.h \
cogtables.c \
cogutils.h \
cogvirtframe.c \
cogvirtframe.h \
gstcog.c \
gstcogdownsample.c \
gstcogmse.c \
gstcogscale.c \
gstcogutils.c \
gstcogutils.h \
gstcms.h \
gstcms.c
nodist_libgstcog_la_SOURCES = $(ORC_NODIST_SOURCES)
noinst_PROGRAMS = generate_tables
generate_tables_SOURCES = generate_tables.c gstcms.c
generate_tables_CFLAGS = $(GST_CFLAGS)
generate_tables_LDADD = $(GST_LIBS) $(LIBM)

View file

@ -1,10 +0,0 @@
#ifndef __COG_COG_H__
#define __COG_COG_H__
#include <cog/cogutils.h>
void cog_init (void);
#endif

View file

@ -1,984 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cog/cog.h>
#include <cog/cogframe.h>
#include <cog/cogvirtframe.h>
#include "gstcogorc.h"
#include <gst/gst.h>
#include <stdlib.h>
#include <string.h>
/**
* cog_frame_new:
*
* Creates a new CogFrame object. The created frame is uninitialized
* and has no data storage associated with it. The caller must fill
* in the required information.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new (void)
{
CogFrame *frame;
frame = g_malloc0 (sizeof (*frame));
frame->refcount = 1;
return frame;
}
/**
* cog_frame_new_and_alloc:
*
* Creates a new CogFrame object with the requested size and format.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_and_alloc (CogMemoryDomain * domain, CogFrameFormat format,
int width, int height)
{
return cog_frame_new_and_alloc_extended (domain, format, width, height, 0);
}
CogFrame *
cog_frame_new_and_alloc_extended (CogMemoryDomain * domain,
CogFrameFormat format, int width, int height, int extension)
{
CogFrame *frame = cog_frame_new ();
int bytes_pp;
int h_shift, v_shift;
int chroma_width;
int chroma_height;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
frame->format = format;
frame->width = width;
frame->height = height;
frame->domain = domain;
frame->extension = extension;
if (COG_FRAME_IS_PACKED (format)) {
g_return_val_if_fail (extension == 0, NULL);
frame->components[0].format = format;
frame->components[0].width = width;
frame->components[0].height = height;
if (format == COG_FRAME_FORMAT_AYUV) {
frame->components[0].stride = width * 4;
} else {
frame->components[0].stride = ROUND_UP_POW2 (width, 1) * 2;
}
frame->components[0].length = frame->components[0].stride * height;
frame->regions[0] = g_malloc (frame->components[0].length);
frame->components[0].data = frame->regions[0];
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
switch (COG_FRAME_FORMAT_DEPTH (format)) {
case COG_FRAME_FORMAT_DEPTH_U8:
bytes_pp = 1;
break;
case COG_FRAME_FORMAT_DEPTH_S16:
bytes_pp = 2;
break;
case COG_FRAME_FORMAT_DEPTH_S32:
bytes_pp = 4;
break;
default:
g_return_val_if_reached (NULL);
bytes_pp = 0;
break;
}
h_shift = COG_FRAME_FORMAT_H_SHIFT (format);
v_shift = COG_FRAME_FORMAT_V_SHIFT (format);
chroma_width = ROUND_UP_SHIFT (width, h_shift);
chroma_height = ROUND_UP_SHIFT (height, v_shift);
frame->components[0].format = format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_4 ((width + extension * 2) * bytes_pp);
frame->components[0].length =
frame->components[0].stride * (frame->components[0].height +
extension * 2);
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
frame->components[1].format = format;
frame->components[1].width = chroma_width;
frame->components[1].height = chroma_height;
frame->components[1].stride =
ROUND_UP_4 ((chroma_width + extension * 2) * bytes_pp);
frame->components[1].length =
frame->components[1].stride * (frame->components[1].height +
extension * 2);
frame->components[1].v_shift = v_shift;
frame->components[1].h_shift = h_shift;
frame->components[2].format = format;
frame->components[2].width = chroma_width;
frame->components[2].height = chroma_height;
frame->components[2].stride =
ROUND_UP_4 ((chroma_width + extension * 2) * bytes_pp);
frame->components[2].length =
frame->components[2].stride * (frame->components[2].height +
extension * 2);
frame->components[2].v_shift = v_shift;
frame->components[2].h_shift = h_shift;
frame->regions[0] = g_malloc (frame->components[0].length +
frame->components[1].length + frame->components[2].length);
frame->components[0].data = COG_OFFSET (frame->regions[0],
frame->components[0].stride * extension + bytes_pp * extension);
frame->components[1].data = COG_OFFSET (frame->regions[0],
frame->components[0].length +
frame->components[1].stride * extension + bytes_pp * extension);
frame->components[2].data = COG_OFFSET (frame->regions[0],
frame->components[0].length + frame->components[1].length +
frame->components[2].stride * extension + bytes_pp * extension);
return frame;
}
/**
* cog_frame_new_from_data_YUY2:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in YUY2 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_YUY2 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_YUYV;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 1) * 2;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_YUY2:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in UYVY format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_UYVY (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_UYVY;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 1) * 2;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_YUY2:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in UYVY format,
* although the row stride is allowed to be different than what
* would normally be calculated from @width.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_UYVY_full (void *data, int width, int height,
int stride)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_UYVY;
frame->width = width;
frame->height = height;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = stride;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_AYUV:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in AYUV format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_AYUV (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_AYUV;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = width * 4;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_v216:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in v216 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_v216 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_v216;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 1) * 4;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_v210:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in v210 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_v210 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_v210;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ((width + 47) / 48) * 128;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_I420:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in I420 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_I420 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_U8_420;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 2);
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride *
ROUND_UP_POW2 (frame->components[0].height, 1);
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
frame->components[1].format = frame->format;
frame->components[1].width = ROUND_UP_SHIFT (width, 1);
frame->components[1].height = ROUND_UP_SHIFT (height, 1);
frame->components[1].stride = ROUND_UP_POW2 (frame->components[1].width, 2);
frame->components[1].length =
frame->components[1].stride * frame->components[1].height;
frame->components[1].data =
COG_OFFSET (frame->components[0].data, frame->components[0].length);
frame->components[1].v_shift = 1;
frame->components[1].h_shift = 1;
frame->components[2].format = frame->format;
frame->components[2].width = ROUND_UP_SHIFT (width, 1);
frame->components[2].height = ROUND_UP_SHIFT (height, 1);
frame->components[2].stride = ROUND_UP_POW2 (frame->components[2].width, 2);
frame->components[2].length =
frame->components[2].stride * frame->components[2].height;
frame->components[2].data =
COG_OFFSET (frame->components[1].data, frame->components[1].length);
frame->components[2].v_shift = 1;
frame->components[2].h_shift = 1;
return frame;
}
/**
* cog_frame_new_from_data_YV12:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in YV12 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_YV12 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_U8_420;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 2);
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride *
ROUND_UP_POW2 (frame->components[0].height, 1);
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
frame->components[2].format = frame->format;
frame->components[2].width = ROUND_UP_SHIFT (width, 1);
frame->components[2].height = ROUND_UP_SHIFT (height, 1);
frame->components[2].stride = ROUND_UP_POW2 (frame->components[2].width, 2);
frame->components[2].length =
frame->components[2].stride * frame->components[2].height;
frame->components[2].data =
COG_OFFSET (frame->components[0].data, frame->components[0].length);
frame->components[2].v_shift = 1;
frame->components[2].h_shift = 1;
frame->components[1].format = frame->format;
frame->components[1].width = ROUND_UP_SHIFT (width, 1);
frame->components[1].height = ROUND_UP_SHIFT (height, 1);
frame->components[1].stride = ROUND_UP_POW2 (frame->components[1].width, 2);
frame->components[1].length =
frame->components[1].stride * frame->components[1].height;
frame->components[1].data =
COG_OFFSET (frame->components[2].data, frame->components[2].length);
frame->components[1].v_shift = 1;
frame->components[1].h_shift = 1;
return frame;
}
/**
* cog_frame_new_from_data_Y42B:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in Y42B format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_Y42B (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_U8_422;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 2);
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride *
ROUND_UP_POW2 (frame->components[0].height, 1);
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
frame->components[1].format = frame->format;
frame->components[1].width = ROUND_UP_SHIFT (width, 1);
frame->components[1].height = height;
frame->components[1].stride = ROUND_UP_POW2 (frame->components[1].width, 2);
frame->components[1].length =
frame->components[1].stride * frame->components[1].height;
frame->components[1].data =
COG_OFFSET (frame->components[0].data, frame->components[0].length);
frame->components[1].v_shift = 0;
frame->components[1].h_shift = 1;
frame->components[2].format = frame->format;
frame->components[2].width = ROUND_UP_SHIFT (width, 1);
frame->components[2].height = height;
frame->components[2].stride = ROUND_UP_POW2 (frame->components[2].width, 2);
frame->components[2].length =
frame->components[2].stride * frame->components[2].height;
frame->components[2].data =
COG_OFFSET (frame->components[1].data, frame->components[1].length);
frame->components[2].v_shift = 0;
frame->components[2].h_shift = 1;
return frame;
}
/**
* cog_frame_new_from_data_Y444:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in Y444 format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_Y444 (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_U8_444;
frame->width = width;
frame->height = height;
frame->components[0].format = frame->format;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_POW2 (width, 4);
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride *
ROUND_UP_POW2 (frame->components[0].height, 1);
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
frame->components[1].format = frame->format;
frame->components[1].width = width;
frame->components[1].height = height;
frame->components[1].stride = ROUND_UP_POW2 (width, 4);
frame->components[1].length =
frame->components[1].stride * frame->components[1].height;
frame->components[1].data =
COG_OFFSET (frame->components[0].data, frame->components[0].length);
frame->components[1].v_shift = 0;
frame->components[1].h_shift = 0;
frame->components[2].format = frame->format;
frame->components[2].width = width;
frame->components[2].height = height;
frame->components[2].stride = ROUND_UP_POW2 (width, 4);
frame->components[2].length =
frame->components[2].stride * frame->components[2].height;
frame->components[2].data =
COG_OFFSET (frame->components[1].data, frame->components[1].length);
frame->components[2].v_shift = 0;
frame->components[2].h_shift = 0;
return frame;
}
/**
* cog_frame_new_from_data_RGB:
*
* Creates a new CogFrame object with the requested size using
* the data pointed to by @data. The data must be in RGB format.
* The data must remain for the lifetime of the CogFrame object.
* It is recommended to use cog_frame_set_free_callback() for
* notification when the data is no longer needed.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_new_from_data_RGB (void *data, int width, int height)
{
CogFrame *frame = cog_frame_new ();
frame->format = COG_FRAME_FORMAT_RGB;
frame->width = width;
frame->height = height;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = ROUND_UP_4 (width * 3);
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
static CogFrame *
cog_frame_new_from_data_RGB32 (void *data, int width, int height, int format)
{
CogFrame *frame = cog_frame_new ();
frame->format = format;
frame->width = width;
frame->height = height;
frame->components[0].width = width;
frame->components[0].height = height;
frame->components[0].stride = width * 4;
frame->components[0].data = data;
frame->components[0].length = frame->components[0].stride * height;
frame->components[0].v_shift = 0;
frame->components[0].h_shift = 0;
return frame;
}
CogFrame *
cog_frame_new_from_data_RGBx (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_RGBx);
}
CogFrame *
cog_frame_new_from_data_xRGB (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_xRGB);
}
CogFrame *
cog_frame_new_from_data_BGRx (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_BGRx);
}
CogFrame *
cog_frame_new_from_data_xBGR (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_xBGR);
}
CogFrame *
cog_frame_new_from_data_RGBA (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_RGBA);
}
CogFrame *
cog_frame_new_from_data_ARGB (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_ARGB);
}
CogFrame *
cog_frame_new_from_data_BGRA (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_BGRA);
}
CogFrame *
cog_frame_new_from_data_ABGR (void *data, int width, int height)
{
return cog_frame_new_from_data_RGB32 (data, width, height,
COG_FRAME_FORMAT_ABGR);
}
/**
* cog_frame_dup:
*
* Creates a new CogFrame object with the same dimensions and format
* as @frame, and copies the data from the @frame to the new object.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_dup (CogFrame * frame)
{
return cog_frame_dup_extended (frame, 0);
}
CogFrame *
cog_frame_dup_extended (CogFrame * frame, int extension)
{
CogFrame *dup_frame;
dup_frame = cog_frame_new_and_alloc_extended (frame->domain,
frame->format, frame->width, frame->height, extension);
cog_frame_convert (dup_frame, frame);
return dup_frame;
}
/**
* cog_frame_clone:
*
* Creates a new CogFrame object with the same dimensions and format
* as @frame. This function leaves the data in the new object
* uninitialized.
*
* Returns: a new CogFrame object
*/
CogFrame *
cog_frame_clone (CogMemoryDomain * domain, CogFrame * frame)
{
return cog_frame_new_and_alloc (domain,
frame->format, frame->width, frame->height);
}
/**
* cog_frame_ref:
* @frame: a frame object
*
* Increases the reference count of @frame.
*
* Returns: the value of @frame
*/
CogFrame *
cog_frame_ref (CogFrame * frame)
{
frame->refcount++;
return frame;
}
/**
* cog_frame_unref:
* @frame: a frame object
*
* Decreases the reference count of @frame. If the new reference
* count is 0, the frame is freed. If a frame free callback was
* set, this function is called.
*
* Returns: the value of @frame
*/
void
cog_frame_unref (CogFrame * frame)
{
int i;
g_return_if_fail (frame->refcount > 0);
frame->refcount--;
if (frame->refcount == 0) {
if (frame->free) {
frame->free (frame, frame->priv);
}
#ifdef HAVE_OPENGL
if (COG_FRAME_IS_OPENGL (frame)) {
cog_opengl_frame_cleanup (frame);
}
#endif
for (i = 0; i < 3; i++) {
if (frame->regions[i]) {
g_free (frame->regions[i]);
}
}
if (frame->virt_frame1) {
cog_frame_unref (frame->virt_frame1);
}
if (frame->virt_frame2) {
cog_frame_unref (frame->virt_frame2);
}
if (frame->virt_priv) {
g_free (frame->virt_priv);
}
g_free (frame);
}
}
/**
* cog_frame_set_free_callback:
* @frame: a frame object
* @free_func: the function to call when the frame is freed
* @priv: callback key
*
* Sets a function that will be called when the object reference
* count drops to zero and the object is freed.
*/
void
cog_frame_set_free_callback (CogFrame * frame,
CogFrameFreeFunc free_func, void *priv)
{
frame->free = free_func;
frame->priv = priv;
}
/**
* cog_frame_convert:
* @dest: destination frame
* @src: source frame
*
* Copies data from the source frame to the destination frame, converting
* formats if necessary. Only a few conversions are supported.
*/
void
cog_frame_convert (CogFrame * dest, CogFrame * src)
{
CogFrame *frame;
CogFrameFormat dest_format;
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
switch (dest->format) {
case COG_FRAME_FORMAT_YUYV:
case COG_FRAME_FORMAT_UYVY:
dest_format = COG_FRAME_FORMAT_U8_422;
break;
case COG_FRAME_FORMAT_AYUV:
case COG_FRAME_FORMAT_ARGB:
dest_format = COG_FRAME_FORMAT_U8_444;
break;
default:
dest_format = dest->format;
break;
}
cog_frame_ref (src);
frame = cog_virt_frame_new_unpack (src);
GST_DEBUG ("unpack %p", frame);
if (COG_FRAME_FORMAT_DEPTH (dest_format) !=
COG_FRAME_FORMAT_DEPTH (frame->format)) {
if (COG_FRAME_FORMAT_DEPTH (dest_format) == COG_FRAME_FORMAT_DEPTH_U8) {
frame = cog_virt_frame_new_convert_u8 (frame);
GST_DEBUG ("convert_u8 %p", frame);
} else if (COG_FRAME_FORMAT_DEPTH (dest_format) ==
COG_FRAME_FORMAT_DEPTH_S16) {
frame = cog_virt_frame_new_convert_s16 (frame);
GST_DEBUG ("convert_s16 %p", frame);
}
}
if ((dest_format & 3) != (frame->format & 3)) {
frame = cog_virt_frame_new_subsample (frame, dest_format,
COG_CHROMA_SITE_MPEG2, 2);
GST_DEBUG ("subsample %p", frame);
}
switch (dest->format) {
case COG_FRAME_FORMAT_YUYV:
frame = cog_virt_frame_new_pack_YUY2 (frame);
GST_DEBUG ("pack_YUY2 %p", frame);
break;
case COG_FRAME_FORMAT_UYVY:
frame = cog_virt_frame_new_pack_UYVY (frame);
GST_DEBUG ("pack_UYVY %p", frame);
break;
case COG_FRAME_FORMAT_AYUV:
frame = cog_virt_frame_new_pack_AYUV (frame);
GST_DEBUG ("pack_AYUV %p", frame);
break;
default:
break;
}
if (dest->width < frame->width || dest->height < frame->height) {
GST_DEBUG ("crop %d %d to %d %d",
frame->width, frame->height, dest->width, dest->height);
frame = cog_virt_frame_new_crop (frame, dest->width, dest->height);
GST_DEBUG ("crop %p", frame);
}
if (dest->width > src->width || dest->height > src->height) {
frame = cog_virt_frame_new_edgeextend (frame, dest->width, dest->height);
GST_DEBUG ("edgeextend %p", frame);
}
cog_virt_frame_render (frame, dest);
cog_frame_unref (frame);
}
#if 0
void
cog_frame_md5 (CogFrame * frame, uint32_t * state)
{
uint8_t *line;
int x, y, k;
state[0] = 0x67452301;
state[1] = 0xefcdab89;
state[2] = 0x98badcfe;
state[3] = 0x10325476;
x = 0;
y = 0;
k = 0;
for (k = 0; k < 3; k++) {
for (y = 0; y < frame->components[k].height; y++) {
line = COG_FRAME_DATA_GET_LINE (&frame->components[k], y);
for (x = 0; x + 63 < frame->components[k].width; x += 64) {
oil_md5 (state, (uint32_t *) (line + x));
}
if (x < frame->components[k].width) {
uint8_t tmp[64];
int left;
left = frame->components[k].width - x;
memcpy (tmp, line + x, left);
memset (tmp + left, 0, 64 - left);
oil_md5 (state, (uint32_t *) tmp);
}
}
}
GST_DEBUG
("md5 %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
state[0] & 0xff, (state[0] >> 8) & 0xff, (state[0] >> 16) & 0xff,
(state[0] >> 24) & 0xff, state[1] & 0xff, (state[1] >> 8) & 0xff,
(state[1] >> 16) & 0xff, (state[1] >> 24) & 0xff, state[2] & 0xff,
(state[2] >> 8) & 0xff, (state[2] >> 16) & 0xff, (state[2] >> 24) & 0xff,
state[3] & 0xff, (state[3] >> 8) & 0xff, (state[3] >> 16) & 0xff,
(state[3] >> 24) & 0xff);
}
#endif
void
cog_frame_split_fields (CogFrame * dest1, CogFrame * dest2, CogFrame * src)
{
CogFrame src_tmp;
g_return_if_fail ((src->height & 1) == 0);
memcpy (&src_tmp, src, sizeof (src_tmp));
src_tmp.height = src->height / 2;
src_tmp.components[0].stride *= 2;
src_tmp.components[1].stride *= 2;
src_tmp.components[2].stride *= 2;
cog_frame_convert (dest1, &src_tmp);
src_tmp.components[0].data = COG_FRAME_DATA_GET_LINE (&src->components[0], 1);
src_tmp.components[1].data = COG_FRAME_DATA_GET_LINE (&src->components[1], 1);
src_tmp.components[2].data = COG_FRAME_DATA_GET_LINE (&src->components[2], 1);
cog_frame_convert (dest2, &src_tmp);
}
void
cog_frame_get_subdata (CogFrame * frame, CogFrameData * fd,
int component, int x, int y)
{
CogFrameData *comp = frame->components + component;
g_return_if_fail (COG_FRAME_FORMAT_DEPTH (comp->format) ==
COG_FRAME_FORMAT_DEPTH_U8);
fd->format = comp->format;
fd->data = COG_FRAME_DATA_GET_PIXEL_U8 (comp, x, y);
fd->stride = comp->stride;
fd->width = MAX (0, comp->width - x);
fd->height = MAX (0, comp->height - y);
fd->h_shift = comp->h_shift;
fd->v_shift = comp->v_shift;
}

View file

@ -1,208 +0,0 @@
#ifndef __COG_FRAME_H__
#define __COG_FRAME_H__
#include <cog/cogutils.h>
COG_BEGIN_DECLS
typedef struct _CogFrame CogFrame;
typedef struct _CogFrameData CogFrameData;
typedef struct _CogUpsampledFrame CogUpsampledFrame;
typedef void (*CogFrameFreeFunc)(CogFrame *frame, void *priv);
typedef void (*CogFrameRenderFunc)(CogFrame *frame, void *dest, int component, int i);
typedef enum _CogColorMatrix {
COG_COLOR_MATRIX_UNKNOWN = 0,
COG_COLOR_MATRIX_HDTV,
COG_COLOR_MATRIX_SDTV
} CogColorMatrix;
typedef enum _CogChromaSite {
COG_CHROMA_SITE_UNKNOWN = 0,
COG_CHROMA_SITE_MPEG2 = 1,
COG_CHROMA_SITE_JPEG
} CogChromaSite;
/* bit pattern:
* 0x100 - 0: normal, 1: indirect (packed)
* 0x001 - horizontal chroma subsampling: 0: 1, 1: 2
* 0x002 - vertical chroma subsampling: 0: 1, 1: 2
* 0x00c - depth: 0: u8, 1: s16, 2: s32
* */
typedef enum _CogFrameFormat {
COG_FRAME_FORMAT_U8_444 = 0x00,
COG_FRAME_FORMAT_U8_422 = 0x01,
COG_FRAME_FORMAT_U8_420 = 0x03,
COG_FRAME_FORMAT_S16_444 = 0x04,
COG_FRAME_FORMAT_S16_422 = 0x05,
COG_FRAME_FORMAT_S16_420 = 0x07,
COG_FRAME_FORMAT_S32_444 = 0x08,
COG_FRAME_FORMAT_S32_422 = 0x09,
COG_FRAME_FORMAT_S32_420 = 0x0b,
/* indirectly supported */
COG_FRAME_FORMAT_YUYV = 0x100, /* YUYV order */
COG_FRAME_FORMAT_UYVY = 0x101, /* UYVY order */
COG_FRAME_FORMAT_AYUV = 0x102,
COG_FRAME_FORMAT_RGB = 0x104,
COG_FRAME_FORMAT_v216 = 0x105,
COG_FRAME_FORMAT_v210 = 0x106,
COG_FRAME_FORMAT_RGBx = 0x110,
COG_FRAME_FORMAT_xRGB = 0x111,
COG_FRAME_FORMAT_BGRx = 0x112,
COG_FRAME_FORMAT_xBGR = 0x113,
COG_FRAME_FORMAT_RGBA = 0x114,
COG_FRAME_FORMAT_ARGB = 0x115,
COG_FRAME_FORMAT_BGRA = 0x116,
COG_FRAME_FORMAT_ABGR = 0x117,
} CogFrameFormat;
#define COG_FRAME_FORMAT_DEPTH(format) ((format) & 0xc)
#define COG_FRAME_FORMAT_DEPTH_U8 0x00
#define COG_FRAME_FORMAT_DEPTH_S16 0x04
#define COG_FRAME_FORMAT_DEPTH_S32 0x08
#define COG_FRAME_FORMAT_H_SHIFT(format) ((format) & 0x1)
#define COG_FRAME_FORMAT_V_SHIFT(format) (((format)>>1) & 0x1)
#define COG_FRAME_IS_PACKED(format) (((format)>>8) & 0x1)
#define COG_FRAME_CACHE_SIZE 8
struct _CogFrameData {
CogFrameFormat format;
void *data;
int stride;
int width;
int height;
int length;
int h_shift;
int v_shift;
};
struct _CogFrame {
int refcount;
CogFrameFreeFunc free;
CogMemoryDomain *domain;
void *regions[3];
void *priv;
CogFrameFormat format;
int width;
int height;
CogFrameData components[3];
int is_virtual;
int cache_offset[3];
int cached_lines[3][COG_FRAME_CACHE_SIZE];
CogFrame *virt_frame1;
CogFrame *virt_frame2;
void (*render_line) (CogFrame *frame, void *dest, int component, int i);
void *virt_priv;
void *virt_priv2;
int param1;
int param2;
int extension;
};
struct _CogUpsampledFrame {
CogFrame *frames[4];
void *components[3];
};
#define COG_FRAME_DATA_GET_LINE(fd,i) (COG_OFFSET((fd)->data,(fd)->stride*(i)))
#define COG_FRAME_DATA_GET_PIXEL_U8(fd,i,j) ((uint8_t *)COG_OFFSET((fd)->data,(fd)->stride*(j)+(i)))
#define COG_FRAME_DATA_GET_PIXEL_S16(fd,i,j) ((int16_t *)COG_OFFSET((fd)->data,(fd)->stride*(j)+(i)*sizeof(int16_t)))
CogFrame * cog_frame_new (void);
CogFrame * cog_frame_new_and_alloc (CogMemoryDomain *domain,
CogFrameFormat format, int width, int height);
CogFrame * cog_frame_new_from_data_I420 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_YV12 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_YUY2 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_UYVY (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_UYVY_full (void *data, int width, int height, int stride);
CogFrame * cog_frame_new_from_data_AYUV (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_v216 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_v210 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_Y42B (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_Y444 (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_RGB (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_RGBx (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_xRGB (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_BGRx (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_xBGR (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_RGBA (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_ARGB (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_BGRA (void *data, int width, int height);
CogFrame * cog_frame_new_from_data_ABGR (void *data, int width, int height);
void cog_frame_set_free_callback (CogFrame *frame,
CogFrameFreeFunc free_func, void *priv);
void cog_frame_unref (CogFrame *frame);
CogFrame *cog_frame_ref (CogFrame *frame);
CogFrame *cog_frame_dup (CogFrame *frame);
CogFrame *cog_frame_clone (CogMemoryDomain *domain, CogFrame *frame);
void cog_frame_convert (CogFrame *dest, CogFrame *src);
void cog_frame_add (CogFrame *dest, CogFrame *src);
void cog_frame_subtract (CogFrame *dest, CogFrame *src);
void cog_frame_shift_left (CogFrame *frame, int shift);
void cog_frame_shift_right (CogFrame *frame, int shift);
//void cog_frame_downsample (CogFrame *dest, CogFrame *src);
void cog_frame_upsample_horiz (CogFrame *dest, CogFrame *src);
void cog_frame_upsample_vert (CogFrame *dest, CogFrame *src);
double cog_frame_calculate_average_luma (CogFrame *frame);
CogFrame * cog_frame_convert_to_444 (CogFrame *frame);
void cog_frame_md5 (CogFrame *frame, uint32_t *state);
CogFrame * cog_frame_new_and_alloc_extended (CogMemoryDomain *domain,
CogFrameFormat format, int width, int height, int extension);
CogFrame *cog_frame_dup_extended (CogFrame *frame, int extension);
void cog_frame_edge_extend (CogFrame *frame, int width, int height);
void cog_frame_zero_extend (CogFrame *frame, int width, int height);
void cog_frame_mark (CogFrame *frame, int value);
void cog_frame_mc_edgeextend (CogFrame *frame);
void cog_frame_data_get_codeblock (CogFrameData *dest, CogFrameData *src,
int x, int y, int horiz_codeblocks, int vert_codeblocks);
CogUpsampledFrame * cog_upsampled_frame_new (CogFrame *frame);
void cog_upsampled_frame_free (CogUpsampledFrame *df);
void cog_upsampled_frame_upsample (CogUpsampledFrame *df);
#ifdef ENABLE_MOTION_REF
int cog_upsampled_frame_get_pixel_prec0 (CogUpsampledFrame *upframe, int k,
int x, int y);
int cog_upsampled_frame_get_pixel_prec1 (CogUpsampledFrame *upframe, int k,
int x, int y);
int cog_upsampled_frame_get_pixel_prec3 (CogUpsampledFrame *upframe, int k,
int x, int y);
int cog_upsampled_frame_get_pixel_precN (CogUpsampledFrame *upframe, int k,
int x, int y, int mv_precision);
#endif
void cog_upsampled_frame_get_block_precN (CogUpsampledFrame *upframe, int k,
int x, int y, int prec, CogFrameData *dest);
void cog_upsampled_frame_get_block_fast_precN (CogUpsampledFrame *upframe, int k,
int x, int y, int prec, CogFrameData *dest, CogFrameData *fd);
void cog_upsampled_frame_get_subdata_prec0 (CogUpsampledFrame *upframe,
int k, int x, int y, CogFrameData *fd);
void cog_upsampled_frame_get_subdata_prec1 (CogUpsampledFrame *upframe,
int k, int x, int y, CogFrameData *fd);
void cog_frame_get_subdata (CogFrame *frame, CogFrameData *fd,
int comp, int x, int y);
void cog_frame_split_fields (CogFrame *dest1, CogFrame *dest2, CogFrame *src);
COG_END_DECLS
#endif

View file

@ -1,516 +0,0 @@
/* This file is autogenerated. Do not edit.*/
#include <glib.h>
gint8 cog_resample_table_4tap[256][4] = {
{0, 64, 0, 0}
, /* 0.000 0.000 0.000 -0.000 64 */
{0, 64, 0, 0}
, /* -0.248 -0.002 0.251 -0.001 64 */
{0, 64, 0, 0}
, /* -0.492 -0.008 0.504 -0.004 64 */
{-1, 64, 1, 0}
, /* 0.267 -0.017 -0.241 -0.009 64 */
{-1, 64, 1, 0}
, /* 0.031 -0.031 0.015 -0.015 64 */
{-1, 64, 1, 0}
, /* -0.202 -0.048 0.274 -0.024 64 */
{-1, 64, 1, 0}
, /* -0.431 -0.069 0.534 -0.034 64 */
{-2, 64, 2, 0}
, /* 0.344 -0.094 -0.203 -0.047 64 */
{-2, 64, 2, 0}
, /* 0.123 -0.123 0.061 -0.061 64 */
{-2, 64, 2, 0}
, /* -0.095 -0.155 0.326 -0.076 64 */
{-2, 64, 2, 0}
, /* -0.309 -0.191 0.594 -0.094 64 */
{-3, 64, 3, 0}
, /* 0.481 -0.231 -0.137 -0.113 64 */
{-3, 64, 3, 0}
, /* 0.275 -0.275 0.134 -0.134 64 */
{-3, 64, 3, 0}
, /* 0.072 -0.322 0.407 -0.157 64 */
{-3, 63, 4, 0}
, /* -0.128 0.628 -0.319 -0.181 64 */
{-3, 63, 4, 0}
, /* -0.323 0.573 -0.043 -0.207 64 */
{-4, 64, 4, 0}
, /* 0.484 -0.484 0.234 -0.234 64 */
{-4, 63, 5, 0}
, /* 0.296 0.454 -0.487 -0.263 64 */
{-4, 63, 5, 0}
, /* 0.111 0.389 -0.206 -0.294 64 */
{-4, 63, 5, 0}
, /* -0.071 0.321 0.076 -0.326 64 */
{-4, 63, 5, 0}
, /* -0.249 0.249 0.360 -0.360 64 */
{-5, 63, 6, 0}
, /* 0.576 0.174 -0.355 -0.395 64 */
{-5, 63, 6, 0}
, /* 0.405 0.095 -0.068 -0.432 64 */
{-5, 63, 6, 0}
, /* 0.237 0.013 0.220 -0.470 64 */
{-5, 63, 7, -1}
, /* 0.072 -0.072 -0.490 0.490 64 */
{-5, 63, 7, -1}
, /* -0.089 -0.161 -0.199 0.449 64 */
{-5, 63, 7, -1}
, /* -0.247 -0.253 0.093 0.407 64 */
{-5, 63, 7, -1}
, /* -0.401 -0.349 0.387 0.363 64 */
{-6, 63, 8, -1}
, /* 0.448 -0.448 -0.318 0.318 64 */
{-6, 63, 8, -1}
, /* 0.300 -0.550 -0.022 0.272 64 */
{-6, 63, 8, -1}
, /* 0.155 -0.655 0.276 0.224 64 */
{-6, 62, 9, -1}
, /* 0.013 0.237 -0.425 0.175 64 */
{-6, 62, 9, -1}
, /* -0.125 0.125 -0.125 0.125 64 */
{-6, 62, 9, -1}
, /* -0.260 0.010 0.176 0.074 64 */
{-6, 62, 9, -1}
, /* -0.392 -0.108 0.479 0.021 64 */
{-7, 62, 10, -1}
, /* 0.479 -0.229 -0.217 -0.033 64 */
{-7, 62, 10, -1}
, /* 0.353 -0.353 0.088 -0.088 64 */
{-7, 62, 10, -1}
, /* 0.231 -0.481 0.394 -0.144 64 */
{-7, 61, 11, -1}
, /* 0.111 0.389 -0.299 -0.201 64 */
{-7, 61, 11, -1}
, /* -0.006 0.256 0.009 -0.259 64 */
{-7, 61, 11, -1}
, /* -0.119 0.119 0.318 -0.318 64 */
{-7, 61, 12, -2}
, /* -0.230 -0.020 -0.371 0.621 64 */
{-7, 61, 12, -2}
, /* -0.337 -0.163 -0.060 0.560 64 */
{-7, 61, 12, -2}
, /* -0.442 -0.308 0.252 0.498 64 */
{-8, 61, 13, -2}
, /* 0.456 -0.456 -0.434 0.434 64 */
{-8, 61, 13, -2}
, /* 0.357 -0.607 -0.120 0.370 64 */
{-8, 60, 13, -1}
, /* 0.262 0.238 0.195 -0.695 64 */
{-8, 60, 14, -2}
, /* 0.168 0.082 -0.489 0.239 64 */
{-8, 60, 14, -2}
, /* 0.078 -0.078 -0.172 0.172 64 */
{-8, 60, 14, -2}
, /* -0.009 -0.241 0.146 0.104 64 */
{-8, 60, 14, -2}
, /* -0.094 -0.406 0.465 0.035 64 */
{-8, 59, 15, -2}
, /* -0.176 0.426 -0.216 -0.034 64 */
{-8, 59, 15, -2}
, /* -0.255 0.255 0.104 -0.104 64 */
{-8, 59, 15, -2}
, /* -0.332 0.082 0.425 -0.175 64 */
{-9, 59, 16, -2}
, /* 0.595 -0.095 -0.253 -0.247 64 */
{-9, 59, 16, -2}
, /* 0.524 -0.274 0.069 -0.319 64 */
{-9, 59, 16, -2}
, /* 0.455 -0.455 0.393 -0.393 64 */
{-9, 58, 17, -2}
, /* 0.389 0.361 -0.284 -0.466 64 */
{-9, 58, 17, -2}
, /* 0.326 0.174 0.041 -0.541 64 */
{-9, 58, 17, -2}
, /* 0.265 -0.015 0.366 -0.616 64 */
{-9, 58, 18, -3}
, /* 0.207 -0.207 -0.308 0.308 64 */
{-9, 58, 18, -3}
, /* 0.152 -0.402 0.018 0.232 64 */
{-9, 58, 18, -3}
, /* 0.099 -0.599 0.345 0.155 64 */
{-9, 57, 19, -3}
, /* 0.048 0.202 -0.328 0.078 64 */
{-9, 57, 19, -3}
, /* 0.000 0.000 0.000 0.000 64 */
{-9, 57, 19, -3}
, /* -0.046 -0.204 0.328 -0.078 64 */
{-9, 56, 20, -3}
, /* -0.089 0.589 -0.343 -0.157 64 */
{-9, 56, 20, -3}
, /* -0.130 0.380 -0.014 -0.236 64 */
{-9, 56, 20, -3}
, /* -0.168 0.168 0.316 -0.316 64 */
{-9, 56, 21, -4}
, /* -0.204 -0.046 -0.354 0.604 64 */
{-9, 56, 21, -4}
, /* -0.238 -0.262 -0.023 0.523 64 */
{-9, 56, 21, -4}
, /* -0.270 -0.480 0.308 0.442 64 */
{-9, 55, 22, -4}
, /* -0.299 0.299 -0.361 0.361 64 */
{-9, 55, 22, -4}
, /* -0.326 0.076 -0.030 0.280 64 */
{-9, 55, 22, -4}
, /* -0.350 -0.150 0.302 0.198 64 */
{-9, 54, 23, -4}
, /* -0.373 0.623 -0.366 0.116 64 */
{-9, 54, 23, -4}
, /* -0.393 0.393 -0.034 0.034 64 */
{-9, 54, 23, -4}
, /* -0.411 0.161 0.299 -0.049 64 */
{-10, 54, 24, -4}
, /* 0.573 -0.073 -0.369 -0.131 64 */
{-10, 54, 24, -4}
, /* 0.559 -0.309 -0.036 -0.214 64 */
{-9, 53, 24, -4}
, /* -0.453 0.453 0.297 -0.297 64 */
{-10, 53, 25, -4}
, /* 0.537 0.213 -0.370 -0.380 64 */
{-10, 53, 25, -4}
, /* 0.530 -0.030 -0.037 -0.463 64 */
{-9, 53, 25, -5}
, /* -0.476 -0.274 0.296 0.454 64 */
{-9, 52, 26, -5}
, /* -0.480 0.480 -0.370 0.370 64 */
{-9, 52, 26, -5}
, /* -0.481 0.231 -0.037 0.287 64 */
{-9, 52, 26, -5}
, /* -0.481 -0.019 0.296 0.204 64 */
{-10, 52, 27, -5}
, /* 0.521 -0.271 -0.370 0.120 64 */
{-9, 51, 27, -5}
, /* -0.475 0.475 -0.037 0.037 64 */
{-9, 51, 27, -5}
, /* -0.469 0.219 0.296 -0.046 64 */
{-10, 51, 28, -5}
, /* 0.539 -0.039 -0.371 -0.129 64 */
{-10, 51, 28, -5}
, /* 0.549 -0.299 -0.038 -0.212 64 */
{-9, 50, 28, -5}
, /* -0.439 0.439 0.295 -0.295 64 */
{-10, 50, 29, -5}
, /* 0.574 0.176 -0.372 -0.378 64 */
{-9, 50, 29, -6}
, /* -0.411 -0.089 -0.040 0.540 64 */
{-9, 50, 29, -6}
, /* -0.394 -0.356 0.293 0.457 64 */
{-9, 49, 30, -6}
, /* -0.375 0.375 -0.375 0.375 64 */
{-9, 49, 30, -6}
, /* -0.355 0.105 -0.043 0.293 64 */
{-9, 49, 30, -6}
, /* -0.333 -0.167 0.289 0.211 64 */
{-9, 48, 31, -6}
, /* -0.309 0.559 -0.380 0.130 64 */
{-9, 48, 31, -6}
, /* -0.283 0.283 -0.049 0.049 64 */
{-9, 48, 31, -6}
, /* -0.256 0.006 0.282 -0.032 64 */
{-9, 48, 31, -6}
, /* -0.228 -0.272 0.612 -0.112 64 */
{-9, 47, 32, -6}
, /* -0.198 0.448 -0.058 -0.192 64 */
{-9, 47, 32, -6}
, /* -0.166 0.166 0.271 -0.271 64 */
{-9, 47, 32, -6}
, /* -0.133 -0.117 0.601 -0.351 64 */
{-9, 47, 33, -7}
, /* -0.098 -0.402 -0.071 0.571 64 */
{-9, 46, 33, -6}
, /* -0.062 0.312 0.257 -0.507 64 */
{-9, 46, 34, -7}
, /* -0.024 0.024 -0.415 0.415 64 */
{-9, 46, 34, -7}
, /* 0.015 -0.265 -0.088 0.338 64 */
{-9, 46, 34, -7}
, /* 0.055 -0.555 0.239 0.261 64 */
{-9, 45, 35, -7}
, /* 0.097 0.153 -0.435 0.185 64 */
{-9, 45, 35, -7}
, /* 0.141 -0.141 -0.109 0.109 64 */
{-9, 45, 35, -7}
, /* 0.185 -0.435 0.216 0.034 64 */
{-9, 44, 36, -7}
, /* 0.231 0.269 -0.460 -0.040 64 */
{-9, 44, 36, -7}
, /* 0.278 -0.028 -0.137 -0.113 64 */
{-9, 44, 36, -7}
, /* 0.327 -0.327 0.186 -0.186 64 */
{-9, 43, 37, -7}
, /* 0.377 0.373 -0.492 -0.258 64 */
{-9, 43, 37, -7}
, /* 0.428 0.072 -0.170 -0.330 64 */
{-9, 43, 37, -7}
, /* 0.480 -0.230 0.151 -0.401 64 */
{-8, 42, 37, -7}
, /* -0.467 0.467 0.471 -0.471 64 */
{-8, 42, 38, -8}
, /* -0.412 0.162 -0.210 0.460 64 */
{-8, 42, 38, -8}
, /* -0.357 -0.143 0.108 0.392 64 */
{-8, 42, 38, -8}
, /* -0.300 -0.450 0.426 0.324 64 */
{-8, 41, 39, -8}
, /* -0.242 0.242 -0.258 0.258 64 */
{-8, 41, 39, -8}
, /* -0.183 -0.067 0.058 0.192 64 */
{-8, 41, 39, -8}
, /* -0.123 -0.377 0.373 0.127 64 */
{-8, 40, 40, -8}
, /* -0.062 0.312 -0.313 0.063 64 */
{-8, 40, 40, -8}
, /* 0.000 0.000 0.000 0.000 64 */
{-8, 40, 40, -8}
, /* 0.063 -0.313 0.312 -0.062 64 */
{-8, 39, 41, -8}
, /* 0.127 0.373 -0.377 -0.123 64 */
{-8, 39, 41, -8}
, /* 0.192 0.058 -0.067 -0.183 64 */
{-8, 39, 41, -8}
, /* 0.258 -0.258 0.242 -0.242 64 */
{-8, 38, 42, -8}
, /* 0.324 0.426 -0.450 -0.300 64 */
{-8, 38, 42, -8}
, /* 0.392 0.108 -0.143 -0.357 64 */
{-8, 38, 42, -8}
, /* 0.460 -0.210 0.162 -0.412 64 */
{-7, 37, 42, -8}
, /* -0.471 0.471 0.467 -0.467 64 */
{-7, 37, 43, -9}
, /* -0.401 0.151 -0.230 0.480 64 */
{-7, 37, 43, -9}
, /* -0.330 -0.170 0.072 0.428 64 */
{-7, 37, 43, -9}
, /* -0.258 -0.492 0.373 0.377 64 */
{-7, 36, 44, -9}
, /* -0.186 0.186 -0.327 0.327 64 */
{-7, 36, 44, -9}
, /* -0.113 -0.137 -0.028 0.278 64 */
{-7, 36, 44, -9}
, /* -0.040 -0.460 0.269 0.231 64 */
{-7, 35, 45, -9}
, /* 0.034 0.216 -0.435 0.185 64 */
{-7, 35, 45, -9}
, /* 0.109 -0.109 -0.141 0.141 64 */
{-7, 35, 45, -9}
, /* 0.185 -0.435 0.153 0.097 64 */
{-7, 34, 46, -9}
, /* 0.261 0.239 -0.555 0.055 64 */
{-7, 34, 46, -9}
, /* 0.338 -0.088 -0.265 0.015 64 */
{-7, 34, 46, -9}
, /* 0.415 -0.415 0.024 -0.024 64 */
{-6, 33, 46, -9}
, /* -0.507 0.257 0.312 -0.062 64 */
{-7, 33, 47, -9}
, /* 0.571 -0.071 -0.402 -0.098 64 */
{-6, 32, 47, -9}
, /* -0.351 0.601 -0.117 -0.133 64 */
{-6, 32, 47, -9}
, /* -0.271 0.271 0.166 -0.166 64 */
{-6, 32, 47, -9}
, /* -0.192 -0.058 0.448 -0.198 64 */
{-6, 31, 48, -9}
, /* -0.112 0.612 -0.272 -0.228 64 */
{-6, 31, 48, -9}
, /* -0.032 0.282 0.006 -0.256 64 */
{-6, 31, 48, -9}
, /* 0.049 -0.049 0.283 -0.283 64 */
{-6, 31, 48, -9}
, /* 0.130 -0.380 0.559 -0.309 64 */
{-6, 30, 49, -9}
, /* 0.211 0.289 -0.167 -0.333 64 */
{-6, 30, 49, -9}
, /* 0.293 -0.043 0.105 -0.355 64 */
{-6, 30, 49, -9}
, /* 0.375 -0.375 0.375 -0.375 64 */
{-6, 29, 50, -9}
, /* 0.457 0.293 -0.356 -0.394 64 */
{-6, 29, 50, -9}
, /* 0.540 -0.040 -0.089 -0.411 64 */
{-5, 29, 50, -10}
, /* -0.378 -0.372 0.176 0.574 64 */
{-5, 28, 50, -9}
, /* -0.295 0.295 0.439 -0.439 64 */
{-5, 28, 51, -10}
, /* -0.212 -0.038 -0.299 0.549 64 */
{-5, 28, 51, -10}
, /* -0.129 -0.371 -0.039 0.539 64 */
{-5, 27, 51, -9}
, /* -0.046 0.296 0.219 -0.469 64 */
{-5, 27, 51, -9}
, /* 0.037 -0.037 0.475 -0.475 64 */
{-5, 27, 52, -10}
, /* 0.120 -0.370 -0.271 0.521 64 */
{-5, 26, 52, -9}
, /* 0.204 0.296 -0.019 -0.481 64 */
{-5, 26, 52, -9}
, /* 0.287 -0.037 0.231 -0.481 64 */
{-5, 26, 52, -9}
, /* 0.370 -0.370 0.480 -0.480 64 */
{-5, 25, 53, -9}
, /* 0.454 0.296 -0.274 -0.476 64 */
{-4, 25, 53, -10}
, /* -0.463 -0.037 -0.030 0.530 64 */
{-4, 25, 53, -10}
, /* -0.380 -0.370 0.213 0.537 64 */
{-4, 24, 53, -9}
, /* -0.297 0.297 0.453 -0.453 64 */
{-4, 24, 54, -10}
, /* -0.214 -0.036 -0.309 0.559 64 */
{-4, 24, 54, -10}
, /* -0.131 -0.369 -0.073 0.573 64 */
{-4, 23, 54, -9}
, /* -0.049 0.299 0.161 -0.411 64 */
{-4, 23, 54, -9}
, /* 0.034 -0.034 0.393 -0.393 64 */
{-4, 23, 54, -9}
, /* 0.116 -0.366 0.623 -0.373 64 */
{-4, 22, 55, -9}
, /* 0.198 0.302 -0.150 -0.350 64 */
{-4, 22, 55, -9}
, /* 0.280 -0.030 0.076 -0.326 64 */
{-4, 22, 55, -9}
, /* 0.361 -0.361 0.299 -0.299 64 */
{-4, 21, 56, -9}
, /* 0.442 0.308 -0.480 -0.270 64 */
{-4, 21, 56, -9}
, /* 0.523 -0.023 -0.262 -0.238 64 */
{-4, 21, 56, -9}
, /* 0.604 -0.354 -0.046 -0.204 64 */
{-3, 20, 56, -9}
, /* -0.316 0.316 0.168 -0.168 64 */
{-3, 20, 56, -9}
, /* -0.236 -0.014 0.380 -0.130 64 */
{-3, 20, 56, -9}
, /* -0.157 -0.343 0.589 -0.089 64 */
{-3, 19, 57, -9}
, /* -0.078 0.328 -0.204 -0.046 64 */
{-3, 19, 57, -9}
, /* 0.000 0.000 0.000 0.000 64 */
{-3, 19, 57, -9}
, /* 0.078 -0.328 0.202 0.048 64 */
{-3, 18, 58, -9}
, /* 0.155 0.345 -0.599 0.099 64 */
{-3, 18, 58, -9}
, /* 0.232 0.018 -0.402 0.152 64 */
{-3, 18, 58, -9}
, /* 0.308 -0.308 -0.207 0.207 64 */
{-2, 17, 58, -9}
, /* -0.616 0.366 -0.015 0.265 64 */
{-2, 17, 58, -9}
, /* -0.541 0.041 0.174 0.326 64 */
{-2, 17, 58, -9}
, /* -0.466 -0.284 0.361 0.389 64 */
{-2, 16, 59, -9}
, /* -0.393 0.393 -0.455 0.455 64 */
{-2, 16, 59, -9}
, /* -0.319 0.069 -0.274 0.524 64 */
{-2, 16, 59, -9}
, /* -0.247 -0.253 -0.095 0.595 64 */
{-2, 15, 59, -8}
, /* -0.175 0.425 0.082 -0.332 64 */
{-2, 15, 59, -8}
, /* -0.104 0.104 0.255 -0.255 64 */
{-2, 15, 59, -8}
, /* -0.034 -0.216 0.426 -0.176 64 */
{-2, 14, 60, -8}
, /* 0.035 0.465 -0.406 -0.094 64 */
{-2, 14, 60, -8}
, /* 0.104 0.146 -0.241 -0.009 64 */
{-2, 14, 60, -8}
, /* 0.172 -0.172 -0.078 0.078 64 */
{-2, 14, 60, -8}
, /* 0.239 -0.489 0.082 0.168 64 */
{-1, 13, 60, -8}
, /* -0.695 0.195 0.238 0.262 64 */
{-2, 13, 61, -8}
, /* 0.370 -0.120 -0.607 0.357 64 */
{-2, 13, 61, -8}
, /* 0.434 -0.434 -0.456 0.456 64 */
{-2, 12, 61, -7}
, /* 0.498 0.252 -0.308 -0.442 64 */
{-2, 12, 61, -7}
, /* 0.560 -0.060 -0.163 -0.337 64 */
{-2, 12, 61, -7}
, /* 0.621 -0.371 -0.020 -0.230 64 */
{-1, 11, 61, -7}
, /* -0.318 0.318 0.119 -0.119 64 */
{-1, 11, 61, -7}
, /* -0.259 0.009 0.256 -0.006 64 */
{-1, 11, 61, -7}
, /* -0.201 -0.299 0.389 0.111 64 */
{-1, 10, 62, -7}
, /* -0.144 0.394 -0.481 0.231 64 */
{-1, 10, 62, -7}
, /* -0.088 0.088 -0.353 0.353 64 */
{-1, 10, 62, -7}
, /* -0.033 -0.217 -0.229 0.479 64 */
{-1, 9, 62, -6}
, /* 0.021 0.479 -0.108 -0.392 64 */
{-1, 9, 62, -6}
, /* 0.074 0.176 0.010 -0.260 64 */
{-1, 9, 62, -6}
, /* 0.125 -0.125 0.125 -0.125 64 */
{-1, 9, 62, -6}
, /* 0.175 -0.425 0.237 0.013 64 */
{-1, 8, 63, -6}
, /* 0.224 0.276 -0.655 0.155 64 */
{-1, 8, 63, -6}
, /* 0.272 -0.022 -0.550 0.300 64 */
{-1, 8, 63, -6}
, /* 0.318 -0.318 -0.448 0.448 64 */
{-1, 7, 63, -5}
, /* 0.363 0.387 -0.349 -0.401 64 */
{-1, 7, 63, -5}
, /* 0.407 0.093 -0.253 -0.247 64 */
{-1, 7, 63, -5}
, /* 0.449 -0.199 -0.161 -0.089 64 */
{-1, 7, 63, -5}
, /* 0.490 -0.490 -0.072 0.072 64 */
{0, 6, 63, -5}
, /* -0.470 0.220 0.013 0.237 64 */
{0, 6, 63, -5}
, /* -0.432 -0.068 0.095 0.405 64 */
{0, 6, 63, -5}
, /* -0.395 -0.355 0.174 0.576 64 */
{0, 5, 63, -4}
, /* -0.360 0.360 0.249 -0.249 64 */
{0, 5, 63, -4}
, /* -0.326 0.076 0.321 -0.071 64 */
{0, 5, 63, -4}
, /* -0.294 -0.206 0.389 0.111 64 */
{0, 5, 63, -4}
, /* -0.263 -0.487 0.454 0.296 64 */
{0, 4, 64, -4}
, /* -0.234 0.234 -0.484 0.484 64 */
{0, 4, 63, -3}
, /* -0.207 -0.043 0.573 -0.323 64 */
{0, 4, 63, -3}
, /* -0.181 -0.319 0.628 -0.128 64 */
{0, 3, 64, -3}
, /* -0.157 0.407 -0.322 0.072 64 */
{0, 3, 64, -3}
, /* -0.134 0.134 -0.275 0.275 64 */
{0, 3, 64, -3}
, /* -0.113 -0.137 -0.231 0.481 64 */
{0, 2, 64, -2}
, /* -0.094 0.594 -0.191 -0.309 64 */
{0, 2, 64, -2}
, /* -0.076 0.326 -0.155 -0.095 64 */
{0, 2, 64, -2}
, /* -0.061 0.061 -0.123 0.123 64 */
{0, 2, 64, -2}
, /* -0.047 -0.203 -0.094 0.344 64 */
{0, 1, 64, -1}
, /* -0.034 0.534 -0.069 -0.431 64 */
{0, 1, 64, -1}
, /* -0.024 0.274 -0.048 -0.202 64 */
{0, 1, 64, -1}
, /* -0.015 0.015 -0.031 0.031 64 */
{0, 1, 64, -1}
, /* -0.009 -0.241 -0.017 0.267 64 */
{0, 0, 64, 0}
, /* -0.004 0.504 -0.008 -0.492 64 */
{0, 0, 64, 0}
, /* -0.001 0.251 -0.002 -0.248 64 */
};

View file

@ -1,108 +0,0 @@
#ifndef __COG_UTILS_H__
#define __COG_UTILS_H__
#if defined(_MSC_VER)
#ifndef COG_NO_STDINT_TYPEDEFS
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
#else
#include "_stdint.h"
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef void CogMemoryDomain;
typedef unsigned int cog_bool;
#ifdef COG_ENABLE_UNSTABLE_API
#define COG_PICTURE_NUMBER_INVALID (-1)
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define DIVIDE_ROUND_UP(a,b) (((a) + (b) - 1)/(b))
#ifndef MIN
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#endif
#ifndef CLAMP
#define CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
#endif
#define NEED_CLAMP(x,y,a,b) ((x) < (a) || (y) > (b))
#define ROUND_UP_SHIFT(x,y) (((x) + (1<<(y)) - 1)>>(y))
#define ROUND_UP_POW2(x,y) (((x) + (1<<(y)) - 1)&((~0)<<(y)))
#define ROUND_UP_2(x) ROUND_UP_POW2(x,1)
#define ROUND_UP_4(x) ROUND_UP_POW2(x,2)
#define ROUND_UP_8(x) ROUND_UP_POW2(x,3)
#define ROUND_UP_64(x) ROUND_UP_POW2(x,6)
#define OFFSET(ptr,offset) ((void *)(((uint8_t *)(ptr)) + (offset)))
#define ROUND_SHIFT(x,y) (((x) + (1<<((y)-1)))>>(y))
#define cog_divide(a,b) (((a)<0)?(((a) - (b) + 1)/(b)):((a)/(b)))
#endif
#define COG_OFFSET(ptr,offset) ((void *)(((uint8_t *)(ptr)) + (offset)))
#define COG_GET(ptr, offset, type) (*(type *)((uint8_t *)(ptr) + (offset)) )
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define COG_GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define COG_GNUC_PREREQ(maj, min) 0
#endif
#if COG_GNUC_PREREQ(3,3) && defined(__ELF__)
#define COG_INTERNAL __attribute__ ((visibility ("internal")))
#else
#define COG_INTERNAL
#endif
#ifdef __cplusplus
#define COG_BEGIN_DECLS extern "C" {
#define COG_END_DECLS }
#else
#define COG_BEGIN_DECLS
#define COG_END_DECLS
#endif
COG_BEGIN_DECLS
void * cog_malloc (int size);
void * cog_malloc0 (int size);
void * cog_realloc (void *ptr, int size);
void cog_free (void *ptr);
int cog_utils_multiplier_to_quant_index (double x);
int cog_dequantise (int q, int quant_factor, int quant_offset);
int cog_quantise (int value, int quant_factor, int quant_offset);
void cog_quantise_s16 (int16_t *dest, int16_t *src, int quant_factor,
int quant_offset, int n);
void cog_quantise_s16_table (int16_t *dest, int16_t *src, int quant_index,
cog_bool is_intra, int n);
void cog_dequantise_s16 (int16_t *dest, int16_t *src, int quant_factor,
int quant_offset, int n);
void cog_dequantise_s16_table (int16_t *dest, int16_t *src, int quant_index,
cog_bool is_intra, int n);
double cog_utils_probability_to_entropy (double x);
double cog_utils_entropy (double a, double total);
void cog_utils_reduce_fraction (int *n, int *d);
double cog_utils_get_time (void);
COG_END_DECLS
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,55 +0,0 @@
#ifndef __COG_VIRT_FRAME_H__
#define __COG_VIRT_FRAME_H__
#include <cog/cogutils.h>
#include <cog/cogframe.h>
COG_BEGIN_DECLS
CogFrame *cog_frame_new_virtual (CogMemoryDomain *domain,
CogFrameFormat format, int width, int height);
void *cog_virt_frame_get_line (CogFrame *frame, int component, int i);
void cog_virt_frame_render_line (CogFrame *frame, void *dest,
int component, int i);
void cog_virt_frame_render (CogFrame *frame, CogFrame *dest);
CogFrame *cog_virt_frame_new_horiz_downsample (CogFrame *vf, int n_taps);
CogFrame *cog_virt_frame_new_vert_downsample (CogFrame *vf, int n_taps);
CogFrame *cog_virt_frame_new_vert_resample (CogFrame *vf, int height, int n_taps);
CogFrame *cog_virt_frame_new_horiz_resample (CogFrame *vf, int width, int n_taps);
CogFrame *cog_virt_frame_new_unpack (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_YUY2 (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_UYVY (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_AYUV (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_v216 (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_v210 (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_RGB (CogFrame *vf);
CogFrame *cog_virt_frame_new_color_matrix_YCbCr_to_RGB (CogFrame *vf, CogColorMatrix color_matrix, int coefficient_bits);
CogFrame * cog_virt_frame_new_color_matrix_RGB_to_YCbCr (CogFrame * vf, CogColorMatrix color_matrix, int coefficient_bits);
CogFrame * cog_virt_frame_new_color_matrix_YCbCr_to_YCbCr (CogFrame * vf,
CogColorMatrix in_color_matrix, CogColorMatrix out_color_matrix,
int bits);
CogFrame *cog_virt_frame_new_subsample (CogFrame *vf, CogFrameFormat format,
CogChromaSite site, int n_taps);
CogFrame * cog_virt_frame_new_convert_u8 (CogFrame *vf);
CogFrame * cog_virt_frame_new_convert_s16 (CogFrame *vf);
CogFrame * cog_virt_frame_new_crop (CogFrame *vf, int width, int height);
CogFrame * cog_virt_frame_new_edgeextend (CogFrame *vf, int width, int height);
CogFrame * cog_virt_frame_new_pack_RGBx (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_xRGB (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_BGRx (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_xBGR (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_RGBA (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_ARGB (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_BGRA (CogFrame *vf);
CogFrame * cog_virt_frame_new_pack_ABGR (CogFrame *vf);
COG_END_DECLS
#endif

View file

@ -1,239 +0,0 @@
#include "config.h"
#include <glib.h>
#include <gst/math-compat.h>
#include <math.h>
#include "gstcms.h"
#define SCALE 256
static void
get_taps (double *taps, double x)
{
taps[3] = x * x * (x - 1);
taps[2] = x * (-x * x + x + 1);
x = 1 - x;
taps[1] = x * (-x * x + x + 1);
taps[0] = x * x * (x - 1);
}
int
main (int argc, char *argv[])
{
int i;
g_print ("/* This file is autogenerated. Do not edit.*/\n");
g_print ("#include <glib.h>\n");
g_print ("gint8 cog_resample_table_4tap[256][4] = {\n");
for (i = 0; i < 256; i++) {
double x = i / 256.0;
double taps[4];
int t[4];
int sum;
get_taps (taps, x);
taps[0] *= SCALE;
taps[1] *= SCALE;
taps[2] *= SCALE;
taps[3] *= SCALE;
t[0] = floor (taps[0]);
t[1] = floor (taps[1]);
t[2] = floor (taps[2]);
t[3] = floor (taps[3]);
sum = t[0] + t[1] + t[2] + t[3];
for (; sum < SCALE; sum++) {
int i;
double max = 0;
int max_i = -1;
for (i = 0; i < 4; i++) {
if (max_i == -1 || (t[i] < taps[i] && (taps[i] - t[i]) > max)) {
max_i = i;
max = taps[i] - t[i];
}
}
t[max_i]++;
}
sum = t[0] + t[1] + t[2] + t[3];
g_print (" { %d, %d, %d, %d }, /* %d %d */\n",
t[0], t[1], t[2], t[3], t[2] + t[0], t[1] + t[3]);
#if 0
g_print ("/* %.3f %.3f %.3f %.3f %d */\n",
taps[0] - t[0], taps[1] - t[1], taps[2] - t[2], taps[3] - t[3], sum);
#endif
}
g_print ("};\n");
g_print ("\n");
{
int cm, bits;
for (cm = 0; cm < 2; cm++) {
for (bits = 6; bits <= 8; bits += 2) {
ColorMatrix matrix;
/*
* At this point, everything is in YCbCr
* All components are in the range [0,255]
*/
color_matrix_set_identity (&matrix);
/* offset required to get input video black to (0.,0.,0.) */
/* we don't do this because the code does it for us */
color_matrix_offset_components (&matrix, -16, -128, -128);
color_matrix_scale_components (&matrix, (1 / 219.0), (1 / 224.0),
(1 / 224.0));
/* colour matrix, YCbCr -> RGB */
/* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */
if (cm) {
color_matrix_YCbCr_to_RGB (&matrix, 0.2126, 0.0722); /* HD */
} else {
color_matrix_YCbCr_to_RGB (&matrix, 0.2990, 0.1140); /* SD */
}
/*
* We are now in RGB space
*/
/* scale to output range. */
color_matrix_scale_components (&matrix, 255.0, 255.0, 255.0);
/* because we're doing 8-bit matrix coefficients */
color_matrix_scale_components (&matrix, 1 << bits, 1 << bits,
1 << bits);
g_print ("static const int cog_ycbcr_to_rgb_matrix_%dbit_%s[] = {\n",
bits, cm ? "hdtv" : "sdtv");
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[0][0]),
(int) rint (matrix.m[0][1]),
(int) rint (matrix.m[0][2]), (int) rint (matrix.m[0][3]));
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[1][0]),
(int) rint (matrix.m[1][1]),
(int) rint (matrix.m[1][2]), (int) rint (matrix.m[1][3]));
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[2][0]),
(int) rint (matrix.m[2][1]),
(int) rint (matrix.m[2][2]), (int) rint (matrix.m[2][3]));
g_print ("};\n");
}
}
}
{
int cm, bits;
for (cm = 0; cm < 2; cm++) {
for (bits = 8; bits <= 8; bits += 1) {
ColorMatrix matrix;
color_matrix_set_identity (&matrix);
color_matrix_scale_components (&matrix, (1 / 255.0), (1 / 255.0),
(1 / 255.0));
/* colour matrix, RGB -> YCbCr */
if (cm) {
color_matrix_RGB_to_YCbCr (&matrix, 0.2126, 0.0722); /* HD */
} else {
color_matrix_RGB_to_YCbCr (&matrix, 0.2990, 0.1140); /* SD */
}
/*
* We are now in YCbCr space
*/
color_matrix_scale_components (&matrix, 219.0, 224.0, 224.0);
color_matrix_offset_components (&matrix, 16, 128, 128);
/* because we're doing 8-bit matrix coefficients */
color_matrix_scale_components (&matrix, 1 << bits, 1 << bits,
1 << bits);
g_print ("static const int cog_rgb_to_ycbcr_matrix_%dbit_%s[] = {\n",
bits, cm ? "hdtv" : "sdtv");
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[0][0]),
(int) rint (matrix.m[0][1]),
(int) rint (matrix.m[0][2]), (int) rint (matrix.m[0][3]));
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[1][0]),
(int) rint (matrix.m[1][1]),
(int) rint (matrix.m[1][2]), (int) rint (matrix.m[1][3]));
g_print (" %d, %d, %d, %d,\n",
(int) rint (matrix.m[2][0]),
(int) rint (matrix.m[2][1]),
(int) rint (matrix.m[2][2]), (int) rint (matrix.m[2][3]));
g_print ("};\n");
}
}
}
{
int cm, bits;
for (cm = 0; cm < 2; cm++) {
for (bits = 8; bits <= 8; bits += 1) {
ColorMatrix matrix;
color_matrix_set_identity (&matrix);
/* offset required to get input video black to (0.,0.,0.) */
/* we don't do this because the code does it for us */
color_matrix_offset_components (&matrix, -16, -128, -128);
color_matrix_scale_components (&matrix, (1 / 219.0), (1 / 224.0),
(1 / 224.0));
/* colour matrix, RGB -> YCbCr */
if (cm) {
color_matrix_YCbCr_to_RGB (&matrix, 0.2126, 0.0722); /* HD */
color_matrix_RGB_to_YCbCr (&matrix, 0.2990, 0.1140); /* SD */
} else {
color_matrix_YCbCr_to_RGB (&matrix, 0.2990, 0.1140); /* SD */
color_matrix_RGB_to_YCbCr (&matrix, 0.2126, 0.0722); /* HD */
}
/*
* We are now in YCbCr space
*/
color_matrix_scale_components (&matrix, 219.0, 224.0, 224.0);
color_matrix_offset_components (&matrix, 16, 128, 128);
/* because we're doing 8-bit matrix coefficients */
color_matrix_scale_components (&matrix, 1 << bits, 1 << bits,
1 << bits);
g_print
("static const int cog_ycbcr_%s_to_ycbcr_%s_matrix_%dbit[] = {\n",
cm ? "hdtv" : "sdtv", cm ? "sdtv" : "hdtv", bits);
g_print (" %d, %d, %d, %d,\n", (int) rint (matrix.m[0][0]),
(int) rint (matrix.m[0][1]), (int) rint (matrix.m[0][2]),
(int) rint (matrix.m[0][3]));
g_print (" %d, %d, %d, %d,\n", (int) rint (matrix.m[1][0]),
(int) rint (matrix.m[1][1]), (int) rint (matrix.m[1][2]),
(int) rint (matrix.m[1][3]));
g_print (" %d, %d, %d, %d,\n", (int) rint (matrix.m[2][0]),
(int) rint (matrix.m[2][1]), (int) rint (matrix.m[2][2]),
(int) rint (matrix.m[2][3]));
g_print ("};\n");
}
}
}
return 0;
}

View file

@ -1,575 +0,0 @@
/* GStreamer
* Copyright (C) 2008 David Schleef <ds@entropywave.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/math-compat.h>
#include "gstcms.h"
#include "cogutils.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
/* our simple CMS */
void
color_xyY_to_XYZ (Color * c)
{
if (c->v[1] == 0) {
c->v[0] = 0;
c->v[1] = 0;
c->v[2] = 0;
} else {
double X, Y, Z;
X = c->v[0] * c->v[2] / c->v[1];
Y = c->v[2];
Z = (1.0 - c->v[0] - c->v[1]) * c->v[2] / c->v[1];
c->v[0] = X;
c->v[1] = Y;
c->v[2] = Z;
}
}
void
color_XYZ_to_xyY (Color * c)
{
double d;
d = c->v[0] + c->v[1] + c->v[2];
if (d == 0) {
c->v[0] = 0.3128;
c->v[1] = 0.3290;
c->v[2] = 0;
} else {
double x, y, Y;
x = c->v[0] / d;
y = c->v[1] / d;
Y = c->v[1];
c->v[0] = x;
c->v[1] = y;
c->v[2] = Y;
}
}
void
color_set (Color * c, double x, double y, double z)
{
c->v[0] = x;
c->v[1] = y;
c->v[2] = z;
}
void
color_matrix_set_identity (ColorMatrix * m)
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
m->m[i][j] = (i == j);
}
}
}
/* Prettyprint a 4x4 matrix @m@ */
void
color_matrix_dump (ColorMatrix * m)
{
int i, j;
printf ("[\n");
for (i = 0; i < 4; i++) {
printf (" ");
for (j = 0; j < 4; j++) {
printf (" %8.5g", m->m[i][j]);
}
printf ("\n");
}
printf ("]\n");
}
/* Perform 4x4 matrix multiplication:
* - @dst@ = @a@ * @b@
* - @dst@ may be a pointer to @a@ andor @b@
*/
void
color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b)
{
ColorMatrix tmp;
int i, j, k;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
double x = 0;
for (k = 0; k < 4; k++) {
x += a->m[i][k] * b->m[k][j];
}
tmp.m[i][j] = x;
}
}
memcpy (dst, &tmp, sizeof (ColorMatrix));
}
void
color_matrix_apply (ColorMatrix * m, Color * dest, Color * src)
{
int i;
Color tmp;
for (i = 0; i < 3; i++) {
double x = 0;
x += m->m[i][0] * src->v[0];
x += m->m[i][1] * src->v[1];
x += m->m[i][2] * src->v[2];
x += m->m[i][3];
tmp.v[i] = x;
}
memcpy (dest, &tmp, sizeof (tmp));
}
void
color_matrix_offset_components (ColorMatrix * m, double a1, double a2,
double a3)
{
ColorMatrix a;
color_matrix_set_identity (&a);
a.m[0][3] = a1;
a.m[1][3] = a2;
a.m[2][3] = a3;
color_matrix_multiply (m, &a, m);
}
void
color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3)
{
ColorMatrix a;
color_matrix_set_identity (&a);
a.m[0][0] = a1;
a.m[1][1] = a2;
a.m[2][2] = a3;
color_matrix_multiply (m, &a, m);
}
void
color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb)
{
double Kg = 1.0 - Kr - Kb;
ColorMatrix k = {
{
{1., 0., 2 * (1 - Kr), 0.},
{1., -2 * Kb * (1 - Kb) / Kg, -2 * Kr * (1 - Kr) / Kg, 0.},
{1., 2 * (1 - Kb), 0., 0.},
{0., 0., 0., 1.},
}
};
color_matrix_multiply (m, &k, m);
}
void
color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb)
{
double Kg = 1.0 - Kr - Kb;
ColorMatrix k;
double x;
k.m[0][0] = Kr;
k.m[0][1] = Kg;
k.m[0][2] = Kb;
k.m[0][3] = 0;
x = 1 / (2 * (1 - Kb));
k.m[1][0] = -x * Kr;
k.m[1][1] = -x * Kg;
k.m[1][2] = x * (1 - Kb);
k.m[1][3] = 0;
x = 1 / (2 * (1 - Kr));
k.m[2][0] = x * (1 - Kr);
k.m[2][1] = -x * Kg;
k.m[2][2] = -x * Kb;
k.m[2][3] = 0;
k.m[3][0] = 0;
k.m[3][1] = 0;
k.m[3][2] = 0;
k.m[3][3] = 1;
color_matrix_multiply (m, &k, m);
}
void
color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst)
{
/*
* At this point, everything is in YCbCr
* All components are in the range [0,255]
*/
color_matrix_set_identity (dst);
/* offset required to get input video black to (0.,0.,0.) */
color_matrix_offset_components (dst, -16, -128, -128);
/* scale required to get input video black to (0.,0.,0.) */
color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), (1 / 224.0));
/* colour matrix, YCbCr -> RGB */
/* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */
color_matrix_YCbCr_to_RGB (dst, 0.2990, 0.1140); /* SD */
/*
* We are now in RGB space
*/
#if 0
/* scale to output range. */
color_matrix_scale_components (dst, 255.0, 255.0, 255.0);
#endif
}
void
color_matrix_build_bt709_to_bt601 (ColorMatrix * dst)
{
color_matrix_set_identity (dst);
/* offset required to get input video black to (0.,0.,0.) */
color_matrix_offset_components (dst, -16, -128, -128);
/* scale required to get input video black to (0.,0.,0.) */
color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), (1 / 224.0));
/* colour matrix, YCbCr -> RGB */
/* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */
color_matrix_YCbCr_to_RGB (dst, 0.2126, 0.0722); /* HD */
color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140); /* SD */
color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
color_matrix_offset_components (dst, 16, 128, 128);
}
void
color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst)
{
color_matrix_set_identity (dst);
color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140); /* SD */
color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
color_matrix_offset_components (dst, 16, 128, 128);
{
Color c;
int i;
for (i = 7; i >= 0; i--) {
color_set (&c, (i & 2) ? 0.75 : 0.0, (i & 4) ? 0.75 : 0.0,
(i & 1) ? 0.75 : 0.0);
color_matrix_apply (dst, &c, &c);
g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
rint (c.v[2]));
}
color_set (&c, -0.075, -0.075, -0.075);
color_matrix_apply (dst, &c, &c);
g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
rint (c.v[2]));
color_set (&c, 0.075, 0.075, 0.075);
color_matrix_apply (dst, &c, &c);
g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
rint (c.v[2]));
}
}
void
color_matrix_invert (ColorMatrix * m)
{
ColorMatrix tmp;
int i, j;
double det;
color_matrix_set_identity (&tmp);
for (j = 0; j < 3; j++) {
for (i = 0; i < 3; i++) {
tmp.m[j][i] =
m->m[(i + 1) % 3][(j + 1) % 3] * m->m[(i + 2) % 3][(j + 2) % 3] -
m->m[(i + 1) % 3][(j + 2) % 3] * m->m[(i + 2) % 3][(j + 1) % 3];
}
}
det =
tmp.m[0][0] * m->m[0][0] + tmp.m[0][1] * m->m[1][0] +
tmp.m[0][2] * m->m[2][0];
for (j = 0; j < 3; j++) {
for (i = 0; i < 3; i++) {
tmp.m[i][j] /= det;
}
}
memcpy (m, &tmp, sizeof (tmp));
}
void
color_matrix_copy (ColorMatrix * dest, ColorMatrix * src)
{
memcpy (dest, src, sizeof (ColorMatrix));
}
void
color_matrix_transpose (ColorMatrix * m)
{
int i, j;
ColorMatrix tmp;
color_matrix_set_identity (&tmp);
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
tmp.m[i][j] = m->m[j][i];
}
}
memcpy (m, &tmp, sizeof (ColorMatrix));
}
void
color_matrix_build_XYZ (ColorMatrix * dst,
double rx, double ry,
double gx, double gy, double bx, double by, double wx, double wy)
{
Color r, g, b, w, scale;
ColorMatrix m;
color_set (&r, rx, ry, 1.0);
color_xyY_to_XYZ (&r);
color_set (&g, gx, gy, 1.0);
color_xyY_to_XYZ (&g);
color_set (&b, bx, by, 1.0);
color_xyY_to_XYZ (&b);
color_set (&w, wx, wy, 1.0);
color_xyY_to_XYZ (&w);
color_matrix_set_identity (dst);
dst->m[0][0] = r.v[0];
dst->m[0][1] = r.v[1];
dst->m[0][2] = r.v[2];
dst->m[1][0] = g.v[0];
dst->m[1][1] = g.v[1];
dst->m[1][2] = g.v[2];
dst->m[2][0] = b.v[0];
dst->m[2][1] = b.v[1];
dst->m[2][2] = b.v[2];
color_matrix_dump (dst);
color_matrix_copy (&m, dst);
color_matrix_invert (&m);
color_matrix_dump (&m);
color_matrix_transpose (&m);
color_matrix_apply (&m, &scale, &w);
g_print ("%g %g %g\n", scale.v[0], scale.v[1], scale.v[2]);
dst->m[0][0] = r.v[0] * scale.v[0];
dst->m[0][1] = r.v[1] * scale.v[0];
dst->m[0][2] = r.v[2] * scale.v[0];
dst->m[1][0] = g.v[0] * scale.v[1];
dst->m[1][1] = g.v[1] * scale.v[1];
dst->m[1][2] = g.v[2] * scale.v[1];
dst->m[2][0] = b.v[0] * scale.v[2];
dst->m[2][1] = b.v[1] * scale.v[2];
dst->m[2][2] = b.v[2] * scale.v[2];
color_matrix_transpose (dst);
color_matrix_dump (dst);
color_set (&scale, 1, 1, 1);
color_matrix_apply (dst, &scale, &scale);
color_XYZ_to_xyY (&scale);
g_print ("white %g %g %g\n", scale.v[0], scale.v[1], scale.v[2]);
}
void
color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst)
{
/* SMPTE C primaries, SMPTE 170M-2004 */
color_matrix_build_XYZ (dst,
0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290);
#if 0
/* NTSC 1953 primaries, SMPTE 170M-2004 */
color_matrix_build_XYZ (dst,
0.67, 0.33, 0.21, 0.71, 0.14, 0.08, 0.3127, 0.3290);
#endif
}
void
color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst)
{
/* Rec. ITU-R BT.709-5 */
color_matrix_build_XYZ (dst,
0.640, 0.330, 0.300, 0.600, 0.150, 0.060, 0.3127, 0.3290);
}
void
color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst)
{
/* Dell monitor */
#if 1
color_matrix_build_XYZ (dst,
0.662, 0.329, 0.205, 0.683, 0.146, 0.077, 0.3135, 0.3290);
#endif
#if 0
color_matrix_build_XYZ (dst,
0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290);
#endif
color_matrix_invert (dst);
}
void
color_transfer_function_apply (Color * dest, Color * src)
{
int i;
for (i = 0; i < 3; i++) {
if (src->v[i] < 0.0812) {
dest->v[i] = src->v[i] / 4.500;
} else {
dest->v[i] = pow (src->v[i] + 0.099, 1 / 0.4500);
}
}
}
void
color_transfer_function_unapply (Color * dest, Color * src)
{
int i;
for (i = 0; i < 3; i++) {
if (src->v[i] < 0.0812 / 4.500) {
dest->v[i] = src->v[i] * 4.500;
} else {
dest->v[i] = pow (src->v[i], 0.4500) - 0.099;
}
}
}
void
color_gamut_clamp (Color * dest, Color * src)
{
dest->v[0] = CLAMP (src->v[0], 0.0, 1.0);
dest->v[1] = CLAMP (src->v[1], 0.0, 1.0);
dest->v[2] = CLAMP (src->v[2], 0.0, 1.0);
}
#if 0
static guint8 *
get_color_transform_table (void)
{
static guint8 *color_transform_table = NULL;
#if 1
if (!color_transform_table) {
ColorMatrix bt601_to_rgb;
ColorMatrix bt601_to_yuv;
ColorMatrix bt601_rgb_to_XYZ;
ColorMatrix dell_XYZ_to_rgb;
guint8 *table_y;
guint8 *table_u;
guint8 *table_v;
int y, u, v;
color_matrix_build_yuv_to_rgb_601 (&bt601_to_rgb);
color_matrix_build_rgb_to_yuv_601 (&bt601_to_yuv);
color_matrix_build_rgb_to_XYZ_601 (&bt601_rgb_to_XYZ);
color_matrix_build_XYZ_to_rgb_dell (&dell_XYZ_to_rgb);
color_transform_table = g_malloc (0x1000000 * 3);
table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000);
table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000);
table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000);
for (y = 0; y < 256; y++) {
for (u = 0; u < 256; u++) {
for (v = 0; v < 256; v++) {
Color c;
c.v[0] = y;
c.v[1] = u;
c.v[2] = v;
color_matrix_apply (&bt601_to_rgb, &c, &c);
color_gamut_clamp (&c, &c);
color_transfer_function_apply (&c, &c);
color_matrix_apply (&bt601_rgb_to_XYZ, &c, &c);
color_matrix_apply (&dell_XYZ_to_rgb, &c, &c);
color_transfer_function_unapply (&c, &c);
color_gamut_clamp (&c, &c);
color_matrix_apply (&bt601_to_yuv, &c, &c);
table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]);
}
}
}
}
#endif
#if 0
if (!color_transform_table) {
ColorMatrix bt709_to_bt601;
guint8 *table_y;
guint8 *table_u;
guint8 *table_v;
int y, u, v;
color_matrix_build_bt709_to_bt601 (&bt709_to_bt601);
color_transform_table = g_malloc (0x1000000 * 3);
table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000);
table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000);
table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000);
for (y = 0; y < 256; y++) {
for (u = 0; u < 256; u++) {
for (v = 0; v < 256; v++) {
Color c;
c.v[0] = y;
c.v[1] = u;
c.v[2] = v;
color_matrix_apply (&bt709_to_bt601, &c, &c);
table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]);
}
}
}
}
#endif
return color_transform_table;
}
#endif

View file

@ -1,71 +0,0 @@
/* GStreamer
* Copyright (C) 2008 David Schleef <ds@entropywave.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _GST_CMS_H_
#define _GST_CMS_H_
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _Color Color;
typedef struct _ColorMatrix ColorMatrix;
struct _Color
{
double v[3];
};
struct _ColorMatrix
{
double m[4][4];
};
void color_xyY_to_XYZ (Color * c);
void color_XYZ_to_xyY (Color * c);
void color_set (Color * c, double x, double y, double z);
void color_matrix_set_identity (ColorMatrix * m);
void color_matrix_dump (ColorMatrix * m);
void color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b);
void color_matrix_apply (ColorMatrix * m, Color * dest, Color * src);
void color_matrix_offset_components (ColorMatrix * m, double a1, double a2,
double a3);
void color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3);
void color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb);
void color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb);
void color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst);
void color_matrix_build_bt709_to_bt601 (ColorMatrix * dst);
void color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst);
void color_matrix_invert (ColorMatrix * m);
void color_matrix_copy (ColorMatrix * dest, ColorMatrix * src);
void color_matrix_transpose (ColorMatrix * m);
void color_matrix_build_XYZ (ColorMatrix * dst,
double rx, double ry,
double gx, double gy, double bx, double by, double wx, double wy);
void color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst);
void color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst);
void color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst);
void color_transfer_function_apply (Color * dest, Color * src);
void color_transfer_function_unapply (Color * dest, Color * src);
void color_gamut_clamp (Color * dest, Color * src);
G_END_DECLS
#endif

View file

@ -1,68 +0,0 @@
/* GStreamer
* Copyright (C) 2007 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <gst/gst.h>
#ifdef HAVE_ORC
#include <orc/orc.h>
#endif
GType gst_deblock_get_type (void);
GType gst_cogdownsample_get_type (void);
GType gst_cogcolorspace_get_type (void);
GType gst_cog_scale_get_type (void);
GType gst_colorconvert_get_type (void);
GType gst_logoinsert_get_type (void);
GType gst_mse_get_type (void);
GST_DEBUG_CATEGORY (cog_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
#ifdef HAVE_ORC
orc_init ();
#endif
GST_DEBUG_CATEGORY_INIT (cog_debug, "cog", 0, "Cog");
gst_element_register (plugin, "cogdownsample", GST_RANK_NONE,
gst_cogdownsample_get_type ());
gst_element_register (plugin, "cogcolorspace", GST_RANK_NONE,
gst_cogcolorspace_get_type ());
gst_element_register (plugin, "cogscale", GST_RANK_NONE,
gst_cog_scale_get_type ());
gst_element_register (plugin, "cogcolorconvert", GST_RANK_NONE,
gst_colorconvert_get_type ());
gst_element_register (plugin, "coglogoinsert", GST_RANK_NONE,
gst_logoinsert_get_type ());
gst_element_register (plugin, "cogmse", GST_RANK_NONE, gst_mse_get_type ());
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
cog,
"Cog plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -1,378 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* This file was (probably) generated from
* gstvideotemplate.c,v 1.18 2005/11/14 02:13:34 thomasvs Exp
* and
* $Id: make_filter,v 1.8 2004/04/19 22:51:57 ds Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/video/video.h>
#include <string.h>
#include <cog/cog.h>
#include <math.h>
#include <cog/cogvirtframe.h>
#define GST_TYPE_COGDOWNSAMPLE \
(gst_cogdownsample_get_type())
#define GST_COGDOWNSAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COGDOWNSAMPLE,GstCogdownsample))
#define GST_COGDOWNSAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COGDOWNSAMPLE,GstCogdownsampleClass))
#define GST_IS_COGDOWNSAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COGDOWNSAMPLE))
#define GST_IS_COGDOWNSAMPLE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COGDOWNSAMPLE))
typedef struct _GstCogdownsample GstCogdownsample;
typedef struct _GstCogdownsampleClass GstCogdownsampleClass;
struct _GstCogdownsample
{
GstBaseTransform base_transform;
};
struct _GstCogdownsampleClass
{
GstBaseTransformClass parent_class;
};
GType gst_cogdownsample_get_type (void);
enum
{
ARG_0
};
static void gst_cogdownsample_base_init (gpointer g_class);
static void gst_cogdownsample_class_init (gpointer g_class,
gpointer class_data);
static void gst_cogdownsample_init (GTypeInstance * instance, gpointer g_class);
static void gst_cogdownsample_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_cogdownsample_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstCaps *gst_cogdownsample_transform_caps (GstBaseTransform *
base_transform, GstPadDirection direction, GstCaps * caps);
static GstFlowReturn gst_cogdownsample_transform (GstBaseTransform *
base_transform, GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_cogdownsample_get_unit_size (GstBaseTransform *
base_transform, GstCaps * caps, guint * size);
static GstStaticPadTemplate gst_cogdownsample_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }"))
);
static GstStaticPadTemplate gst_cogdownsample_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }"))
);
GType
gst_cogdownsample_get_type (void)
{
static GType compress_type = 0;
if (!compress_type) {
static const GTypeInfo compress_info = {
sizeof (GstCogdownsampleClass),
gst_cogdownsample_base_init,
NULL,
gst_cogdownsample_class_init,
NULL,
NULL,
sizeof (GstCogdownsample),
0,
gst_cogdownsample_init,
};
compress_type = g_type_register_static (GST_TYPE_BASE_TRANSFORM,
"GstCogdownsample", &compress_info, 0);
}
return compress_type;
}
static void
gst_cogdownsample_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_cogdownsample_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_cogdownsample_sink_template));
gst_element_class_set_static_metadata (element_class,
"Scale down video by factor of 2", "Filter/Effect/Video",
"Scales down video by a factor of 2", "David Schleef <ds@schleef.org>");
}
static void
gst_cogdownsample_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstBaseTransformClass *base_transform_class;
gobject_class = G_OBJECT_CLASS (g_class);
base_transform_class = GST_BASE_TRANSFORM_CLASS (g_class);
gobject_class->set_property = gst_cogdownsample_set_property;
gobject_class->get_property = gst_cogdownsample_get_property;
base_transform_class->transform = gst_cogdownsample_transform;
base_transform_class->transform_caps = gst_cogdownsample_transform_caps;
base_transform_class->get_unit_size = gst_cogdownsample_get_unit_size;
}
static void
gst_cogdownsample_init (GTypeInstance * instance, gpointer g_class)
{
GST_DEBUG ("gst_cogdownsample_init");
}
static void
gst_cogdownsample_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
g_return_if_fail (GST_IS_COGDOWNSAMPLE (object));
GST_DEBUG ("gst_cogdownsample_set_property");
switch (prop_id) {
default:
break;
}
}
static void
gst_cogdownsample_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
g_return_if_fail (GST_IS_COGDOWNSAMPLE (object));
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
transform_value (GValue * dest, const GValue * src, GstPadDirection dir)
{
g_value_init (dest, G_VALUE_TYPE (src));
if (G_VALUE_HOLDS_INT (src)) {
int x;
x = g_value_get_int (src);
if (dir == GST_PAD_SINK) {
g_value_set_int (dest, x / 2);
} else {
g_value_set_int (dest, x * 2);
}
} else if (GST_VALUE_HOLDS_INT_RANGE (src)) {
int min, max;
min = gst_value_get_int_range_min (src);
max = gst_value_get_int_range_max (src);
if (dir == GST_PAD_SINK) {
min = (min + 1) / 2;
if (max == G_MAXINT) {
max = G_MAXINT / 2;
} else {
max = (max + 1) / 2;
}
} else {
if (max > G_MAXINT / 2) {
max = G_MAXINT;
} else {
max = max * 2;
}
if (min > G_MAXINT / 2) {
min = G_MAXINT;
} else {
min = min * 2;
}
}
gst_value_set_int_range (dest, min, max);
} else {
/* FIXME */
g_warning ("case not handled");
g_value_set_int (dest, 100);
}
}
static GstCaps *
gst_cogdownsample_transform_caps (GstBaseTransform * base_transform,
GstPadDirection direction, GstCaps * caps)
{
int i;
GstStructure *structure;
GValue new_value = { 0 };
const GValue *value;
caps = gst_caps_copy (caps);
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
value = gst_structure_get_value (structure, "width");
transform_value (&new_value, value, direction);
gst_structure_set_value (structure, "width", &new_value);
g_value_unset (&new_value);
value = gst_structure_get_value (structure, "height");
transform_value (&new_value, value, direction);
gst_structure_set_value (structure, "height", &new_value);
g_value_unset (&new_value);
}
return caps;
}
static gboolean
gst_cogdownsample_get_unit_size (GstBaseTransform * base_transform,
GstCaps * caps, guint * size)
{
int width, height;
uint32_t format;
gst_structure_get_fourcc (gst_caps_get_structure (caps, 0),
"format", &format);
gst_structure_get_int (gst_caps_get_structure (caps, 0), "width", &width);
gst_structure_get_int (gst_caps_get_structure (caps, 0), "height", &height);
switch (format) {
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
*size = width * height * 3 / 2;
break;
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
*size = width * height * 2;
break;
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
*size = width * height * 4;
break;
default:
g_assert_not_reached ();
}
return TRUE;
}
static GstFlowReturn
gst_cogdownsample_transform (GstBaseTransform * base_transform,
GstBuffer * inbuf, GstBuffer * outbuf)
{
CogFrame *outframe;
int width, height;
uint32_t format;
CogFrame *frame;
g_return_val_if_fail (GST_IS_COGDOWNSAMPLE (base_transform), GST_FLOW_ERROR);
gst_structure_get_fourcc (gst_caps_get_structure (inbuf->caps, 0),
"format", &format);
gst_structure_get_int (gst_caps_get_structure (inbuf->caps, 0),
"width", &width);
gst_structure_get_int (gst_caps_get_structure (inbuf->caps, 0),
"height", &height);
switch (format) {
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
frame = cog_frame_new_from_data_I420 (GST_BUFFER_DATA (inbuf),
width, height);
outframe = cog_frame_new_from_data_I420 (GST_BUFFER_DATA (outbuf),
width / 2, height / 2);
break;
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
frame = cog_frame_new_from_data_YV12 (GST_BUFFER_DATA (inbuf),
width, height);
outframe = cog_frame_new_from_data_YV12 (GST_BUFFER_DATA (outbuf),
width / 2, height / 2);
break;
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
frame = cog_frame_new_from_data_YUY2 (GST_BUFFER_DATA (inbuf),
width, height);
outframe = cog_frame_new_from_data_YUY2 (GST_BUFFER_DATA (outbuf),
width / 2, height / 2);
break;
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
frame = cog_frame_new_from_data_UYVY (GST_BUFFER_DATA (inbuf),
width, height);
outframe = cog_frame_new_from_data_UYVY (GST_BUFFER_DATA (outbuf),
width / 2, height / 2);
break;
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
frame = cog_frame_new_from_data_AYUV (GST_BUFFER_DATA (inbuf),
width, height);
outframe = cog_frame_new_from_data_AYUV (GST_BUFFER_DATA (outbuf),
width / 2, height / 2);
break;
default:
g_assert_not_reached ();
return GST_FLOW_ERROR;
}
frame = cog_virt_frame_new_unpack (frame);
frame = cog_virt_frame_new_horiz_downsample (frame, 3);
frame = cog_virt_frame_new_vert_downsample (frame, 2);
switch (format) {
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
frame = cog_virt_frame_new_pack_YUY2 (frame);
break;
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
frame = cog_virt_frame_new_pack_UYVY (frame);
break;
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
frame = cog_virt_frame_new_pack_AYUV (frame);
break;
default:
break;
}
cog_virt_frame_render (frame, outframe);
cog_frame_unref (frame);
cog_frame_unref (outframe);
return GST_FLOW_OK;
}

View file

@ -1,558 +0,0 @@
/*
* GStreamer
* Copyright (C) 2007,2009 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/glib-compat-private.h>
#include <gst/video/video.h>
#include <string.h>
#include <cog/cogframe.h>
#ifdef HAVE_ORC
#include <orc/orc.h>
#endif
#include <math.h>
#include "gstcogutils.h"
#define GST_CAT_DEFAULT gst_mse_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define GST_TYPE_MSE (gst_mse_get_type())
#define GST_MSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MSE,GstMSE))
#define GST_IS_MSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MSE))
#define GST_MSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_MSE,GstMSEClass))
#define GST_IS_MSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_MSE))
#define GST_MSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_MSE,GstMSEClass))
typedef struct _GstMSE GstMSE;
typedef struct _GstMSEClass GstMSEClass;
typedef void (*GstMSEProcessFunc) (GstMSE *, guint8 *, guint);
struct _GstMSE
{
GstElement element;
/* < private > */
GstPad *srcpad;
GstPad *sinkpad_ref;
GstPad *sinkpad_test;
GstBuffer *buffer_ref;
GMutex *lock;
GCond *cond;
gboolean cancel;
GstVideoFormat format;
int width;
int height;
double luma_mse_sum;
double chroma_mse_sum;
int n_frames;
};
struct _GstMSEClass
{
GstElementClass parent;
};
GType gst_mse_get_type (void);
enum
{
PROP_0,
LUMA_PSNR,
CHROMA_PSNR
};
#define DEBUG_INIT(bla) \
GST_DEBUG_CATEGORY_INIT (gst_mse_debug, "mse", 0, "cogmse element");
GST_BOILERPLATE_FULL (GstMSE, gst_mse, GstElement,
GST_TYPE_ELEMENT, DEBUG_INIT);
static void gst_mse_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_mse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstFlowReturn gst_mse_chain_test (GstPad * pad, GstBuffer * buffer);
static GstFlowReturn gst_mse_chain_ref (GstPad * pad, GstBuffer * buffer);
static gboolean gst_mse_sink_event (GstPad * pad, GstEvent * event);
static void gst_mse_reset (GstMSE * filter);
static GstCaps *gst_mse_getcaps (GstPad * pad);
static gboolean gst_mse_set_caps (GstPad * pad, GstCaps * outcaps);
static void gst_mse_finalize (GObject * object);
static void cog_frame_mse (CogFrame * a, CogFrame * b, double *mse);
static double mse_to_db (double mse, gboolean is_chroma);
static GstStaticPadTemplate gst_framestore_sink_ref_template =
GST_STATIC_PAD_TEMPLATE ("sink_ref",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{I420,YUY2,AYUV}"))
);
static GstStaticPadTemplate gst_framestore_sink_test_template =
GST_STATIC_PAD_TEMPLATE ("sink_test",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{I420,YUY2,AYUV}"))
);
static GstStaticPadTemplate gst_framestore_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{I420,YUY2,AYUV}"))
);
static void
gst_mse_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_framestore_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_framestore_sink_ref_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_framestore_sink_test_template));
gst_element_class_set_static_metadata (element_class, "Calculate MSE",
"Filter/Effect",
"Calculates mean squared error between two video streams",
"David Schleef <ds@schleef.org>");
}
static void
gst_mse_class_init (GstMSEClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_mse_set_property;
gobject_class->get_property = gst_mse_get_property;
gobject_class->finalize = gst_mse_finalize;
g_object_class_install_property (gobject_class, LUMA_PSNR,
g_param_spec_double ("luma-psnr", "luma-psnr", "luma-psnr",
0, 70, 40, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, CHROMA_PSNR,
g_param_spec_double ("chroma-psnr", "chroma-psnr", "chroma-psnr",
0, 70, 40, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
static void
gst_mse_init (GstMSE * filter, GstMSEClass * klass)
{
gst_element_create_all_pads (GST_ELEMENT (filter));
filter->srcpad = gst_element_get_static_pad (GST_ELEMENT (filter), "src");
gst_pad_set_getcaps_function (filter->srcpad, gst_mse_getcaps);
filter->sinkpad_ref =
gst_element_get_static_pad (GST_ELEMENT (filter), "sink_ref");
gst_pad_set_chain_function (filter->sinkpad_ref, gst_mse_chain_ref);
gst_pad_set_event_function (filter->sinkpad_ref, gst_mse_sink_event);
gst_pad_set_getcaps_function (filter->sinkpad_ref, gst_mse_getcaps);
filter->sinkpad_test =
gst_element_get_static_pad (GST_ELEMENT (filter), "sink_test");
gst_pad_set_chain_function (filter->sinkpad_test, gst_mse_chain_test);
gst_pad_set_event_function (filter->sinkpad_test, gst_mse_sink_event);
gst_pad_set_getcaps_function (filter->sinkpad_test, gst_mse_getcaps);
gst_pad_set_setcaps_function (filter->sinkpad_test, gst_mse_set_caps);
gst_mse_reset (filter);
filter->cond = g_cond_new ();
filter->lock = g_mutex_new ();
}
static void
gst_mse_finalize (GObject * object)
{
GstMSE *fs = GST_MSE (object);
gst_object_unref (fs->srcpad);
gst_object_unref (fs->sinkpad_ref);
gst_object_unref (fs->sinkpad_test);
g_mutex_free (fs->lock);
g_cond_free (fs->cond);
gst_buffer_replace (&fs->buffer_ref, NULL);
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static GstCaps *
gst_mse_getcaps (GstPad * pad)
{
GstMSE *fs;
GstCaps *caps;
GstCaps *icaps;
GstCaps *peercaps;
fs = GST_MSE (gst_pad_get_parent (pad));
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
if (pad != fs->srcpad) {
peercaps = gst_pad_peer_get_caps (fs->srcpad);
if (peercaps) {
icaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps);
gst_caps_unref (peercaps);
caps = icaps;
}
}
if (pad != fs->sinkpad_ref) {
peercaps = gst_pad_peer_get_caps (fs->sinkpad_ref);
if (peercaps) {
icaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps);
gst_caps_unref (peercaps);
caps = icaps;
}
}
if (pad != fs->sinkpad_test) {
peercaps = gst_pad_peer_get_caps (fs->sinkpad_test);
if (peercaps) {
icaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps);
gst_caps_unref (peercaps);
caps = icaps;
}
}
gst_object_unref (fs);
return caps;
}
static gboolean
gst_mse_set_caps (GstPad * pad, GstCaps * caps)
{
GstMSE *fs;
fs = GST_MSE (gst_pad_get_parent (pad));
gst_video_format_parse_caps (caps, &fs->format, &fs->width, &fs->height);
gst_object_unref (fs);
return TRUE;
}
static void
gst_mse_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMSE *fs = GST_MSE (object);
switch (prop_id) {
case LUMA_PSNR:
g_value_set_double (value,
mse_to_db (fs->luma_mse_sum / fs->n_frames, FALSE));
break;
case CHROMA_PSNR:
g_value_set_double (value,
mse_to_db (fs->chroma_mse_sum / fs->n_frames, TRUE));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mse_reset (GstMSE * fs)
{
fs->luma_mse_sum = 0;
fs->chroma_mse_sum = 0;
fs->n_frames = 0;
fs->cancel = FALSE;
if (fs->buffer_ref) {
gst_buffer_unref (fs->buffer_ref);
fs->buffer_ref = NULL;
}
}
static GstFlowReturn
gst_mse_chain_ref (GstPad * pad, GstBuffer * buffer)
{
GstMSE *fs;
fs = GST_MSE (gst_pad_get_parent (pad));
GST_DEBUG ("chain ref");
g_mutex_lock (fs->lock);
while (fs->buffer_ref) {
GST_DEBUG ("waiting for ref buffer clear");
g_cond_wait (fs->cond, fs->lock);
if (fs->cancel) {
g_mutex_unlock (fs->lock);
gst_object_unref (fs);
return GST_FLOW_FLUSHING;
}
}
fs->buffer_ref = buffer;
g_cond_signal (fs->cond);
g_mutex_unlock (fs->lock);
gst_object_unref (fs);
return GST_FLOW_OK;
}
static GstFlowReturn
gst_mse_chain_test (GstPad * pad, GstBuffer * buffer)
{
GstMSE *fs;
GstFlowReturn ret;
GstBuffer *buffer_ref;
fs = GST_MSE (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (fs, "chain test");
g_mutex_lock (fs->lock);
while (fs->buffer_ref == NULL) {
GST_DEBUG_OBJECT (fs, "waiting for ref buffer");
g_cond_wait (fs->cond, fs->lock);
if (fs->cancel) {
g_mutex_unlock (fs->lock);
gst_object_unref (fs);
return GST_FLOW_FLUSHING;
}
}
buffer_ref = fs->buffer_ref;
fs->buffer_ref = NULL;
g_cond_signal (fs->cond);
g_mutex_unlock (fs->lock);
if (1) {
CogFrame *frame_ref;
CogFrame *frame_test;
double mse[3];
frame_ref = gst_cog_buffer_wrap (gst_buffer_ref (buffer_ref), fs->format,
fs->width, fs->height);
frame_test = gst_cog_buffer_wrap (gst_buffer_ref (buffer), fs->format,
fs->width, fs->height);
cog_frame_mse (frame_ref, frame_test, mse);
GST_INFO ("mse %g %g %g", mse_to_db (mse[0], FALSE),
mse_to_db (mse[1], TRUE), mse_to_db (mse[2], TRUE));
fs->luma_mse_sum += mse[0];
fs->chroma_mse_sum += 0.5 * (mse[1] + mse[2]);
fs->n_frames++;
cog_frame_unref (frame_ref);
cog_frame_unref (frame_test);
}
ret = gst_pad_push (fs->srcpad, buffer);
gst_buffer_unref (buffer_ref);
gst_object_unref (fs);
return ret;
}
static gboolean
gst_mse_sink_event (GstPad * pad, GstEvent * event)
{
GstMSE *fs;
fs = GST_MSE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
{
gboolean update;
double rate;
double applied_rate;
GstFormat format;
gint64 start, stop, position;
gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
&format, &start, &stop, &position);
GST_DEBUG ("new_segment %d %g %g %d %" G_GINT64_FORMAT
" %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
update, rate, applied_rate, format, start, stop, position);
}
break;
case GST_EVENT_FLUSH_START:
GST_DEBUG ("flush start");
fs->cancel = TRUE;
break;
case GST_EVENT_FLUSH_STOP:
GST_DEBUG ("flush stop");
fs->cancel = FALSE;
break;
default:
break;
}
gst_pad_push_event (fs->srcpad, event);
gst_object_unref (fs);
return TRUE;
}
static int
sum_square_diff_u8 (uint8_t * s1, uint8_t * s2, int n)
{
#ifndef HAVE_ORC
int sum = 0;
int i;
int x;
for (i = 0; i < n; i++) {
x = s1[i] - s2[i];
sum += x * x;
}
return sum;
#else
static OrcProgram *p = NULL;
OrcExecutor *ex;
int val;
if (p == NULL) {
OrcCompileResult ret;
p = orc_program_new_ass (4, 1, 1);
orc_program_add_temporary (p, 2, "t1");
orc_program_add_temporary (p, 2, "t2");
orc_program_add_temporary (p, 4, "t3");
orc_program_append_ds_str (p, "convubw", "t1", "s1");
orc_program_append_ds_str (p, "convubw", "t2", "s2");
orc_program_append_str (p, "subw", "t1", "t1", "t2");
orc_program_append_str (p, "mullw", "t1", "t1", "t1");
orc_program_append_ds_str (p, "convuwl", "t3", "t1");
orc_program_append_ds_str (p, "accl", "a1", "t3");
ret = orc_program_compile (p);
if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL (ret)) {
GST_ERROR ("Orc compiler failure");
return 0;
}
}
ex = orc_executor_new (p);
orc_executor_set_n (ex, n);
orc_executor_set_array_str (ex, "s1", s1);
orc_executor_set_array_str (ex, "s2", s2);
orc_executor_run (ex);
val = orc_executor_get_accumulator (ex, 0);
orc_executor_free (ex);
return val;
#endif
}
static double
cog_frame_component_squared_error (CogFrameData * a, CogFrameData * b)
{
int j;
double sum;
g_return_val_if_fail (a->width == b->width, 0.0);
g_return_val_if_fail (a->height == b->height, 0.0);
sum = 0;
for (j = 0; j < a->height; j++) {
sum += sum_square_diff_u8 (COG_FRAME_DATA_GET_LINE (a, j),
COG_FRAME_DATA_GET_LINE (b, j), a->width);
}
return sum;
}
static void
cog_frame_mse (CogFrame * a, CogFrame * b, double *mse)
{
double sum, n;
sum = cog_frame_component_squared_error (&a->components[0],
&b->components[0]);
n = a->components[0].width * a->components[0].height;
mse[0] = sum / n;
sum = cog_frame_component_squared_error (&a->components[1],
&b->components[1]);
n = a->components[1].width * a->components[1].height;
mse[1] = sum / n;
sum = cog_frame_component_squared_error (&a->components[2],
&b->components[2]);
n = a->components[2].width * a->components[2].height;
mse[2] = sum / n;
}
static double
mse_to_db (double mse, gboolean is_chroma)
{
if (is_chroma) {
return 10.0 * log (mse / (224.0 * 224.0)) / log (10.0);
} else {
return 10.0 * log (mse / (219.0 * 219.0)) / log (10.0);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,150 +0,0 @@
/* autogenerated from gstcogorc.orc */
#ifndef _GSTCOGORC_H_
#define _GSTCOGORC_H_
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ORC_INTEGER_TYPEDEFS_
#define _ORC_INTEGER_TYPEDEFS_
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <stdint.h>
typedef int8_t orc_int8;
typedef int16_t orc_int16;
typedef int32_t orc_int32;
typedef int64_t orc_int64;
typedef uint8_t orc_uint8;
typedef uint16_t orc_uint16;
typedef uint32_t orc_uint32;
typedef uint64_t orc_uint64;
#define ORC_UINT64_C(x) UINT64_C(x)
#elif defined(_MSC_VER)
typedef signed __int8 orc_int8;
typedef signed __int16 orc_int16;
typedef signed __int32 orc_int32;
typedef signed __int64 orc_int64;
typedef unsigned __int8 orc_uint8;
typedef unsigned __int16 orc_uint16;
typedef unsigned __int32 orc_uint32;
typedef unsigned __int64 orc_uint64;
#define ORC_UINT64_C(x) (x##Ui64)
#define inline __inline
#else
#include <limits.h>
typedef signed char orc_int8;
typedef short orc_int16;
typedef int orc_int32;
typedef unsigned char orc_uint8;
typedef unsigned short orc_uint16;
typedef unsigned int orc_uint32;
#if INT_MAX == LONG_MAX
typedef long long orc_int64;
typedef unsigned long long orc_uint64;
#define ORC_UINT64_C(x) (x##ULL)
#else
typedef long orc_int64;
typedef unsigned long orc_uint64;
#define ORC_UINT64_C(x) (x##UL)
#endif
#endif
typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;
typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;
typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64;
#endif
#ifndef ORC_RESTRICT
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define ORC_RESTRICT restrict
#elif defined(__GNUC__) && __GNUC__ >= 4
#define ORC_RESTRICT __restrict__
#else
#define ORC_RESTRICT
#endif
#endif
void cogorc_memcpy_2d (orc_uint8 * ORC_RESTRICT d1, int d1_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_downsample_horiz_cosite_1tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, int n);
void cogorc_downsample_horiz_cosite_3tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, int n);
void cogorc_downsample_420_jpeg (orc_uint8 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, int n);
void cogorc_downsample_vert_halfsite_2tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, int n);
void cogorc_downsample_vert_cosite_3tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int n);
void cogorc_downsample_vert_halfsite_4tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, int n);
void cogorc_upsample_horiz_cosite_1tap (guint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, int n);
void cogorc_upsample_horiz_cosite (guint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, int n);
void cogorc_upsample_vert_avgub (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, int n);
void orc_unpack_yuyv_y (orc_uint8 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, int n);
void orc_unpack_yuyv_u (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void orc_unpack_yuyv_v (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void orc_pack_yuyv (orc_uint32 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int n);
void orc_unpack_uyvy_y (orc_uint8 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, int n);
void orc_unpack_uyvy_u (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void orc_unpack_uyvy_v (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void orc_pack_uyvy (orc_uint32 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int n);
void orc_addc_convert_u8_s16 (orc_uint8 * ORC_RESTRICT d1, const gint16 * ORC_RESTRICT s1, int n);
void orc_subc_convert_s16_u8 (gint16 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, int n);
void orc_splat_u8_ns (orc_uint8 * ORC_RESTRICT d1, int p1, int n);
void orc_splat_s16_ns (gint16 * ORC_RESTRICT d1, int p1, int n);
void orc_matrix2_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int p1, int p2, int p3, int n);
void orc_matrix2_11_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int p1, int p2, int n);
void orc_matrix2_12_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int p1, int p2, int n);
void orc_matrix3_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int n);
void orc_matrix3_100_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int n);
void orc_matrix3_100_offset_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, int n);
void orc_matrix3_000_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, int n);
void orc_pack_123x (guint32 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int p1, int n);
void orc_pack_x123 (guint32 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int p1, int n);
void cogorc_combine2_u8 (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, int p1, int p2, int n);
void cogorc_combine4_u8 (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, int p1, int p2, int p3, int p4, int n);
void cogorc_unpack_axyz_0 (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void cogorc_unpack_axyz_1 (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void cogorc_unpack_axyz_2 (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void cogorc_unpack_axyz_3 (orc_uint8 * ORC_RESTRICT d1, const orc_uint32 * ORC_RESTRICT s1, int n);
void cogorc_resample_horiz_1tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, int p1, int p2, int n);
void cogorc_resample_horiz_2tap (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, int p1, int p2, int n);
void cogorc_convert_I420_UYVY (orc_uint32 * ORC_RESTRICT d1, orc_uint32 * ORC_RESTRICT d2, const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, int n);
void cogorc_convert_I420_YUY2 (orc_uint32 * ORC_RESTRICT d1, orc_uint32 * ORC_RESTRICT d2, const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, int n);
void cogorc_convert_I420_AYUV (orc_uint32 * ORC_RESTRICT d1, orc_uint32 * ORC_RESTRICT d2, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, int n);
void cogorc_convert_YUY2_I420 (orc_uint16 * ORC_RESTRICT d1, orc_uint16 * ORC_RESTRICT d2, orc_uint8 * ORC_RESTRICT d3, orc_uint8 * ORC_RESTRICT d4, const orc_uint32 * ORC_RESTRICT s1, const orc_uint32 * ORC_RESTRICT s2, int n);
void cogorc_convert_UYVY_YUY2 (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_planar_chroma_420_422 (orc_uint8 * ORC_RESTRICT d1, int d1_stride, orc_uint8 * ORC_RESTRICT d2, int d2_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_planar_chroma_420_444 (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint16 * ORC_RESTRICT d2, int d2_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_planar_chroma_422_444 (orc_uint16 * ORC_RESTRICT d1, int d1_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_planar_chroma_444_422 (orc_uint8 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_planar_chroma_444_420 (orc_uint8 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint16 * ORC_RESTRICT s2, int s2_stride, int n, int m);
void cogorc_planar_chroma_422_420 (orc_uint8 * ORC_RESTRICT d1, int d1_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, const orc_uint8 * ORC_RESTRICT s2, int s2_stride, int n, int m);
void cogorc_convert_YUY2_AYUV (orc_uint64 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_UYVY_AYUV (orc_uint64 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_YUY2_Y42B (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint8 * ORC_RESTRICT d2, int d2_stride, orc_uint8 * ORC_RESTRICT d3, int d3_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_UYVY_Y42B (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint8 * ORC_RESTRICT d2, int d2_stride, orc_uint8 * ORC_RESTRICT d3, int d3_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_YUY2_Y444 (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint16 * ORC_RESTRICT d2, int d2_stride, orc_uint16 * ORC_RESTRICT d3, int d3_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_UYVY_Y444 (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint16 * ORC_RESTRICT d2, int d2_stride, orc_uint16 * ORC_RESTRICT d3, int d3_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_UYVY_I420 (orc_uint16 * ORC_RESTRICT d1, orc_uint16 * ORC_RESTRICT d2, orc_uint8 * ORC_RESTRICT d3, orc_uint8 * ORC_RESTRICT d4, const orc_uint32 * ORC_RESTRICT s1, const orc_uint32 * ORC_RESTRICT s2, int n);
void cogorc_convert_AYUV_I420 (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint16 * ORC_RESTRICT d2, int d2_stride, orc_uint8 * ORC_RESTRICT d3, int d3_stride, orc_uint8 * ORC_RESTRICT d4, int d4_stride, const orc_uint64 * ORC_RESTRICT s1, int s1_stride, const orc_uint64 * ORC_RESTRICT s2, int s2_stride, int n, int m);
void cogorc_convert_AYUV_YUY2 (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint64 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_UYVY (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint64 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_Y42B (orc_uint16 * ORC_RESTRICT d1, int d1_stride, orc_uint8 * ORC_RESTRICT d2, int d2_stride, orc_uint8 * ORC_RESTRICT d3, int d3_stride, const orc_uint64 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_Y444 (orc_uint8 * ORC_RESTRICT d1, int d1_stride, orc_uint8 * ORC_RESTRICT d2, int d2_stride, orc_uint8 * ORC_RESTRICT d3, int d3_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_Y42B_YUY2 (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint8 * ORC_RESTRICT s2, int s2_stride, const orc_uint8 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_Y42B_UYVY (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint8 * ORC_RESTRICT s2, int s2_stride, const orc_uint8 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_Y42B_AYUV (orc_uint64 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint8 * ORC_RESTRICT s2, int s2_stride, const orc_uint8 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_Y444_YUY2 (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint16 * ORC_RESTRICT s2, int s2_stride, const orc_uint16 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_Y444_UYVY (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint16 * ORC_RESTRICT s1, int s1_stride, const orc_uint16 * ORC_RESTRICT s2, int s2_stride, const orc_uint16 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_Y444_AYUV (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint8 * ORC_RESTRICT s1, int s1_stride, const orc_uint8 * ORC_RESTRICT s2, int s2_stride, const orc_uint8 * ORC_RESTRICT s3, int s3_stride, int n, int m);
void cogorc_convert_AYUV_ARGB (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_BGRA (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_ABGR (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_AYUV_RGBA (orc_uint32 * ORC_RESTRICT d1, int d1_stride, const orc_uint32 * ORC_RESTRICT s1, int s1_stride, int n, int m);
void cogorc_convert_I420_BGRA (orc_uint32 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, int n);
void cogorc_convert_I420_BGRA_avg (orc_uint32 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, const orc_uint8 * ORC_RESTRICT s3, const orc_uint8 * ORC_RESTRICT s4, const orc_uint8 * ORC_RESTRICT s5, int n);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,653 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) 2005 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-videoscale
* @see_also: videorate, videoconvert
*
* <refsect2>
* <para>
* This element resizes video frames. By default the element will try to
* negotiate to the same size on the source and sinkpad so that no scaling
* is needed. It is therefore safe to insert this element in a pipeline to
* get more robust behaviour without any cost if no scaling is needed.
* </para>
* <para>
* This element supports a wide range of color spaces including various YUV and
* RGB formats and is therefore generally able to operate anywhere in a
* pipeline.
* </para>
* <title>Example pipelines</title>
* <para>
* <programlisting>
* gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! ximagesink
* </programlisting>
* Decode an Ogg/Theora and display the video using ximagesink. Since
* ximagesink cannot perform scaling, the video scaling will be performed by
* videoscale when you resize the video window.
* To create the test Ogg/Theora file refer to the documentation of theoraenc.
* </para>
* <para>
* <programlisting>
* gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw-yuv, width=50 ! xvimagesink
* </programlisting>
* Decode an Ogg/Theora and display the video using xvimagesink with a width of
* 50.
* </para>
* </refsect2>
*
* Last reviewed on 2006-03-02 (0.10.4)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/base/gstbasetransform.h>
#include <cog/cog.h>
#include <cog/cogvirtframe.h>
#include "gstcogutils.h"
GST_DEBUG_CATEGORY_STATIC (cog_scale_debug);
#define GST_CAT_DEFAULT cog_scale_debug
#define GST_TYPE_COG_SCALE \
(gst_cog_scale_get_type())
#define GST_COG_SCALE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COG_SCALE,GstCogScale))
#define GST_COG_SCALE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COG_SCALE,GstCogScaleClass))
#define GST_IS_COG_SCALE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COG_SCALE))
#define GST_IS_COG_SCALE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COG_SCALE))
typedef struct _GstCogScale GstCogScale;
typedef struct _GstCogScaleClass GstCogScaleClass;
/**
* GstCogScale:
*
* Opaque data structure
*/
struct _GstCogScale
{
GstBaseTransform element;
int quality;
/* negotiated stuff */
GstVideoFormat format;
guint src_size;
guint dest_size;
gint to_width;
gint to_height;
gint from_width;
gint from_height;
/*< private > */
};
struct _GstCogScaleClass
{
GstBaseTransformClass parent_class;
};
GType gst_cog_scale_get_type (void);
#define DEFAULT_QUALITY 5
enum
{
PROP_0,
PROP_QUALITY
};
/* can't handle width/height of 1 yet, since we divide a lot by (n-1) */
#undef GST_VIDEO_SIZE_RANGE
#define GST_VIDEO_SIZE_RANGE "(int) [ 2, MAX ]"
#define TEMPLATE_CAPS \
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV, Y42B }") ";" \
GST_VIDEO_CAPS_ARGB)
static GstStaticPadTemplate gst_cog_scale_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
TEMPLATE_CAPS);
static GstStaticPadTemplate gst_cog_scale_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
TEMPLATE_CAPS);
static void gst_cog_scale_base_init (gpointer g_class);
static void gst_cog_scale_class_init (GstCogScaleClass * klass);
static void gst_cog_scale_init (GstCogScale * videoscale);
static void gst_cog_scale_finalize (GstCogScale * videoscale);
static gboolean gst_cog_scale_src_event (GstBaseTransform * trans,
GstEvent * event);
/* base transform vmethods */
static GstCaps *gst_cog_scale_transform_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps);
static gboolean gst_cog_scale_set_caps (GstBaseTransform * trans,
GstCaps * in, GstCaps * out);
static gboolean gst_cog_scale_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, guint * size);
static GstFlowReturn gst_cog_scale_transform (GstBaseTransform * trans,
GstBuffer * in, GstBuffer * out);
static void gst_cog_scale_fixate_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
static void gst_cog_scale_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_cog_scale_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
GType
gst_cog_scale_get_type (void)
{
static GType cog_scale_type = 0;
if (!cog_scale_type) {
static const GTypeInfo cog_scale_info = {
sizeof (GstCogScaleClass),
gst_cog_scale_base_init,
NULL,
(GClassInitFunc) gst_cog_scale_class_init,
NULL,
NULL,
sizeof (GstCogScale),
0,
(GInstanceInitFunc) gst_cog_scale_init,
};
cog_scale_type =
g_type_register_static (GST_TYPE_BASE_TRANSFORM, "GstCogScale",
&cog_scale_info, 0);
GST_DEBUG_CATEGORY_INIT (cog_scale_debug, "cogscale", 0, "Cog scale");
}
return cog_scale_type;
}
static void
gst_cog_scale_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_static_metadata (element_class, "Video scaler",
"Filter/Effect/Video",
"Resizes video", "Wim Taymans <wim.taymans@chello.be>");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_cog_scale_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_cog_scale_sink_template));
}
static void
gst_cog_scale_class_init (GstCogScaleClass * klass)
{
GObjectClass *gobject_class;
GstBaseTransformClass *trans_class;
gobject_class = (GObjectClass *) klass;
trans_class = (GstBaseTransformClass *) klass;
gobject_class->finalize = (GObjectFinalizeFunc) gst_cog_scale_finalize;
gobject_class->set_property = gst_cog_scale_set_property;
gobject_class->get_property = gst_cog_scale_get_property;
g_object_class_install_property (gobject_class, PROP_QUALITY,
g_param_spec_int ("quality", "quality", "Scaling Quality",
0, 10, DEFAULT_QUALITY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
trans_class->transform_caps =
GST_DEBUG_FUNCPTR (gst_cog_scale_transform_caps);
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_cog_scale_set_caps);
trans_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_cog_scale_get_unit_size);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_cog_scale_transform);
trans_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_cog_scale_fixate_caps);
trans_class->src_event = GST_DEBUG_FUNCPTR (gst_cog_scale_src_event);
trans_class->passthrough_on_same_caps = TRUE;
parent_class = g_type_class_peek_parent (klass);
}
static void
gst_cog_scale_init (GstCogScale * videoscale)
{
gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (videoscale), TRUE);
videoscale->quality = DEFAULT_QUALITY;
}
static void
gst_cog_scale_finalize (GstCogScale * videoscale)
{
G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (videoscale));
}
static void
gst_cog_scale_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstCogScale *vscale = GST_COG_SCALE (object);
switch (prop_id) {
case PROP_QUALITY:
GST_OBJECT_LOCK (vscale);
vscale->quality = g_value_get_int (value);
GST_OBJECT_UNLOCK (vscale);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_cog_scale_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstCogScale *vscale = GST_COG_SCALE (object);
switch (prop_id) {
case PROP_QUALITY:
GST_OBJECT_LOCK (vscale);
g_value_set_int (value, vscale->quality);
GST_OBJECT_UNLOCK (vscale);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstCaps *
gst_cog_scale_transform_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps)
{
GstCaps *ret;
GstStructure *structure;
const GValue *par;
/* this function is always called with a simple caps */
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
structure = gst_caps_get_structure (caps, 0);
ret = gst_caps_copy (caps);
structure = gst_caps_get_structure (ret, 0);
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
/* if pixel aspect ratio, make a range of it */
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
GstCaps *copy;
GstStructure *cstruct;
/* copy input PAR first, this is the prefered PAR */
gst_structure_set_value (structure, "pixel-aspect-ratio", par);
/* then make a copy with a fraction range as a second choice */
copy = gst_caps_copy (ret);
cstruct = gst_caps_get_structure (copy, 0);
gst_structure_set (cstruct,
"pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
/* and append */
gst_caps_append (ret, copy);
}
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
return ret;
}
static gboolean
gst_cog_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
{
GstCogScale *videoscale;
gboolean ret;
videoscale = GST_COG_SCALE (trans);
ret = gst_video_format_parse_caps (in, &videoscale->format,
&videoscale->from_width, &videoscale->from_height);
ret &= gst_video_format_parse_caps (out, NULL,
&videoscale->to_width, &videoscale->to_height);
if (!ret)
goto done;
videoscale->src_size = gst_video_format_get_size (videoscale->format,
videoscale->from_width, videoscale->from_height);
videoscale->dest_size = gst_video_format_get_size (videoscale->format,
videoscale->to_width, videoscale->to_height);
/* FIXME: par */
GST_DEBUG_OBJECT (videoscale, "from=%dx%d, size %d -> to=%dx%d, size %d",
videoscale->from_width, videoscale->from_height, videoscale->src_size,
videoscale->to_width, videoscale->to_height, videoscale->dest_size);
done:
return ret;
}
static gboolean
gst_cog_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
guint * size)
{
GstVideoFormat format;
gint width, height;
g_assert (size);
if (!gst_video_format_parse_caps (caps, &format, &width, &height))
return FALSE;
*size = gst_video_format_get_size (format, width, height);
return TRUE;
}
static void
gst_cog_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
GstCaps * caps, GstCaps * othercaps)
{
GstStructure *ins, *outs;
const GValue *from_par, *to_par;
g_return_if_fail (gst_caps_is_fixed (caps));
GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
ins = gst_caps_get_structure (caps, 0);
outs = gst_caps_get_structure (othercaps, 0);
from_par = gst_structure_get_value (ins, "pixel-aspect-ratio");
to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
/* we have both PAR but they might not be fixated */
if (from_par && to_par) {
gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
gint count = 0, w = 0, h = 0;
guint num, den;
/* from_par should be fixed */
g_return_if_fail (gst_value_is_fixed (from_par));
from_par_n = gst_value_get_fraction_numerator (from_par);
from_par_d = gst_value_get_fraction_denominator (from_par);
/* fixate the out PAR */
if (!gst_value_is_fixed (to_par)) {
GST_DEBUG_OBJECT (base, "fixating to_par to %dx%d", from_par_n,
from_par_d);
gst_structure_fixate_field_nearest_fraction (outs, "pixel-aspect-ratio",
from_par_n, from_par_d);
}
to_par_n = gst_value_get_fraction_numerator (to_par);
to_par_d = gst_value_get_fraction_denominator (to_par);
/* if both width and height are already fixed, we can't do anything
* about it anymore */
if (gst_structure_get_int (outs, "width", &w))
++count;
if (gst_structure_get_int (outs, "height", &h))
++count;
if (count == 2) {
GST_DEBUG_OBJECT (base, "dimensions already set to %dx%d, not fixating",
w, h);
return;
}
gst_structure_get_int (ins, "width", &from_w);
gst_structure_get_int (ins, "height", &from_h);
if (!gst_video_calculate_display_ratio (&num, &den, from_w, from_h,
from_par_n, from_par_d, to_par_n, to_par_d)) {
GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
("Error calculating the output scaled size - integer overflow"));
return;
}
GST_DEBUG_OBJECT (base,
"scaling input with %dx%d and PAR %d/%d to output PAR %d/%d",
from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d);
GST_DEBUG_OBJECT (base, "resulting output should respect ratio of %d/%d",
num, den);
/* now find a width x height that respects this display ratio.
* prefer those that have one of w/h the same as the incoming video
* using wd / hd = num / den */
/* if one of the output width or height is fixed, we work from there */
if (h) {
GST_DEBUG_OBJECT (base, "height is fixed,scaling width");
w = (guint) gst_util_uint64_scale_int (h, num, den);
} else if (w) {
GST_DEBUG_OBJECT (base, "width is fixed, scaling height");
h = (guint) gst_util_uint64_scale_int (w, den, num);
} else {
/* none of width or height is fixed, figure out both of them based only on
* the input width and height */
/* check hd / den is an integer scale factor, and scale wd with the PAR */
if (from_h % den == 0) {
GST_DEBUG_OBJECT (base, "keeping video height");
h = from_h;
w = (guint) gst_util_uint64_scale_int (h, num, den);
} else if (from_w % num == 0) {
GST_DEBUG_OBJECT (base, "keeping video width");
w = from_w;
h = (guint) gst_util_uint64_scale_int (w, den, num);
} else {
GST_DEBUG_OBJECT (base, "approximating but keeping video height");
h = from_h;
w = (guint) gst_util_uint64_scale_int (h, num, den);
}
}
GST_DEBUG_OBJECT (base, "scaling to %dx%d", w, h);
/* now fixate */
gst_structure_fixate_field_nearest_int (outs, "width", w);
gst_structure_fixate_field_nearest_int (outs, "height", h);
} else {
gint width, height;
if (gst_structure_get_int (ins, "width", &width)) {
if (gst_structure_has_field (outs, "width")) {
gst_structure_fixate_field_nearest_int (outs, "width", width);
}
}
if (gst_structure_get_int (ins, "height", &height)) {
if (gst_structure_has_field (outs, "height")) {
gst_structure_fixate_field_nearest_int (outs, "height", height);
}
}
}
GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, othercaps);
}
#if 0
static gboolean
gst_cog_scale_prepare_image (gint format, GstBuffer * buf,
VSImage * img, VSImage * img_u, VSImage * img_v)
{
gboolean res = TRUE;
img->pixels = GST_BUFFER_DATA (buf);
switch (format) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
img_u->pixels = img->pixels + GST_ROUND_UP_2 (img->height) * img->stride;
img_u->height = GST_ROUND_UP_2 (img->height) / 2;
img_u->width = GST_ROUND_UP_2 (img->width) / 2;
img_u->stride = GST_ROUND_UP_4 (img_u->width);
memcpy (img_v, img_u, sizeof (*img_v));
img_v->pixels = img_u->pixels + img_u->height * img_u->stride;
break;
default:
break;
}
return res;
}
#endif
static GstFlowReturn
gst_cog_scale_transform (GstBaseTransform * trans, GstBuffer * in,
GstBuffer * out)
{
GstCogScale *videoscale;
GstFlowReturn ret = GST_FLOW_OK;
CogFrame *outframe;
CogFrame *frame;
int w, h;
int quality;
static const int n_vert_taps[11] = { 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4 };
static const int n_horiz_taps[11] = { 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4 };
videoscale = GST_COG_SCALE (trans);
GST_OBJECT_LOCK (videoscale);
quality = videoscale->quality;
GST_OBJECT_UNLOCK (videoscale);
frame = gst_cog_buffer_wrap (gst_buffer_ref (in), videoscale->format,
videoscale->from_width, videoscale->from_height);
outframe = gst_cog_buffer_wrap (gst_buffer_ref (out), videoscale->format,
videoscale->to_width, videoscale->to_height);
frame = cog_virt_frame_new_unpack (frame);
w = videoscale->from_width;
h = videoscale->from_height;
while (w >= 2 * videoscale->to_width || h >= 2 * videoscale->to_height) {
if (w >= 2 * videoscale->to_width) {
frame = cog_virt_frame_new_horiz_downsample (frame, 3);
w /= 2;
}
if (h >= 2 * videoscale->to_height) {
frame = cog_virt_frame_new_vert_downsample (frame, 4);
h /= 2;
}
}
if (w != videoscale->to_width) {
frame = cog_virt_frame_new_horiz_resample (frame, videoscale->to_width,
n_horiz_taps[quality]);
}
if (h != videoscale->to_height) {
frame = cog_virt_frame_new_vert_resample (frame, videoscale->to_height,
n_vert_taps[quality]);
}
switch (videoscale->format) {
case GST_VIDEO_FORMAT_YUY2:
frame = cog_virt_frame_new_pack_YUY2 (frame);
break;
case GST_VIDEO_FORMAT_UYVY:
frame = cog_virt_frame_new_pack_UYVY (frame);
break;
default:
break;
}
cog_virt_frame_render (frame, outframe);
cog_frame_unref (frame);
cog_frame_unref (outframe);
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
GST_BUFFER_SIZE (out));
return ret;
/* ERRORS */
#if 0
unsupported:
{
GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
("Unsupported format %d for scaling method %d",
videoscale->format, method));
return GST_FLOW_ERROR;
}
unknown_mode:
{
GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
("Unknown scaling method %d", videoscale->method));
return GST_FLOW_ERROR;
}
#endif
}
static gboolean
gst_cog_scale_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstCogScale *videoscale;
gboolean ret;
double a;
GstStructure *structure;
videoscale = GST_COG_SCALE (trans);
GST_DEBUG_OBJECT (videoscale, "handling %s event",
GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
event =
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
structure = (GstStructure *) gst_event_get_structure (event);
if (gst_structure_get_double (structure, "pointer_x", &a)) {
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
a * videoscale->from_width / videoscale->to_width, NULL);
}
if (gst_structure_get_double (structure, "pointer_y", &a)) {
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
a * videoscale->from_height / videoscale->to_height, NULL);
}
break;
case GST_EVENT_QOS:
break;
default:
break;
}
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
return ret;
}

View file

@ -1,185 +0,0 @@
/* Cog
* Copyright (C) 2008 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstcogutils.h"
#include <gst/gst.h>
#include <gst/video/video.h>
#include <cog/cog.h>
#include <cog/cogvirtframe.h>
#include <math.h>
#include <string.h>
GST_DEBUG_CATEGORY_EXTERN (cog_debug);
#define GST_CAT_DEFAULT cog_debug
static void
gst_cog_frame_free (CogFrame * frame, void *priv)
{
gst_buffer_unref (GST_BUFFER (priv));
}
CogFrame *
gst_cog_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width,
int height)
{
CogFrame *frame;
int size;
size = gst_video_format_get_size (format, width, height);
if (GST_BUFFER_SIZE (buf) != size) {
GST_ERROR ("size incorrect, expected %d, got %d", size,
GST_BUFFER_SIZE (buf));
}
switch (format) {
case GST_VIDEO_FORMAT_I420:
frame =
cog_frame_new_from_data_I420 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_YV12:
frame =
cog_frame_new_from_data_YV12 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_YUY2:
frame =
cog_frame_new_from_data_YUY2 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_UYVY:
frame =
cog_frame_new_from_data_UYVY (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_AYUV:
frame =
cog_frame_new_from_data_AYUV (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_Y42B:
frame =
cog_frame_new_from_data_Y42B (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_Y444:
frame =
cog_frame_new_from_data_Y444 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_v210:
frame =
cog_frame_new_from_data_v210 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_v216:
frame =
cog_frame_new_from_data_v216 (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_RGBx:
frame =
cog_frame_new_from_data_RGBx (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_BGRx:
frame =
cog_frame_new_from_data_BGRx (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_xRGB:
frame =
cog_frame_new_from_data_xRGB (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_xBGR:
frame =
cog_frame_new_from_data_xBGR (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_RGBA:
frame =
cog_frame_new_from_data_RGBA (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_BGRA:
frame =
cog_frame_new_from_data_BGRA (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_ARGB:
frame =
cog_frame_new_from_data_ARGB (GST_BUFFER_DATA (buf), width, height);
break;
case GST_VIDEO_FORMAT_ABGR:
frame =
cog_frame_new_from_data_ABGR (GST_BUFFER_DATA (buf), width, height);
break;
default:
g_assert_not_reached ();
return NULL;
}
cog_frame_set_free_callback (frame, gst_cog_frame_free, buf);
return frame;
}
#if 0
#ifdef GST_BUFFER_FREE_FUNC
static void
cog_buf_free_func (gpointer priv)
{
CogBuffer *buffer = (CogBuffer *) priv;
cog_buffer_unref (buffer);
}
#endif
/* takes the reference */
GstBuffer *
gst_cog_wrap_cog_buffer (CogBuffer * buffer)
{
GstBuffer *gstbuf;
#ifdef GST_BUFFER_FREE_FUNC
gstbuf = gst_buffer_new ();
GST_BUFFER_DATA (gstbuf) = buffer->data;
GST_BUFFER_SIZE (gstbuf) = buffer->length;
GST_BUFFER_MALLOCDATA (gstbuf) = (void *) buffer;
GST_BUFFER_FREE_FUNC (gstbuf) = cog_buf_free_func;
#else
gstbuf = gst_buffer_new_and_alloc (buffer->length);
memcpy (GST_BUFFER_DATA (gstbuf), buffer->data, buffer->length);
#endif
return gstbuf;
}
static void
gst_cog_buffer_free (CogBuffer * buffer, void *priv)
{
gst_buffer_unref (GST_BUFFER (priv));
}
CogBuffer *
gst_cog_wrap_gst_buffer (GstBuffer * buffer)
{
CogBuffer *cogbuf;
cogbuf = cog_buffer_new_with_data (GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer));
cogbuf->free = gst_cog_buffer_free;
cogbuf->priv = buffer;
return cogbuf;
}
#endif

View file

@ -1,37 +0,0 @@
/* Schrodinger
* Copyright (C) 2008 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _GST_COG_UTILS_H_
#define _GST_COG_UTILS_H_
#include <gst/gst.h>
#include <gst/video/video.h>
#include <cog/cog.h>
#include <cog/cogframe.h>
CogFrame *
gst_cog_buffer_wrap (GstBuffer *buf, GstVideoFormat format, int width,
int height);
#if 0
GstBuffer * gst_cog_wrap_cog_buffer (CogBuffer *buffer);
CogBuffer * gst_cog_wrap_gst_buffer (GstBuffer *buffer);
#endif
#endif