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 743186 - v4l2object: set colorspace in caps for capture devices
v4l2object: set colorspace in caps for capture devices
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-19 15:28 UTC by Aurélien Zanelli
Modified: 2015-02-25 19:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
v4l2object: set colorspace in caps for capture devices (3.88 KB, patch)
2015-01-19 15:30 UTC, Aurélien Zanelli
needs-work Details | Review
v4l2object: set colorspace in caps for capture devices (3.83 KB, patch)
2015-01-20 08:46 UTC, Aurélien Zanelli
committed Details | Review

Description Aurélien Zanelli 2015-01-19 15:28:39 UTC
Currently, when using a v4l2src, we don't set the colorspace information in the pipeline caps. Since this information is set by the driver for a capture device, it could be interesting to forward it in caps using our colorimetry structure.
Comment 1 Aurélien Zanelli 2015-01-19 15:30:41 UTC
Created attachment 294894 [details] [review]
v4l2object: set colorspace in caps for capture devices

Proposal patch to retrieve the colorspace information and to set it in caps.
Comment 2 Nicolas Dufresne (ndufresne) 2015-01-19 16:17:50 UTC
Review of attachment 294894 [details] [review]:

Few comments, the last one is mostly a reflection, but I'm not 100% sure it matter.

::: sys/v4l2/gstv4l2object.c
@@ +1675,3 @@
+      break;
+    default:
+      GST_ERROR ("Unknown enum v4l2_colorspace %d", colorspace);

I think some driver don't support it, hence will set 0. I think we should handle that case without spamming the logs. I already have two spammer to fix  now ;-P Also, see the guessing code we do in the opposite direction.

@@ +1791,3 @@
+    fmt.fmt.pix.height = height;
+    fmt.fmt.pix.pixelformat = pixelformat;
+  }

The if case is not needed, this part of the structure is that same for mplane.

@@ +2308,3 @@
         pixelformat);
     gst_v4l2_object_add_aspect_ratio (v4l2object, tmp);
+    gst_v4l2_object_add_colorspace (v4l2object, tmp, max_w, max_h, pixelformat);

I think this is a case where just checking the max may really lead to wrong result. We probably want to check min and max, if if different, put both in the caps.
Comment 3 Aurélien Zanelli 2015-01-19 17:02:09 UTC
(In reply to comment #2)
> Review of attachment 294894 [details] [review]:
> 
> Few comments, the last one is mostly a reflection, but I'm not 100% sure it
> matter.
> 
> ::: sys/v4l2/gstv4l2object.c
> @@ +1675,3 @@
> +      break;
> +    default:
> +      GST_ERROR ("Unknown enum v4l2_colorspace %d", colorspace);
> 
> I think some driver don't support it, hence will set 0. I think we should
> handle that case without spamming the logs. I already have two spammer to fix 
> now ;-P Also, see the guessing code we do in the opposite direction.

If the driver doesn't set the colorspace, I think we can just leave the caps with no colorimetry since the guess could be really wrong and we could live without colorimetry. 
In the opposite direction, we guess the colorspace as a last resort because the application must set it according to the spec.

However, I agree with the fact that I'm maybe too aggressive with an error :) for a thing we can live without.
So what do you think of a warning or debug message instead (warning will also spam)

> 
> @@ +1791,3 @@
> +    fmt.fmt.pix.height = height;
> +    fmt.fmt.pix.pixelformat = pixelformat;
> +  }
> 
> The if case is not needed, this part of the structure is that same for mplane.
Agreed, I will merge it.

> 
> @@ +2308,3 @@
>          pixelformat);
>      gst_v4l2_object_add_aspect_ratio (v4l2object, tmp);
> +    gst_v4l2_object_add_colorspace (v4l2object, tmp, max_w, max_h,
> pixelformat);
> 
> I think this is a case where just checking the max may really lead to wrong
> result. We probably want to check min and max, if if different, put both in the
> caps.

Not a bad reflection, I don't know if the size matter or not, it could depend of the driver I think. But in this case we would know for sure the colorspace when the format is negotiatied, ie after final S_FMT.
I think if some drivers do this, checking min and max could not be enough. For instance, I think of a device which can output SD with associated colorspace smtpe170m, HD in rec709 and UHD in bt2020.
Comment 4 Nicolas Dufresne (ndufresne) 2015-01-19 17:58:46 UTC
(In reply to comment #3)
> (In reply to comment #2)
> However, I agree with the fact that I'm maybe too aggressive with an error :)
> for a thing we can live without.
> So what do you think of a warning or debug message instead (warning will also
> spam)

I would opt of debug message and no colorimetry field in the caps seems fine to me.


> > 
> > @@ +2308,3 @@
> >          pixelformat);
> >      gst_v4l2_object_add_aspect_ratio (v4l2object, tmp);
> > +    gst_v4l2_object_add_colorspace (v4l2object, tmp, max_w, max_h,
> > pixelformat);
> > 
> > I think this is a case where just checking the max may really lead to wrong
> > result. We probably want to check min and max, if if different, put both in the
> > caps.
> 
> Not a bad reflection, I don't know if the size matter or not, it could depend
> of the driver I think. But in this case we would know for sure the colorspace
> when the format is negotiatied, ie after final S_FMT.
> I think if some drivers do this, checking min and max could not be enough. For
> instance, I think of a device which can output SD with associated colorspace
> smtpe170m, HD in rec709 and UHD in bt2020.

Fair, maybe we can leave it this way for now and add a comment. There is an evident solution in the driver, which is to implement enumeration.
Comment 5 Aurélien Zanelli 2015-01-20 08:46:06 UTC
Created attachment 294959 [details] [review]
v4l2object: set colorspace in caps for capture devices

- demote GST_ERROR to GST_DEBUG to avoid errors spamming.
- add a comment about getting the fact that getting colorspace for maximum frame size could be wrong in case device colorspace depends on size (if possible).
Comment 6 Nicolas Dufresne (ndufresne) 2015-02-25 19:49:27 UTC
Review of attachment 294959 [details] [review]:

commit 7a1613b9e15ab3e437c56b4de7bc15a30ea4f619
Author: Aurélien Zanelli <aurelien.zanelli@parrot.com>
Date:   Mon Jan 19 15:29:24 2015 +0100

    v4l2object: set colorspace in caps for capture devices
    
    This information is set by the driver for a capture device, and so could
    be forwarded to pipeline by setting the colorimetry in caps.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743186