After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761851 - video: add orc UYVY422 to GRAY8 conversion function
video: add orc UYVY422 to GRAY8 conversion function
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other Linux
: Normal enhancement
: 1.7.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-11 09:02 UTC by Göran Jönsson
Modified: 2016-02-27 01:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst-plugins-base patch (1.23 MB, patch)
2016-02-11 09:02 UTC, Göran Jönsson
none Details | Review
new gst-plugins-base patch (20.81 KB, patch)
2016-02-11 10:11 UTC, Göran Jönsson
none Details | Review
new gst-plugins-base patch (2.20 KB, patch)
2016-02-11 10:36 UTC, Göran Jönsson
none Details | Review
new gst-plugins-base patch (2.24 KB, patch)
2016-02-26 08:47 UTC, Göran Jönsson
committed Details | Review

Description Göran Jönsson 2016-02-11 09:02:14 UTC
Created attachment 320855 [details] [review]
gst-plugins-base patch

This is the same as in ticket 569655 but now for video-converter.

!!Obs
I put in this little change in gst-plugins-base/gst-libs/gst/video/video-orc.orc

.function video_orc_convert_UYVY_GRAY8
.flags 2d
.dest 1 d guint8
.source 1 s guint8

ldresnearb d, s, 0x10000, 0x20000

Then I do 
orcc --implementation video-orc.orc -o video-orc-dist.c
orcc --implementation video-orc.orc -o tmp-orc.c
orcc --header video-orc.orc -o video-orc-dist.h
orcc --header video-orc.orc -o video-orc.h

I use orc that I clone some days ago.
commit e0d39f67ca8c22af3923ed886a313c0052708f8f
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Wed Dec 30 20:52:58 2015 +0200
,,,,

This causes that all the files
video-orc-dist.c
tmp-orc.c
video-orc-dist.h
video-orc.h

Loses the line 
#include <glib.h>

So this causes build errors when building gst-plugins-base with make.
( I added the include again as seen in attached patch )
Also massive (1000:s of lines ) code changes in video-orc-dist.c take place as you can see in patch.

I suppose I have done something wrong but I don't know what can you tell me what I do wrong ?
My guess is I using wrong version of orc or I should use some options to orcc.

Regards
Göran Jönsson
Comment 1 Tim-Philipp Müller 2016-02-11 09:19:00 UTC
Try 'make orc-update' in gst-libs/gst/video/ after your changes.
Comment 2 Göran Jönsson 2016-02-11 10:11:06 UTC
Created attachment 320859 [details] [review]
new gst-plugins-base patch

The problem with the #include disappear, but there are still format changes in
video-orc-dist.c but not so many as before.
Comment 3 Göran Jönsson 2016-02-11 10:36:03 UTC
Created attachment 320863 [details] [review]
new gst-plugins-base patch

New patch without video-orc-dist.c and video-orc-dist.h
Comment 4 Tim-Philipp Müller 2016-02-11 11:10:06 UTC
Comment on attachment 320863 [details] [review]
new gst-plugins-base patch

>+.function video_orc_convert_UYVY_GRAY8
>+.flags 2d
>+.dest 1 d guint8
>+.source 1 s guint8
>+
>+ldresnearb d, s, 0x10000, 0x20000

Could you explain how that works?

Does that actually work for you?

What's the output of:

ORC_DEBUG=2 gst-launch-1.0 videotestsrc num-buffers=1 pattern=red ! video/x-raw,format=UYVY,width=4,height=4 ! videoconvert ! video/x-raw,format=GRAY8 ! fakesink dump=true
Comment 5 Göran Jönsson 2016-02-12 06:15:34 UTC
>+.function video_orc_convert_UYVY_GRAY8
>+.flags 2d
>+.dest 1 d guint8
>+.source 1 s guint8
>+
>+ldresnearb d, s, 0x10000, 0x20000

Generates

