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 687964 - videocrop: Add NV12/NV21 support
videocrop: Add NV12/NV21 support
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.x
Other All
: Normal enhancement
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 687965
 
 
Reported: 2012-11-09 09:39 UTC by Nicolas Dufresne (ndufresne)
Modified: 2012-11-10 01:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
videocrop: Add NV12/NV21 support (3.85 KB, patch)
2012-11-09 09:39 UTC, Nicolas Dufresne (ndufresne)
needs-work Details | Review
videocrop: Add NV12/NV21 support (3.84 KB, patch)
2012-11-09 12:36 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Nicolas Dufresne (ndufresne) 2012-11-09 09:39:22 UTC
Videocrop does not support NV12/21 bi-planar format. There format are commonly
found on Android and iOS platforms.
Comment 1 Nicolas Dufresne (ndufresne) 2012-11-09 09:39:24 UTC
Created attachment 228528 [details] [review]
videocrop: Add NV12/NV21 support
Comment 2 Sebastian Dröge (slomo) 2012-11-09 10:42:04 UTC
Review of attachment 228528 [details] [review]:

::: gst/videocrop/gstvideocrop.c
@@ +392,3 @@
+  /* UV plane */
+  uv_in = y_in + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  uv_out = y_out + GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);

Use GST_VIDEO_FRAME_PLANE_DATA() here too. The components are always in order Y, U, V, A while what you want is the offset to the second plane (no matter if U or V is the first component in memory).

Also the Y and UV planes could be in different memory areas.

@@ +404,3 @@
+  }
+
+  uv_in += (vcrop->crop_top / 2) * GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 1);

Round down this one too maybe?

@@ +408,3 @@
+  dx = GST_ROUND_UP_2 (width);
+
+  for (i = 0; i < GST_ROUND_UP_2 (height) / 2; i++) {

Maybe put this round-divide calculation out of the loop

::: gst/videocrop/gstvideocrop.h
@@ +40,3 @@
   VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX,     /* UYVY, YVYU */
+  VIDEO_CROP_PIXEL_FORMAT_PLANAR,             /* I420, YV12 */
+  VIDEO_CROP_PIXEL_FORMAT_BIPLANAR            /* NV12, NV21 */

Maybe call this semi-planar instead... first read bipolar here ;)
Comment 3 Nicolas Dufresne (ndufresne) 2012-11-09 12:20:46 UTC
(In reply to comment #2)
> Review of attachment 228528 [details] [review]:
> 
> ::: gst/videocrop/gstvideocrop.c
> @@ +392,3 @@
> +  /* UV plane */
> +  uv_in = y_in + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
> +  uv_out = y_out + GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
> 
> Use GST_VIDEO_FRAME_PLANE_DATA() here too. The components are always in order
> Y, U, V, A while what you want is the offset to the second plane (no matter if
> U or V is the first component in memory).
> 
> Also the Y and UV planes could be in different memory areas.

Good point, this is a porting error.

> 
> @@ +404,3 @@
> +  }
> +
> +  uv_in += (vcrop->crop_top / 2) * GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 1);
> 
> Round down this one too maybe?

Dividing by two already round down, also you don't need (vcrop->crop_top / 2) to be even. Unless I don't understand what you mean ?

> 
> @@ +408,3 @@
> +  dx = GST_ROUND_UP_2 (width);
> +
> +  for (i = 0; i < GST_ROUND_UP_2 (height) / 2; i++) {
> 
> Maybe put this round-divide calculation out of the loop
> 
> ::: gst/videocrop/gstvideocrop.h
> @@ +40,3 @@
>    VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX,     /* UYVY, YVYU */
> +  VIDEO_CROP_PIXEL_FORMAT_PLANAR,             /* I420, YV12 */
> +  VIDEO_CROP_PIXEL_FORMAT_BIPLANAR            /* NV12, NV21 */
> 
> Maybe call this semi-planar instead... first read bipolar here ;)

Biplanar was from VLC doc I have read, but semi-planar seems more common. I'll change that.
Comment 4 Nicolas Dufresne (ndufresne) 2012-11-09 12:36:08 UTC
Created attachment 228559 [details] [review]
videocrop: Add NV12/NV21 support
Comment 5 Sebastian Dröge (slomo) 2012-11-09 14:25:11 UTC
Comment on attachment 228559 [details] [review]
videocrop: Add NV12/NV21 support

Looks good now, thanks :)
Comment 6 Olivier Crête 2012-11-10 01:39:40 UTC
commit e111068f7bd348c34082da2513f527185547e892
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Fri Nov 9 13:27:16 2012 +0100

    videocrop: Add NV12/NV21 support
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687964