video: fill in the pack/unpack functions

Add support for supporting chroma subsampling correctly in the pack
function.
Fill in the pack and unpack functions for most formats.
Add some missing pack/unpack functions to the orc file.
This commit is contained in:
Wim Taymans 2012-05-29 15:12:16 +02:00
parent f859dcd699
commit abe4b0b235
6 changed files with 1754 additions and 88 deletions

View file

@ -1,4 +1,7 @@
# variables used for enum generation
ORC_SOURCE=videoblendorc
include $(top_srcdir)/common/orc.mak
glib_enum_headers = video.h colorbalance.h navigation.h
glib_enum_define = GST_VIDEO
glib_gen_prefix = gst_video
@ -28,7 +31,7 @@ libgstvideo_@GST_API_VERSION@_la_SOURCES = \
gstvideoencoder.c \
gstvideoutils.c
nodist_libgstvideo_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES)
nodist_libgstvideo_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES) $(ORC_NODIST_SOURCES)
libgstvideo_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/video
libgstvideo_@GST_API_VERSION@include_HEADERS = \
@ -47,8 +50,9 @@ libgstvideo_@GST_API_VERSION@include_HEADERS = \
gstvideoutils.h
nodist_libgstvideo_@GST_API_VERSION@include_HEADERS = $(built_headers)
libgstvideo_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstvideo_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
libgstvideo_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \
$(ORC_CFLAGS)
libgstvideo_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS)
libgstvideo_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
include $(top_srcdir)/common/gst-glib-gen.mak

File diff suppressed because it is too large Load diff

View file

