diff options
author | Wim Taymans <wtaymans@redhat.com> | 2014-11-06 16:18:25 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-11-06 16:26:24 +0100 |
commit | d35c5fd75c64b50bb8e194893864a708a00c8565 (patch) | |
tree | fd56f3b2911c8f81f722558b20d0b3034a27f05c /gst-libs | |
parent | da6f66e5507348675752743a12049de5fe462111 (diff) | |
download | gstreamer-plugins-base-d35c5fd75c64b50bb8e194893864a708a00c8565.tar.gz |
video-converter: ORCify 8<->16 conversion
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/video/video-converter.c | 61 | ||||
-rw-r--r-- | gst-libs/gst/video/video-orc.orc | 12 |
2 files changed, 38 insertions, 35 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c index 05bf0c73b..9b12f0ba7 100644 --- a/gst-libs/gst/video/video-converter.c +++ b/gst-libs/gst/video/video-converter.c @@ -389,7 +389,10 @@ chain_convert (GstVideoConverter * convert, GstLineCache * prev) GST_DEBUG ("chain convert"); prev = convert->convert_lines = gst_line_cache_new (prev); prev->write_input = TRUE; - prev->pass_alloc = TRUE; + if (convert->in_bits != convert->out_bits) + prev->pass_alloc = FALSE; + else + prev->pass_alloc = TRUE; gst_line_cache_set_need_line_func (convert->convert_lines, do_convert_lines, convert, NULL); } @@ -1327,30 +1330,6 @@ video_converter_compute_resample (GstVideoConverter * convert) convert->down_n_lines); } -#define TO_16(x) (((x)<<8) | (x)) - -static void -convert_to16 (gpointer line, gint width) -{ - guint8 *line8 = line; - guint16 *line16 = line; - gint i; - - for (i = (width - 1) * 4; i >= 0; i--) - line16[i] = TO_16 (line8[i]); -} - -static void -convert_to8 (gpointer line, gint width) -{ - guint8 *line8 = line; - guint16 *line16 = line; - gint i; - - for (i = 0; i < width * 4; i++) - line8[i] = line16[i] >> 8; -} - #define FRAME_GET_PLANE_STRIDE(frame, plane) \ GST_VIDEO_FRAME_PLANE_STRIDE (frame, plane) #define FRAME_GET_PLANE_LINE(frame, plane, line) \ @@ -1516,35 +1495,47 @@ do_convert_lines (GstLineCache * cache, gint out_line, gint in_line, gpointer user_data) { GstVideoConverter *convert = user_data; - gpointer *lines; + gpointer *lines, destline; guint in_bits, out_bits; gint width; lines = gst_line_cache_get_lines (cache->prev, out_line, in_line, 1); + destline = lines[0]; + in_bits = convert->in_bits; out_bits = convert->out_bits; width = MIN (convert->in_width, convert->out_width); - GST_DEBUG ("convert line %d", in_line); if (out_bits == 16 || in_bits == 16) { + gpointer srcline = lines[0]; + + if (out_bits != in_bits) + destline = gst_line_cache_alloc_line (cache, out_line); + /* FIXME, we can scale in the conversion matrix */ - if (in_bits == 8) - convert_to16 (lines[0], width); + if (in_bits == 8) { + GST_DEBUG ("8->16 line %d", in_line); + video_orc_convert_u8_to_u16 (destline, srcline, width * 4); + srcline = destline; + } if (convert->matrix) - convert->matrix (convert, lines[0]); + convert->matrix (convert, srcline); if (convert->dither16) - convert->dither16 (convert, lines[0], in_line); + convert->dither16 (convert, srcline, in_line); - if (out_bits == 8) - convert_to8 (lines[0], width); + if (out_bits == 8) { + GST_DEBUG ("16->8 line %d", in_line); + video_orc_convert_u16_to_u8 (destline, srcline, width * 4); + } } else { + GST_DEBUG ("convert line %d", in_line); if (convert->matrix) - convert->matrix (convert, lines[0]); + convert->matrix (convert, destline); } - gst_line_cache_add_line (cache, in_line, lines[0]); + gst_line_cache_add_line (cache, in_line, destline); return TRUE; } diff --git a/gst-libs/gst/video/video-orc.orc b/gst-libs/gst/video/video-orc.orc index 302231c5f..cf6c2bd5a 100644 --- a/gst-libs/gst/video/video-orc.orc +++ b/gst-libs/gst/video/video-orc.orc @@ -530,6 +530,18 @@ addb d1, t, a copyb d1, s1 +.function video_orc_convert_u16_to_u8 +.source 2 s guint16 +.dest 1 d guint8 + +convhwb d, s + +.function video_orc_convert_u8_to_u16 +.source 1 s guint8 +.dest 2 d guint16 + +mergebw d, s, s + .function video_orc_convert_I420_UYVY .dest 4 d1 guint8 .dest 4 d2 guint8 |