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 737400 - videoscale: Lanczos resizing for NV image format
videoscale: Lanczos resizing for NV image format
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-09-26 05:03 UTC by RaviKiran
Modified: 2014-09-26 14:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lanczos method for NV format (21.69 KB, patch)
2014-09-26 05:06 UTC, RaviKiran
none Details | Review
lanczos method for NV formats (21.85 KB, patch)
2014-09-26 09:29 UTC, RaviKiran
committed Details | Review
fixes as suggested by Nicolas (6.99 KB, patch)
2014-09-26 14:03 UTC, Luis de Bethencourt
needs-work Details | Review
Declaring new variables in their own lines. (6.91 KB, patch)
2014-09-26 14:33 UTC, Luis de Bethencourt
committed Details | Review

Description RaviKiran 2014-09-26 05:03:37 UTC
Support lanczos scaling method for NV12 and NV21 image format.
Comment 1 RaviKiran 2014-09-26 05:06:55 UTC
Created attachment 287122 [details] [review]
lanczos method for NV format

Tested with same and different aspect-ratios and different submethods. It is working fine. Please review the patch
Comment 2 Luis de Bethencourt 2014-09-26 08:11:02 UTC
Hello Ravi,

In the commit message could you please have a description of what the patch does?
Commit messages are like so

"area: summary

longer description

url to bugzilla"

Could you provide me a link to the spec of NV12 and NV21 for some quick checking and testing?

Besides those two little things it looks good :)

Thanks
Comment 3 RaviKiran 2014-09-26 09:29:02 UTC
Created attachment 287133 [details] [review]
lanczos method for NV formats

I used following pipelines to check:
gst-launch-1.0 videotestsrc ! "video/x-raw,format={NV12}, width=320,height=240" ! videoscale method=lanczos ! "video/x-raw,format={NV12}, width=640,height=400" ! videoconvert ! ximagesink

gst-launch-1.0 videotestsrc ! "video/x-raw,format={NV21}, width=320,height=240" ! videoscale method=lanczos ! "video/x-raw,format={NV21}, width=640,height=480" ! videoconvert ! ximagesink

couple of references I came across-
http://www.fourcc.org/yuv.php#NV12
https://wiki.videolan.org/YUV/#Semi-planar
Comment 4 Luis de Bethencourt 2014-09-26 11:48:04 UTC
Testing and cleaning the commit lines that just add or remove empty lines.
Comment 5 Luis de Bethencourt 2014-09-26 12:13:08 UTC
Comment on attachment 287133 [details] [review]
lanczos method for NV formats

Merged. Great work.
Comment 6 Nicolas Dufresne (ndufresne) 2014-09-26 13:30:37 UTC
Review of attachment 287133 [details] [review]:

This is a lot of copy paste to my taste but seems to respect the existing code style. Ravi or Luis, could you please provide a patch to fix the review left over.

::: gst/videoscale/vs_lanczos.c
@@ +220,3 @@
+vs_image_scale_lanczos_NV_int16 (const VSImage * dest, const VSImage * src,
+    uint8_t * tmpbuf, double sharpness, gboolean dither, double a,
+    double sharpen);

Style: type and declaration should be on same line.

@@ +753,3 @@
+  const tap_type *tapsline; \
+  int offset; \
+  if (_shift > 0) offset = (1<<_shift)>>1; \

Style: Space before after operators

@@ +756,3 @@
+  else offset = 0; \
+  for (i = 0; i < n; i++) { \
+    srcline = src + 2*offsets[i]; \

Style: Space before after operators

@@ +765,3 @@
+    } \
+    dest[i*2+0] = (sum1 + offset) >> _shift; \
+    dest[i*2+1] = (sum2 + offset) >> _shift; \

I know this is copy pasted, but doing multiplication in index is far from ideal for performance. Aslo, you compute k*2 and i*2 twice. (Note, k * 2 == k << 1). There is also style issues with operators missing space in between.

@@ +898,2 @@
   } \
 }

Normally we try and split the unrelated style fix from our patches.
Comment 7 Tim-Philipp Müller 2014-09-26 13:47:01 UTC
Code should be written primarily for clarity. The compiler will optimise i*2 to a bitshift (hopefully), and it can also avoid double computation of i*2 if that makes sense, and we can let the compiler decide that IMHO.
Comment 8 Luis de Bethencourt 2014-09-26 14:03:59 UTC
Created attachment 287159 [details] [review]
fixes as suggested by Nicolas

Thanks Nicolas. They are good suggestions.

Should I split the style changes into a second patch or have it all in this one? Currently it includes the fixes to avoid recalculating the same value multiple times.

Like so:
-      sum1 += srcline[k*4+0] * tapsline[k]; \
-      sum2 += srcline[k*4+1] * tapsline[k]; \
-      sum3 += srcline[k*4+2] * tapsline[k]; \
-      sum4 += srcline[k*4+3] * tapsline[k]; \
+      l = k * 4; \
+      sum1 += srcline[l] * tapsline[k]; \
+      sum2 += srcline[l + 1] * tapsline[k]; \
+      sum3 += srcline[l + 2] * tapsline[k]; \
+      sum4 += srcline[l + 3] * tapsline[k]; \

And also a few style fixes.
Comment 9 Nicolas Dufresne (ndufresne) 2014-09-26 14:26:16 UTC
As Tim mention, we can hope that the compiler will optimize the recalculation (I've hit cases where the compiler was not doing so, so I'm careful in color transformation code these days), but I'd really like to see a patch for the style.
Comment 10 Nicolas Dufresne (ndufresne) 2014-09-26 14:27:35 UTC
Review of attachment 287159 [details] [review]:

::: gst/videoscale/vs_lanczos.c
@@ +710,3 @@
 { \
+  int i, j; \
+  int k, l; \

I agree with Tim the this affects the readability a bit.
Comment 11 Luis de Bethencourt 2014-09-26 14:33:21 UTC
Created attachment 287161 [details] [review]
Declaring new variables in their own lines.
Comment 12 Nicolas Dufresne (ndufresne) 2014-09-26 14:34:41 UTC
Review of attachment 287161 [details] [review]:

Ok, let's take this one.
Comment 13 Luis de Bethencourt 2014-09-26 14:38:24 UTC
Comment on attachment 287161 [details] [review]
Declaring new variables in their own lines.

Merged