@ -130,6 +130,8 @@ typedef enum {
#define GST_VIDEO_MAX_COMPONENTS 4
typedef struct _GstVideoFormatInfo GstVideoFormatInfo;
typedef struct _GstVideoColorimetry GstVideoColorimetry;
typedef enum _GstVideoChromaSite GstVideoChromaSite;
/**
* GstVideoFormatFlags:
@ -207,21 +209,28 @@ typedef void (*GstVideoFormatUnpack) (GstVideoFormatInfo *info,
* @info: a #GstVideoFormatInfo
* @flags: flags to control the packing
* @src: a source array
* @sstride: the source array stride
* @data: pointers to the destination data planes
* @stride: strides of the destination planes
* @x: the x position in the image to pack to
* @chroma_site: the chroma siting of the target when subsampled
* @y: the y position in the image to pack to
* @width: the amount of pixels to pack.
*
* Packs @width pixels from @src to the given planes and strides in the
* format @info. The pixels from source have each component interleaved
* and will be packed into the planes in @data.
*
* When @info refers to a format with a h_sub != 0, this function operates on
* (1 << h_sub) lines meaning that @src should contain at least (1 << h_sub)
* lines with a stride of @sstride and @y should be a multiple of (1 << h_sub).
*/
typedef void (*GstVideoFormatPack) (GstVideoFormatInfo *info,
GstVideoPackFlags flags, const gpointer src,
GstVideoPackFlags flags,
const gpointer src, gint sstride,
gpointer data[GST_VIDEO_MAX_PLANES],
const gint stride[GST_VIDEO_MAX_PLANES],
gint x, gint y, gint width);
GstVideoChromaSite chroma_site,
gint y, gint width);
/**
* GstVideoFormatInfo:
@ -382,7 +391,7 @@ typedef enum {
*
* Various Chroma sitings.
*/
typedef enum {
enum _GstVideoChromaSite {
GST_VIDEO_CHROMA_SITE_UNKNOWN = 0,
GST_VIDEO_CHROMA_SITE_NONE = (1 << 0),
GST_VIDEO_CHROMA_SITE_H_COSITED = (1 << 1),
@ -393,7 +402,7 @@ typedef enum {
GST_VIDEO_CHROMA_SITE_JPEG = (GST_VIDEO_CHROMA_SITE_NONE),
GST_VIDEO_CHROMA_SITE_MPEG2 = (GST_VIDEO_CHROMA_SITE_H_COSITED),
GST_VIDEO_CHROMA_SITE_DV = (GST_VIDEO_CHROMA_SITE_COSITED | GST_VIDEO_CHROMA_SITE_ALT_LINE),
} GstVideoChromaSite;
};
/**
* GstVideoColorRange:
@ -500,12 +509,12 @@ typedef enum {
*
* Structure describing the color info.
*/
typedef struct {
struct _GstVideoColorimetry {
GstVideoColorRange range;
GstVideoColorMatrix matrix;
GstVideoTransferFunction transfer;
GstVideoColorPrimaries primaries;
} GstVideoColorimetry;
};
/* predefined colorimetry */
#define GST_VIDEO_COLORIMETRY_BT601 "bt601"

View file

@ -99,6 +99,10 @@ void cogorc_putline_UYVY (guint8 * ORC_RESTRICT d1,
const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_UYVY (guint8 * ORC_RESTRICT d1,
const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_YVYU (guint8 * ORC_RESTRICT d1,
const guint8 * ORC_RESTRICT s1, int n);
void cogorc_putline_YVYU (guint8 * ORC_RESTRICT d1,
const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_YUV9 (guint8 * ORC_RESTRICT d1,
const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2,
const guint8 * ORC_RESTRICT s3, int n);
@ -2044,6 +2048,436 @@ cogorc_getline_UYVY (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1,
#endif
/* cogorc_getline_YVYU */
#ifdef DISABLE_ORC
void
cogorc_getline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1,
int n)
{
int i;
orc_union64 *ORC_RESTRICT ptr0;
const orc_union32 *ORC_RESTRICT ptr4;
orc_union32 var36;
orc_union16 var37;
orc_union64 var38;
orc_union16 var39;
orc_union16 var40;
orc_union16 var41;
orc_union32 var42;
orc_union32 var43;
ptr0 = (orc_union64 *) d1;
ptr4 = (orc_union32 *) s1;
/* 3: loadpb */
var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */
var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */
for (i = 0; i < n; i++) {
/* 0: loadl */
var36 = ptr4[i];
/* 1: splitwb */
{
orc_union16 _src;
_src.i = var36.x2[0];
var39.x2[0] = _src.x2[1];
var40.x2[0] = _src.x2[0];
}
{
orc_union16 _src;
_src.i = var36.x2[1];
var39.x2[1] = _src.x2[1];
var40.x2[1] = _src.x2[0];
}
/* 2: swapw */
var41.i = ORC_SWAP_W (var39.i);
/* 4: mergebw */
{
orc_union16 _dest;
_dest.x2[0] = var37.x2[0];
_dest.x2[1] = var40.x2[0];
var42.x2[0] = _dest.i;
}
{
orc_union16 _dest;
_dest.x2[0] = var37.x2[1];
_dest.x2[1] = var40.x2[1];
var42.x2[1] = _dest.i;
}
/* 5: mergewl */
{
orc_union32 _dest;
_dest.x2[0] = var41.i;
_dest.x2[1] = var41.i;
var43.i = _dest.i;
}
/* 6: mergewl */
{
orc_union32 _dest;
_dest.x2[0] = var42.x2[0];
_dest.x2[1] = var43.x2[0];
var38.x2[0] = _dest.i;
}
{
orc_union32 _dest;
_dest.x2[0] = var42.x2[1];
_dest.x2[1] = var43.x2[1];
var38.x2[1] = _dest.i;
}
/* 7: storeq */
ptr0[i] = var38;
}
}
#else
static void
_backup_cogorc_getline_YVYU (OrcExecutor * ORC_RESTRICT ex)
{
int i;
int n = ex->n;
orc_union64 *ORC_RESTRICT ptr0;
const orc_union32 *ORC_RESTRICT ptr4;
orc_union32 var36;
orc_union16 var37;
orc_union64 var38;
orc_union16 var39;
orc_union16 var40;
orc_union16 var41;
orc_union32 var42;
orc_union32 var43;
ptr0 = (orc_union64 *) ex->arrays[0];
ptr4 = (orc_union32 *) ex->arrays[4];
/* 3: loadpb */
var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */
var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */
for (i = 0; i < n; i++) {
/* 0: loadl */
var36 = ptr4[i];
/* 1: splitwb */
{
orc_union16 _src;
_src.i = var36.x2[0];
var39.x2[0] = _src.x2[1];
var40.x2[0] = _src.x2[0];
}
{
orc_union16 _src;
_src.i = var36.x2[1];
var39.x2[1] = _src.x2[1];
var40.x2[1] = _src.x2[0];
}
/* 2: swapw */
var41.i = ORC_SWAP_W (var39.i);
/* 4: mergebw */
{
orc_union16 _dest;
_dest.x2[0] = var37.x2[0];
_dest.x2[1] = var40.x2[0];
var42.x2[0] = _dest.i;
}
{
orc_union16 _dest;
_dest.x2[0] = var37.x2[1];
_dest.x2[1] = var40.x2[1];
var42.x2[1] = _dest.i;
}
/* 5: mergewl */
{
orc_union32 _dest;
_dest.x2[0] = var41.i;
_dest.x2[1] = var41.i;
var43.i = _dest.i;
}
/* 6: mergewl */
{
orc_union32 _dest;
_dest.x2[0] = var42.x2[0];
_dest.x2[1] = var43.x2[0];
var38.x2[0] = _dest.i;
}
{
orc_union32 _dest;
_dest.x2[0] = var42.x2[1];
_dest.x2[1] = var43.x2[1];
var38.x2[1] = _dest.i;
}
/* 7: storeq */
ptr0[i] = var38;
}
}
void
cogorc_getline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1,
int n)
{
OrcExecutor _ex, *ex = &_ex;
static volatile int p_inited = 0;
static OrcProgram *p = 0;
void (*func) (OrcExecutor *);
if (!p_inited) {
orc_once_mutex_lock ();
if (!p_inited) {
p = orc_program_new ();
orc_program_set_name (p, "cogorc_getline_YVYU");
orc_program_set_backup_function (p, _backup_cogorc_getline_YVYU);
orc_program_add_destination (p, 8, "d1");
orc_program_add_source (p, 4, "s1");
orc_program_add_constant (p, 2, 0x000000ff, "c1");
orc_program_add_temporary (p, 2, "t1");
orc_program_add_temporary (p, 2, "t2");
orc_program_add_temporary (p, 4, "t3");
orc_program_add_temporary (p, 4, "t4");
orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_S1,
ORC_VAR_D1);
orc_program_append_2 (p, "swapw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_D1,
ORC_VAR_D1);
orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T3, ORC_VAR_C1, ORC_VAR_T1,
ORC_VAR_D1);
orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T4, ORC_VAR_T2, ORC_VAR_T2,
ORC_VAR_D1);
orc_program_append_2 (p, "mergewl", 1, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_T4,
ORC_VAR_D1);
orc_program_compile (p);
}
p_inited = TRUE;
orc_once_mutex_unlock ();
}
ex->program = p;
ex->n = n;
ex->arrays[ORC_VAR_D1] = d1;
ex->arrays[ORC_VAR_S1] = (void *) s1;
func = p->code_exec;
func (ex);
}
#endif
/* cogorc_putline_YVYU */
#ifdef DISABLE_ORC
void
cogorc_putline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1,
int n)
{
int i;
orc_union32 *ORC_RESTRICT ptr0;
const orc_union64 *ORC_RESTRICT ptr4;
orc_union64 var37;
orc_union32 var38;
orc_union32 var39;
orc_union32 var40;
orc_union16 var41;
orc_union16 var42;
orc_union16 var43;
orc_union16 var44;
orc_union16 var45;
ptr0 = (orc_union32 *) d1;
ptr4 = (orc_union64 *) s1;
for (i = 0; i < n; i++) {
/* 0: loadq */
var37 = ptr4[i];
/* 1: splitlw */
{
orc_union32 _src;
_src.i = var37.x2[0];
var39.x2[0] = _src.x2[1];
var40.x2[0] = _src.x2[0];
}
{
orc_union32 _src;
_src.i = var37.x2[1];
var39.x2[1] = _src.x2[1];
var40.x2[1] = _src.x2[0];
}
/* 2: splitlw */
{
orc_union32 _src;
_src.i = var39.i;
var41.i = _src.x2[1];
var42.i = _src.x2[0];
}
/* 3: avgub */
var43.x2[0] = ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1;
var43.x2[1] = ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1;
/* 4: select1wb */
{
orc_union16 _src;
_src.i = var40.x2[0];
var44.x2[0] = _src.x2[1];
}
{
orc_union16 _src;
_src.i = var40.x2[1];
var44.x2[1] = _src.x2[1];
}
/* 5: swapw */
var45.i = ORC_SWAP_W (var43.i);
/* 6: mergebw */
{
orc_union16 _dest;
_dest.x2[0] = var44.x2[0];
_dest.x2[1] = var45.x2[0];
var38.x2[0] = _dest.i;
}
{
orc_union16 _dest;
_dest.x2[0] = var44.x2[1];
_dest.x2[1] = var45.x2[1];
var38.x2[1] = _dest.i;
}
/* 7: storel */
ptr0[i] = var38;
}
}
#else
static void
_backup_cogorc_putline_YVYU (OrcExecutor * ORC_RESTRICT ex)
{
int i;
int n = ex->n;
orc_union32 *ORC_RESTRICT ptr0;
const orc_union64 *ORC_RESTRICT ptr4;
orc_union64 var37;
orc_union32 var38;
orc_union32 var39;
orc_union32 var40;
orc_union16 var41;
orc_union16 var42;
orc_union16 var43;
orc_union16 var44;
orc_union16 var45;
ptr0 = (orc_union32 *) ex->arrays[0];
ptr4 = (orc_union64 *) ex->arrays[4];
for (i = 0; i < n; i++) {
/* 0: loadq */
var37 = ptr4[i];
/* 1: splitlw */
{
orc_union32 _src;
_src.i = var37.x2[0];
var39.x2[0] = _src.x2[1];
var40.x2[0] = _src.x2[0];
}
{
orc_union32 _src;
_src.i = var37.x2[1];
var39.x2[1] = _src.x2[1];
var40.x2[1] = _src.x2[0];
}
/* 2: splitlw */
{
orc_union32 _src;
_src.i = var39.i;
var41.i = _src.x2[1];
var42.i = _src.x2[0];
}
/* 3: avgub */
var43.x2[0] = ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1;
var43.x2[1] = ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1;
/* 4: select1wb */
{
orc_union16 _src;
_src.i = var40.x2[0];
var44.x2[0] = _src.x2[1];
}
{
orc_union16 _src;
_src.i = var40.x2[1];
var44.x2[1] = _src.x2[1];
}
/* 5: swapw */
var45.i = ORC_SWAP_W (var43.i);
/* 6: mergebw */
{
orc_union16 _dest;
_dest.x2[0] = var44.x2[0];
_dest.x2[1] = var45.x2[0];
var38.x2[0] = _dest.i;
}
{
orc_union16 _dest;
_dest.x2[0] = var44.x2[1];
_dest.x2[1] = var45.x2[1];
var38.x2[1] = _dest.i;
}
/* 7: storel */
ptr0[i] = var38;
}
}
void
cogorc_putline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1,
int n)
{
OrcExecutor _ex, *ex = &_ex;
static volatile int p_inited = 0;
static OrcProgram *p = 0;
void (*func) (OrcExecutor *);
if (!p_inited) {
orc_once_mutex_lock ();
if (!p_inited) {
p = orc_program_new ();
orc_program_set_name (p, "cogorc_putline_YVYU");
orc_program_set_backup_function (p, _backup_cogorc_putline_YVYU);
orc_program_add_destination (p, 4, "d1");
orc_program_add_source (p, 8, "s1");
orc_program_add_temporary (p, 2, "t1");
orc_program_add_temporary (p, 2, "t2");
orc_program_add_temporary (p, 2, "t3");
orc_program_add_temporary (p, 4, "t4");
orc_program_add_temporary (p, 4, "t5");
orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T5, ORC_VAR_T4, ORC_VAR_S1,
ORC_VAR_D1);
orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T2, ORC_VAR_T3, ORC_VAR_T5,
ORC_VAR_D1);
orc_program_append_2 (p, "avgub", 1, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T3,
ORC_VAR_D1);
orc_program_append_2 (p, "select1wb", 1, ORC_VAR_T1, ORC_VAR_T4,
ORC_VAR_D1, ORC_VAR_D1);
orc_program_append_2 (p, "swapw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_D1,
ORC_VAR_D1);
orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2,
ORC_VAR_D1);
orc_program_compile (p);
}
p_inited = TRUE;
orc_once_mutex_unlock ();
}
ex->program = p;
ex->n = n;
ex->arrays[ORC_VAR_D1] = d1;
ex->arrays[ORC_VAR_S1] = (void *) s1;
func = p->code_exec;
func (ex);
}
#endif
/* cogorc_getline_YUV9 */
#ifdef DISABLE_ORC
void