+#ifdef DISABLE_ORC
+void
+video_orc_convert_UYVY_GRAY8 (guint8 * ORC_RESTRICT d1, int d1_stride,
+    const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m)
+{
+  int i;
+  int j;
+  orc_int8 *ORC_RESTRICT ptr0;
+  const orc_int8 *ORC_RESTRICT ptr4;
+  orc_int8 var32;
+
+  for (j = 0; j < m; j++) {
+    ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j);
+    ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j);
+
+
+    for (i = 0; i < n; i++) {
+      /* 0: ldresnearb */
+      var32 = ptr4[(65536 + i * 131072) >> 16];
+      /* 1: storeb */
+      ptr0[i] = var32;
+    }
+  }
+
+}

If look at 
var32 = ptr4[(65536 + i * 131072) >> 16]; 

=> var32 = ptr4[(0x10000 + i * 0x20000) >> 16];
=> var32 = ptr4[(0x10000 + i * 0x20000)/ 0x10000];
=> var32 = ptr4[(1 + i * 2)];
Comment 6 Tim-Philipp Müller 2016-02-12 13:06:56 UTC
Surely there are easier ways to do this without the ldresnearb op?
Comment 7 Göran Jönsson 2016-02-15 06:10:34 UTC
Do it all in one instruction is easy I will say, but the last word will be yours of course. Do you want me to implement something different ? Or maybe I should commented it for better readability ? 

When I run 
ORC_DEBUG=2 installation/bin/gst-launch-1.0 videotestsrc num-buffers=1 pattern=red ! video/x-raw,format=UYVY,width=4,height=4 ! videoconvert ! video/x-raw,format=GRAY8 ! fakesink dump=true

I got 
ORC: WARNING: orccompiler.c(392): orc_program_compile_full(): program video_orc_convert_UYVY_GRAY8 failed to compile, reason: no code generation rule for ldresnearb on target sse
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
00000000 (0x190e8b0): 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51  QQQQQQQQQQQQQQQQ
Got EOS from element "pipeline0".
Execution ended after 0:00:00.000071883
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Maybe the print 
ORC: WARNING: orccompiler.c(392): orc_program_compile_full(): program video_orc_convert_UYVY_GRAY8 failed to compile, reason: no code generation rule for ldresnearb on target sse

gives another reason for not using ldresnearb ?
Comment 8 Tim-Philipp Müller 2016-02-15 09:13:57 UTC
I think it would be better to implement it differently, seeing that ldresnearb is not implemented for any backend currently.
Comment 9 Göran Jönsson 2016-02-23 12:21:06 UTC
I tryed this code but it will not compile

.function video_orc_convert_UYVY_GRAY8
.flags 2d
.dest 1 d guint8
.source 1 s guint8
.accumulator 4 a glong
.temp 1 t1

accl   a,1
loadoffb t1, s, a
storeb   d,t1
accl     a,1

output when compile,

Failed to compile no orc for 'video_orc_convert_UYVY_GRAY8'
Failed to compile backup code for 'video_orc_convert_UYVY_GRAY8'
Comment 10 Göran Jönsson 2016-02-23 13:38:52 UTC
.function video_orc_convert_UYVY_GRAY8
.flags 2d
.dest 1 d guint8
.source 1 s guint8
.accumulator 4 a glong
.temp 1 t1

accl   a,1
loadoffb t1, s, a
storeb   d,t1

output when compile,

Failed to compile no orc for 'video_orc_convert_UYVY_GRAY8'
Failed to compile backup code for 'video_orc_convert_UYVY_GRAY8'
Comment 11 Göran Jönsson 2016-02-24 10:43:11 UTC
Skip that I have another idea.
Comment 12 Göran Jönsson 2016-02-26 08:47:42 UTC
Created attachment 322441 [details] [review]
new gst-plugins-base patch

New patch for review.
Comment 13 Tim-Philipp Müller 2016-02-27 01:17:21 UTC
commit b424712644363288405c911d22b5d028d174db23
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sat Feb 27 00:11:02 2016 +0000

    video: update disted orc backup file
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761851

commit babcf4d30cf84f9f2c849ae309932e136ba37e4c
Author: Göran Jönsson <goranjn@axis.com>
Date:   Thu Feb 11 11:27:57 2016 +0100

    video-converter: add direct UYVY to GRAY8 conversion function
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761851