video-chroma: optimize chroma subsampling a little

Combine multiplies in 4x filters.
Rename conversion functions to make them nicer in orc.
Add ORC versions for various downsampling algorithms
Add unit test chroma resampler
This commit is contained in:
Wim Taymans 2014-11-06 13:08:42 +01:00
parent 64c1303dd0
commit 21f57317bb
3 changed files with 326 additions and 167 deletions

View file

@ -24,6 +24,7 @@
#include <string.h>
#include <stdio.h>
#include "video-orc.h"
#include "video-format.h"
typedef struct
@ -105,7 +106,7 @@ struct _GstVideoChromaResample
#define PB3(i) (l3[3 + 4 * (i)])
#define FILT_1_1(a,b) ((a) + (b) + 1) >> 1
#define FILT_1_3_3_1(a,b,c,d) ((a) + 3*(b) + 3*(c) + (d) + 4) >> 3
#define FILT_1_3_3_1(a,b,c,d) ((a) + 3*((b)+(c)) + (d) + 4) >> 3
#define FILT_3_1(a,b) (3*(a) + (b) + 2) >> 2
#define FILT_1_3(a,b) ((a) + 3*(b) + 2) >> 2
@ -119,7 +120,7 @@ struct _GstVideoChromaResample
#define FILT_10_3_2_1(a,b,c,d) (10*(a) + 3*(b) + 2*(c) + (d) + 8) >> 16
#define FILT_1_2_3_10(a,b,c,d) ((a) + 2*(b) + 3*(c) + 10*(d) + 8) >> 16
#define FILT_1_2_3_4_3_2_1(a,b,c,d,e,f,g) ((a) + 2*(b) + 3*(c) + 4*(d) + 3*(e) + 2*(f) + (g) + 8) >> 16
#define FILT_1_2_3_4_3_2_1(a,b,c,d,e,f,g) ((a) + 2*((b)+(f)) + 3*((c)+(e)) + 4*(d) + (g) + 8) >> 16
/* 2x horizontal upsampling without cositing
*
@ -131,9 +132,9 @@ struct _GstVideoChromaResample
* x x
* a b
*/
#define MAKE_UPSAMPLE_H2(type) \
#define MAKE_UPSAMPLE_H2(name,type) \
static void \
video_chroma_up_h2_##type (GstVideoChromaResample *resample, \
video_chroma_up_h2_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -163,9 +164,9 @@ video_chroma_up_h2_##type (GstVideoChromaResample *resample, \
* b x x x
* O--O--O- <---- b
*/
#define MAKE_UPSAMPLE_V2(type) \
#define MAKE_UPSAMPLE_V2(name,type) \
static void \
video_chroma_up_v2_##type (GstVideoChromaResample *resample, \
video_chroma_up_v2_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
gint i; \
@ -208,9 +209,9 @@ video_chroma_up_v2_##type (GstVideoChromaResample *resample, \
* d x x x
* --------------O--O--O-
*/
#define MAKE_UPSAMPLE_VI2(type) \
#define MAKE_UPSAMPLE_VI2(name,type) \
static void \
video_chroma_up_vi2_##type (GstVideoChromaResample *resample, \
video_chroma_up_vi2_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
gint i; \
@ -259,10 +260,20 @@ video_chroma_up_vi2_##type (GstVideoChromaResample *resample, \
* x x x x
* a b c d
*/
#define MAKE_DOWNSAMPLE_H2(type) \
#define MAKE_DOWNSAMPLE_H2_ORC(name,type) \
static void \
video_chroma_down_h2_##type (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
video_chroma_down_h2_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
\
video_orc_chroma_down_h2_##name (p, p, width / 2); \
}
#define MAKE_DOWNSAMPLE_H2(name,type) \
static void \
video_chroma_down_h2_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
gint i; \
@ -284,24 +295,17 @@ video_chroma_down_h2_##type (GstVideoChromaResample *resample, \
* O O O
* d x--x--x-
*/
#define MAKE_DOWNSAMPLE_V2(type) \
#define MAKE_DOWNSAMPLE_V2(name,type) \
static void \
video_chroma_down_v2_##type (GstVideoChromaResample *resample, \
video_chroma_down_v2_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
gint i; \
type *l0 = lines[0]; \
type *l1 = lines[1]; \
\
if (l0 != l1) { \
for (i = 0; i < width; i++) { \
type tr0 = PR0(i), tr1 = PR1(i); \
type tb0 = PB0(i), tb1 = PB1(i); \
if (l0 != l1) \
video_orc_chroma_down_v2_##name (l0, l0, l1, width); \
\
PR0(i) = FILT_1_1 (tr0, tr1); \
PB0(i) = FILT_1_1 (tb0, tb1); \
} \
} \
if (resample->h_resample) \
resample->h_resample (resample, l0, width); \
}
@ -316,9 +320,9 @@ video_chroma_down_v2_##type (GstVideoChromaResample *resample, \
* O O O <---
* d --------------x--x--x-
*/
#define MAKE_DOWNSAMPLE_VI2(type) \
#define MAKE_DOWNSAMPLE_VI2(name,type) \
static void \
video_chroma_down_vi2_##type (GstVideoChromaResample *resample, \
video_chroma_down_vi2_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -326,18 +330,18 @@ video_chroma_down_vi2_##type (GstVideoChromaResample *resample, \
resample->h_resample (resample, lines[0], width); \
}
MAKE_UPSAMPLE_H2 (guint16);
MAKE_UPSAMPLE_H2 (guint8);
MAKE_UPSAMPLE_V2 (guint16);
MAKE_UPSAMPLE_V2 (guint8);
MAKE_UPSAMPLE_VI2 (guint16);
MAKE_UPSAMPLE_VI2 (guint8);
MAKE_DOWNSAMPLE_H2 (guint16);
MAKE_DOWNSAMPLE_H2 (guint8);
MAKE_DOWNSAMPLE_V2 (guint16);
MAKE_DOWNSAMPLE_V2 (guint8);
MAKE_DOWNSAMPLE_VI2 (guint16);
MAKE_DOWNSAMPLE_VI2 (guint8);
MAKE_UPSAMPLE_H2 (u16, guint16);
MAKE_UPSAMPLE_H2 (u8, guint8);
MAKE_UPSAMPLE_V2 (u16, guint16);
MAKE_UPSAMPLE_V2 (u8, guint8);
MAKE_UPSAMPLE_VI2 (u16, guint16);
MAKE_UPSAMPLE_VI2 (u8, guint8);
MAKE_DOWNSAMPLE_H2 (u16, guint16);
MAKE_DOWNSAMPLE_H2_ORC (u8, guint8);
MAKE_DOWNSAMPLE_V2 (u16, guint16);
MAKE_DOWNSAMPLE_V2 (u8, guint8);
MAKE_DOWNSAMPLE_VI2 (u16, guint16);
MAKE_DOWNSAMPLE_VI2 (u8, guint8);
/* 4x horizontal upsampling without cositing
*
@ -350,9 +354,9 @@ MAKE_DOWNSAMPLE_VI2 (guint8);
* x x
* a b
*/
#define MAKE_UPSAMPLE_H4(type) \
#define MAKE_UPSAMPLE_H4(name,type) \
static void \
video_chroma_up_h4_##type (GstVideoChromaResample *resample, \
video_chroma_up_h4_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -390,9 +394,9 @@ video_chroma_up_h4_##type (GstVideoChromaResample *resample, \
* O--O--O-
* O--O--O-
*/
#define MAKE_UPSAMPLE_V4(type) \
#define MAKE_UPSAMPLE_V4(name,type) \
static void \
video_chroma_up_v4_##type (GstVideoChromaResample *resample, \
video_chroma_up_v4_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
gint i; \
@ -432,9 +436,9 @@ video_chroma_up_v4_##type (GstVideoChromaResample *resample, \
/* 4x vertical upsampling interlaced without cositing
*
*/
#define MAKE_UPSAMPLE_VI4(type) \
#define MAKE_UPSAMPLE_VI4(name,type) \
static void \
video_chroma_up_vi4_##type (GstVideoChromaResample *resample, \
video_chroma_up_vi4_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -452,9 +456,9 @@ video_chroma_up_vi4_##type (GstVideoChromaResample *resample, \
* x x x x x x x x
* a b c d e f g h
*/
#define MAKE_DOWNSAMPLE_H4(type) \
#define MAKE_DOWNSAMPLE_H4(name,type) \
static void \
video_chroma_down_h4_##type (GstVideoChromaResample *resample, \
video_chroma_down_h4_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -482,35 +486,27 @@ video_chroma_down_h4_##type (GstVideoChromaResample *resample, \
* g x--x--x-
* h x--x--x-
*/
#define MAKE_DOWNSAMPLE_V4(type) \
#define MAKE_DOWNSAMPLE_V4(name,type) \
static void \
video_chroma_down_v4_##type (GstVideoChromaResample *resample, \
video_chroma_down_v4_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
gint i; \
type *l0 = lines[0]; \
type *l1 = lines[1]; \
type *l2 = lines[2]; \
type *l3 = lines[3]; \
\
for (i = 0; i < width; i++) { \
type tr0 = PR0(i), tr1 = PR1(i); \
type tr2 = PR2(i), tr3 = PR3(i); \
type tb0 = PB0(i), tb1 = PB1(i); \
type tb2 = PB2(i), tb3 = PB3(i); \
video_orc_chroma_down_v4_##name(l0, l0, l1, l2, l3, width); \
\
PR0(i) = FILT_1_3_3_1 (tr0, tr1, tr2, tr3); \
PB0(i) = FILT_1_3_3_1 (tb0, tb1, tb2, tb3); \
} \
if (resample->h_resample) \
resample->h_resample (resample, l0, width); \
}
/* 4x vertical downsampling interlaced without cositing
*
*/
#define MAKE_DOWNSAMPLE_VI4(type) \
#define MAKE_DOWNSAMPLE_VI4(name,type) \
static void \
video_chroma_down_vi4_##type (GstVideoChromaResample *resample, \
video_chroma_down_vi4_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -519,18 +515,18 @@ video_chroma_down_vi4_##type (GstVideoChromaResample *resample, \
} \
}
MAKE_UPSAMPLE_H4 (guint16);
MAKE_UPSAMPLE_H4 (guint8);
MAKE_UPSAMPLE_V4 (guint16);
MAKE_UPSAMPLE_V4 (guint8);
MAKE_UPSAMPLE_VI4 (guint16);
MAKE_UPSAMPLE_VI4 (guint8);
MAKE_DOWNSAMPLE_H4 (guint16);
MAKE_DOWNSAMPLE_H4 (guint8);
MAKE_DOWNSAMPLE_V4 (guint16);
MAKE_DOWNSAMPLE_V4 (guint8);
MAKE_DOWNSAMPLE_VI4 (guint16);
MAKE_DOWNSAMPLE_VI4 (guint8);
MAKE_UPSAMPLE_H4 (u16, guint16);
MAKE_UPSAMPLE_H4 (u8, guint8);
MAKE_UPSAMPLE_V4 (u16, guint16);
MAKE_UPSAMPLE_V4 (u8, guint8);
MAKE_UPSAMPLE_VI4 (u16, guint16);
MAKE_UPSAMPLE_VI4 (u8, guint8);
MAKE_DOWNSAMPLE_H4 (u16, guint16);
MAKE_DOWNSAMPLE_H4 (u8, guint8);
MAKE_DOWNSAMPLE_V4 (u16, guint16);
MAKE_DOWNSAMPLE_V4 (u8, guint8);
MAKE_DOWNSAMPLE_VI4 (u16, guint16);
MAKE_DOWNSAMPLE_VI4 (u8, guint8);
/* 2x horizontal upsampling with cositing
*
@ -541,9 +537,9 @@ MAKE_DOWNSAMPLE_VI4 (guint8);
* x x
* a b
*/
#define MAKE_UPSAMPLE_H2_CS(type) \
#define MAKE_UPSAMPLE_H2_CS(name,type) \
static void \
video_chroma_up_h2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_h2_cs_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -561,9 +557,9 @@ video_chroma_up_h2_cs_##type (GstVideoChromaResample *resample, \
* b x O--O--O-
* O--O--O-
*/
#define MAKE_UPSAMPLE_V2_CS(type) \
#define MAKE_UPSAMPLE_V2_CS(name,type) \
static void \
video_chroma_up_v2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_v2_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -574,9 +570,9 @@ video_chroma_up_v2_cs_##type (GstVideoChromaResample *resample, \
/* 2x vertical upsampling interlaced with cositing
*
*/
#define MAKE_UPSAMPLE_VI2_CS(type) \
#define MAKE_UPSAMPLE_VI2_CS(name,type) \
static void \
video_chroma_up_vi2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_vi2_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -594,9 +590,9 @@ video_chroma_up_vi2_cs_##type (GstVideoChromaResample *resample, \
* x x x x x x
* a b c d e f
*/
#define MAKE_DOWNSAMPLE_H2_CS(type) \
#define MAKE_DOWNSAMPLE_H2_CS(name,type) \
static void \
video_chroma_down_h2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_h2_cs_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -626,9 +622,9 @@ video_chroma_down_h2_cs_##type (GstVideoChromaResample *resample, \
* e x O--O--O-
* f x --------
*/
#define MAKE_DOWNSAMPLE_V2_CS(type) \
#define MAKE_DOWNSAMPLE_V2_CS(name,type) \
static void \
video_chroma_down_v2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_v2_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -639,9 +635,9 @@ video_chroma_down_v2_cs_##type (GstVideoChromaResample *resample, \
/* 2x vertical downsampling interlaced with cositing
*
*/
#define MAKE_DOWNSAMPLE_VI2_CS(type) \
#define MAKE_DOWNSAMPLE_VI2_CS(name,type) \
static void \
video_chroma_down_vi2_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_vi2_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -650,18 +646,18 @@ video_chroma_down_vi2_cs_##type (GstVideoChromaResample *resample, \
} \
}
MAKE_UPSAMPLE_H2_CS (guint16);
MAKE_UPSAMPLE_H2_CS (guint8);
MAKE_UPSAMPLE_V2_CS (guint16);
MAKE_UPSAMPLE_V2_CS (guint8);
MAKE_UPSAMPLE_VI2_CS (guint16);
MAKE_UPSAMPLE_VI2_CS (guint8);
MAKE_DOWNSAMPLE_H2_CS (guint16);
MAKE_DOWNSAMPLE_H2_CS (guint8);
MAKE_DOWNSAMPLE_V2_CS (guint16);
MAKE_DOWNSAMPLE_V2_CS (guint8);
MAKE_DOWNSAMPLE_VI2_CS (guint16);
MAKE_DOWNSAMPLE_VI2_CS (guint8);
MAKE_UPSAMPLE_H2_CS (u16, guint16);
MAKE_UPSAMPLE_H2_CS (u8, guint8);
MAKE_UPSAMPLE_V2_CS (u16, guint16);
MAKE_UPSAMPLE_V2_CS (u8, guint8);
MAKE_UPSAMPLE_VI2_CS (u16, guint16);
MAKE_UPSAMPLE_VI2_CS (u8, guint8);
MAKE_DOWNSAMPLE_H2_CS (u16, guint16);
MAKE_DOWNSAMPLE_H2_CS (u8, guint8);
MAKE_DOWNSAMPLE_V2_CS (u16, guint16);
MAKE_DOWNSAMPLE_V2_CS (u8, guint8);
MAKE_DOWNSAMPLE_VI2_CS (u16, guint16);
MAKE_DOWNSAMPLE_VI2_CS (u8, guint8);
/* 4x horizontal upsampling with cositing
*
@ -673,9 +669,9 @@ MAKE_DOWNSAMPLE_VI2_CS (guint8);
* x x
* a b
*/
#define MAKE_UPSAMPLE_H4_CS(type) \
#define MAKE_UPSAMPLE_H4_CS(name,type) \
static void \
video_chroma_up_h4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_h4_cs_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -702,9 +698,9 @@ video_chroma_up_h4_cs_##type (GstVideoChromaResample *resample, \
* b x O--O--O-
* O--O--O-
*/
#define MAKE_UPSAMPLE_V4_CS(type) \
#define MAKE_UPSAMPLE_V4_CS(name,type) \
static void \
video_chroma_up_v4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_v4_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -715,9 +711,9 @@ video_chroma_up_v4_cs_##type (GstVideoChromaResample *resample, \
/* 4x vertical upsampling interlaced with cositing
*
*/
#define MAKE_UPSAMPLE_VI4_CS(type) \
#define MAKE_UPSAMPLE_VI4_CS(name,type) \
static void \
video_chroma_up_vi4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_up_vi4_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -734,9 +730,9 @@ video_chroma_up_vi4_cs_##type (GstVideoChromaResample *resample, \
* x x x x x x x x
* a b c d e f g h
*/
#define MAKE_DOWNSAMPLE_H4_CS(type) \
#define MAKE_DOWNSAMPLE_H4_CS(name,type) \
static void \
video_chroma_down_h4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_h4_cs_##name (GstVideoChromaResample *resample, \
gpointer pixels, gint width) \
{ \
type *p = pixels; \
@ -770,9 +766,9 @@ video_chroma_down_h4_cs_##type (GstVideoChromaResample *resample, \
* i x O--O--O-
* j x --------
*/
#define MAKE_DOWNSAMPLE_V4_CS(type) \
#define MAKE_DOWNSAMPLE_V4_CS(name,type) \
static void \
video_chroma_down_v4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_v4_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -783,9 +779,9 @@ video_chroma_down_v4_cs_##type (GstVideoChromaResample *resample, \
/* 4x vertical downsampling interlaced with cositing
*
*/
#define MAKE_DOWNSAMPLE_VI4_CS(type) \
#define MAKE_DOWNSAMPLE_VI4_CS(name,type) \
static void \
video_chroma_down_vi4_cs_##type (GstVideoChromaResample *resample, \
video_chroma_down_vi4_cs_##name (GstVideoChromaResample *resample, \
gpointer lines[], gint width) \
{ \
/* FIXME */ \
@ -794,18 +790,18 @@ video_chroma_down_vi4_cs_##type (GstVideoChromaResample *resample, \
} \
}
MAKE_UPSAMPLE_H4_CS (guint16);
MAKE_UPSAMPLE_H4_CS (guint8);
MAKE_UPSAMPLE_V4_CS (guint16);
MAKE_UPSAMPLE_V4_CS (guint8);
MAKE_UPSAMPLE_VI4_CS (guint16);
MAKE_UPSAMPLE_VI4_CS (guint8);
MAKE_DOWNSAMPLE_H4_CS (guint16);
MAKE_DOWNSAMPLE_H4_CS (guint8);
MAKE_DOWNSAMPLE_V4_CS (guint16);
MAKE_DOWNSAMPLE_V4_CS (guint8);
MAKE_DOWNSAMPLE_VI4_CS (guint16);
MAKE_DOWNSAMPLE_VI4_CS (guint8);
MAKE_UPSAMPLE_H4_CS (u16, guint16);
MAKE_UPSAMPLE_H4_CS (u8, guint8);
MAKE_UPSAMPLE_V4_CS (u16, guint16);
MAKE_UPSAMPLE_V4_CS (u8, guint8);
MAKE_UPSAMPLE_VI4_CS (u16, guint16);
MAKE_UPSAMPLE_VI4_CS (u8, guint8);
MAKE_DOWNSAMPLE_H4_CS (u16, guint16);
MAKE_DOWNSAMPLE_H4_CS (u8, guint8);
MAKE_DOWNSAMPLE_V4_CS (u16, guint16);
MAKE_DOWNSAMPLE_V4_CS (u8, guint8);
MAKE_DOWNSAMPLE_VI4_CS (u16, guint16);
MAKE_DOWNSAMPLE_VI4_CS (u8, guint8);
typedef struct
{
@ -815,22 +811,22 @@ typedef struct
static const HorizResampler h_resamplers[] = {
{NULL},
{video_chroma_up_h2_guint8},
{video_chroma_down_h2_guint8},
{video_chroma_up_h2_guint16},
{video_chroma_down_h2_guint16},
{video_chroma_up_h2_cs_guint8},
{video_chroma_down_h2_cs_guint8},
{video_chroma_up_h2_cs_guint16},
{video_chroma_down_h2_cs_guint16},
{video_chroma_up_h4_guint8},
{video_chroma_down_h4_guint8},
{video_chroma_up_h4_guint16},
{video_chroma_down_h4_guint16},
{video_chroma_up_h4_cs_guint8},
{video_chroma_down_h4_cs_guint8},
{video_chroma_up_h4_cs_guint16},
{video_chroma_down_h4_cs_guint16}
{video_chroma_up_h2_u8},
{video_chroma_down_h2_u8},
{video_chroma_up_h2_u16},
{video_chroma_down_h2_u16},
{video_chroma_up_h2_cs_u8},
{video_chroma_down_h2_cs_u8},
{video_chroma_up_h2_cs_u16},
{video_chroma_down_h2_cs_u16},
{video_chroma_up_h4_u8},
{video_chroma_down_h4_u8},
{video_chroma_up_h4_u16},
{video_chroma_down_h4_u16},
{video_chroma_up_h4_cs_u8},
{video_chroma_down_h4_cs_u8},
{video_chroma_up_h4_cs_u16},
{video_chroma_down_h4_cs_u16}
};
typedef struct
@ -851,42 +847,42 @@ video_chroma_none (GstVideoChromaResample * resample,
static const VertResampler v_resamplers[] = {
{video_chroma_none, 1, 0},
{video_chroma_up_v2_guint8, 2, -1},
{video_chroma_down_v2_guint8, 2, 0},
{video_chroma_up_v2_u8, 2, -1},
{video_chroma_down_v2_u8, 2, 0},
/* 16 bits */
{video_chroma_up_v2_guint16, 2, -1},
{video_chroma_down_v2_guint16, 2, 0},
{video_chroma_up_v2_u16, 2, -1},
{video_chroma_down_v2_u16, 2, 0},
/* cosited */
{video_chroma_up_v2_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v2_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v2_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v2_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v2_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v2_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v2_cs_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v2_cs_u16, 1, 0}, /* IMPLEMENT ME */
/* 4x */
{video_chroma_up_v4_guint8, 4, -2},
{video_chroma_down_v4_guint8, 4, 0},
{video_chroma_up_v4_guint16, 4, -2},
{video_chroma_down_v4_guint16, 4, 0},
{video_chroma_up_v4_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v4_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v4_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v4_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v4_u8, 4, -2},
{video_chroma_down_v4_u8, 4, 0},
{video_chroma_up_v4_u16, 4, -2},
{video_chroma_down_v4_u16, 4, 0},
{video_chroma_up_v4_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v4_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_v4_cs_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_v4_cs_u16, 1, 0}, /* IMPLEMENT ME */
/* interlaced */
{video_chroma_up_vi2_guint8, 4, -2},
{video_chroma_down_vi2_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_guint16, 4, -2},
{video_chroma_down_vi2_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi2_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi2_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_cs_guint8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_cs_guint16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_u8, 4, -2},
{video_chroma_down_vi2_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_u16, 4, -2},
{video_chroma_down_vi2_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi2_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi2_cs_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi2_cs_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_cs_u8, 1, 0}, /* IMPLEMENT ME */
{video_chroma_up_vi4_cs_u16, 1, 0}, /* IMPLEMENT ME */
{video_chroma_down_vi4_cs_u16, 1, 0}, /* IMPLEMENT ME */
};
/**
@ -931,6 +927,9 @@ gst_video_chroma_resample_new (GstVideoChromaMethod method,
h_index =
((ABS (h_factor) - 1) * 8) + (cosite ? 4 : 0) + (bits ==
16 ? 2 : 0) + (h_factor < 0 ? 1 : 0) + 1;
GST_DEBUG ("h_resample %d, factor %d, cosite %d", h_index, h_factor, cosite);
cosite = (site & GST_VIDEO_CHROMA_SITE_V_COSITED ? 1 : 0);
if (v_factor == 0)
v_index = 0;
@ -939,6 +938,8 @@ gst_video_chroma_resample_new (GstVideoChromaMethod method,
((ABS (v_factor) - 1) * 8) + (cosite ? 4 : 0) + (bits ==
16 ? 2 : 0) + (v_factor < 0 ? 1 : 0) + 1;
GST_DEBUG ("v_resample %d, factor %d, cosite %d", v_index, v_factor, cosite);
result = g_slice_new (GstVideoChromaResample);
result->method = method;
result->site = site;
@ -951,8 +952,8 @@ gst_video_chroma_resample_new (GstVideoChromaMethod method,
result->n_lines = v_resamplers[v_index].n_lines;
result->offset = v_resamplers[v_index].offset;
GST_DEBUG ("select resample %p %d, factor %d, "
"cosite %d, bits %d", result, h_index, h_factor, cosite, bits);
GST_DEBUG ("resample %p, bits %d, n_lines %u, offset %d", result, bits,
result->n_lines, result->offset);
return result;
}

View file

@ -1630,3 +1630,106 @@ mullw d, w1, t
convubw w1, s
mullw w1, w1, t
addw d, d, w1
.function video_orc_chroma_down_h2_u8
.source 8 s guint8
.dest 8 d guint8
.temp 4 ayuv1
.temp 4 ayuv2
.temp 2 ay1
.temp 2 uv1
.temp 2 uv2
splitql ayuv2, ayuv1, s
splitlw uv1, ay1, ayuv1
select1lw uv2, ayuv2
x2 avgub uv1, uv1, uv2
mergewl ayuv1, ay1, uv1
mergelq d, ayuv1, ayuv2
.function video_orc_chroma_down_v2_u8
.source 4 s1 guint8
.source 4 s2 guint8
.dest 4 d guint8
.temp 2 ay1
.temp 2 uv1
.temp 2 uv2
splitlw uv1, ay1, s1
select1lw uv2, s2
x2 avgub uv1, uv1, uv2
mergewl d, ay1, uv1
.function video_orc_chroma_down_v2_u16
.source 8 s1 guint16
.source 8 s2 guint16
.dest 8 d guint16
.temp 4 ay1
.temp 4 uv1
.temp 4 uv2
splitql uv1, ay1, s1
select1ql uv2, s2
x2 avguw uv1, uv1, uv2
mergelq d, ay1, uv1
.function video_orc_chroma_down_v4_u8
.source 4 s1 guint8
.source 4 s2 guint8
.source 4 s3 guint8
.source 4 s4 guint8
.dest 4 d guint8
.temp 2 ay1
.temp 2 uv1
.temp 4 uuvv1
.temp 4 uuvv2
.temp 4 uuvv3
splitlw uv1, ay1, s1
x2 convubw uuvv1, uv1
select1lw uv1, s4
x2 convubw uuvv2, uv1
x2 addw uuvv3, uuvv1, uuvv2
select1lw uv1, s2
x2 convubw uuvv1, uv1
select1lw uv1, s3
x2 convubw uuvv2, uv1
x2 addw uuvv1, uuvv1, uuvv2
x2 shlw uuvv2, uuvv1, 1
x2 addw uuvv1, uuvv1, uuvv2
x2 addw uuvv3, uuvv3, uuvv1
x2 addw uuvv3, uuvv3, 4
x2 shruw uuvv3, uuvv3, 3
x2 convwb uv1, uuvv3
mergewl d, ay1, uv1
.function video_orc_chroma_down_v4_u16
.source 8 s1 guint16
.source 8 s2 guint16
.source 8 s3 guint16
.source 8 s4 guint16
.dest 8 d guint16
.temp 4 ay1
.temp 4 uv1
.temp 8 uuvv1
.temp 8 uuvv2
.temp 8 uuvv3
splitql uv1, ay1, s1
x2 convuwl uuvv1, uv1
select1ql uv1, s4
x2 convuwl uuvv2, uv1
x2 addl uuvv3, uuvv1, uuvv2
select1ql uv1, s2
x2 convuwl uuvv1, uv1
select1ql uv1, s3
x2 convuwl uuvv2, uv1
x2 addl uuvv1, uuvv1, uuvv2
x2 shll uuvv2, uuvv1, 1
x2 addl uuvv1, uuvv1, uuvv2
x2 addl uuvv3, uuvv3, uuvv1
x2 addl uuvv3, uuvv3, 4
x2 shrul uuvv3, uuvv3, 3
x2 convlw uv1, uuvv3
mergelq d, ay1, uv1

View file

@ -1897,6 +1897,60 @@ GST_START_TEST (test_video_pack_unpack2)
}
GST_END_TEST;
#undef WIDTH
#undef HEIGHT
#undef TIME
#define WIDTH 1920
#define HEIGHT 1080
#define TIME 1.0
#define GET_LINE(l) (pixels + CLAMP (l, 0, HEIGHT-1) * WIDTH * 4)
GST_START_TEST (test_video_chroma)
{
guint8 *pixels;
GstVideoChromaResample *resample;
guint n_lines;
gint i, j, offset, count;
gpointer lines[2];
GTimer *timer;
gdouble elapsed, subsample_sec;
timer = g_timer_new ();
pixels = make_pixels (8, WIDTH, HEIGHT);
resample = gst_video_chroma_resample_new (GST_VIDEO_CHROMA_METHOD_LINEAR,
GST_VIDEO_CHROMA_SITE_NONE, GST_VIDEO_CHROMA_FLAG_NONE,
GST_VIDEO_FORMAT_AYUV, -1, -1);
gst_video_chroma_resample_get_info (resample, &n_lines, &offset);
fail_unless (n_lines == 2);
fail_unless (offset == 0);
count = 0;
g_timer_start (timer);
while (TRUE) {
for (i = 0; i < HEIGHT; i += n_lines) {
for (j = 0; j < n_lines; j++)
lines[j] = GET_LINE (i + offset + j);
gst_video_chroma_resample (resample, lines, WIDTH);
}
count++;
elapsed = g_timer_elapsed (timer, NULL);
if (elapsed >= TIME)
break;
}
subsample_sec = count / elapsed;
GST_DEBUG ("%f subsamples/sec", subsample_sec);
gst_video_chroma_resample_free (resample);
g_timer_destroy (timer);
}
GST_END_TEST;
#undef WIDTH
#undef HEIGHT
GST_START_TEST (test_video_scaler)
{
@ -1935,6 +1989,7 @@ video_suite (void)
tcase_add_test (tc_chain, test_overlay_composition_premultiplied_alpha);
tcase_add_test (tc_chain, test_overlay_composition_global_alpha);
tcase_add_test (tc_chain, test_video_pack_unpack2);
tcase_add_test (tc_chain, test_video_chroma);
tcase_add_test (tc_chain, test_video_scaler);
return s;