View file

@ -75,6 +75,8 @@ void cogorc_getline_YUY2 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT
void cogorc_putline_YUY2 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n);
void cogorc_putline_UYVY (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_UYVY (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n);
void cogorc_putline_YVYU (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n);
void cogorc_getline_YUV9 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int n);
void cogorc_getline_Y42B (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int n);
void cogorc_putline_Y42B (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, const guint8 * ORC_RESTRICT s1, int n);

View file

@ -160,6 +160,39 @@ mergewl uvuv, uv, uv
x2 mergewl ayuv, ayay, uvuv
.function cogorc_getline_YVYU
.dest 8 ayuv guint8
.source 4 uyvy guint8
.const 2 c255 0xff
.temp 2 yy
.temp 2 uv
.temp 4 ayay
.temp 4 uvuv
x2 splitwb uv, yy, uyvy
swapw uv, uv
x2 mergebw ayay, c255, yy
mergewl uvuv, uv, uv
x2 mergewl ayuv, ayay, uvuv
.function cogorc_putline_YVYU
.dest 4 yuy2 guint8
.source 8 ayuv guint8
.temp 2 yy
.temp 2 uv1
.temp 2 uv2
.temp 4 ayay
.temp 4 uvuv
x2 splitlw uvuv, ayay, ayuv
splitlw uv1, uv2, uvuv
x2 avgub uv1, uv1, uv2
x2 select1wb yy, ayay
swapw uv1, uv1
x2 mergebw yuy2, yy, uv1
.function cogorc_getline_YUV9
.dest 8 d guint8
.source 2 y guint8