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 736252 - gdkpixbufdec: packetized mode logic
gdkpixbufdec: packetized mode logic
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Linux
: Normal blocker
: 1.8.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-09-08 05:28 UTC by Vineeth
Modified: 2016-06-08 06:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch for pngdec (1.10 KB, patch)
2014-09-12 04:00 UTC, Vineeth
needs-work Details | Review
patch for jpegdec (1.16 KB, patch)
2014-09-12 04:00 UTC, Vineeth
needs-work Details | Review
patch for webpdec (1.10 KB, patch)
2014-09-12 04:01 UTC, Vineeth
needs-work Details | Review
Modified as per input segement format (1.17 KB, patch)
2014-09-13 04:41 UTC, Vineeth
needs-work Details | Review
modified as per input segment format (1.16 KB, patch)
2014-09-16 07:58 UTC, Vineeth
committed Details | Review
modified as per input segment format (1.33 KB, patch)
2014-09-16 07:59 UTC, Vineeth
committed Details | Review
modified as per input segment format (1.28 KB, patch)
2014-09-16 07:59 UTC, Vineeth
committed Details | Review
modified as per input segment format (1.16 KB, patch)
2014-09-16 08:00 UTC, Vineeth
committed Details | Review
gdkpixbufdec packetized logic (3.34 KB, patch)
2014-09-16 11:19 UTC, Vineeth
committed Details | Review
jpegdec: Wait for segment event before checking it (2.79 KB, patch)
2016-06-06 21:04 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
pngdec: Wait for segment event before checking it (2.72 KB, patch)
2016-06-08 00:55 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
vmncdec: Wait for segment event before checking it (2.87 KB, patch)
2016-06-08 01:05 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
webpdec: Wait for segment event before checking it (2.95 KB, patch)
2016-06-08 01:38 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Vineeth 2014-09-08 05:28:27 UTC
To check packetized mode the logic being used is 

  /* packetised mode? *//* FIXME: shouln't this be fps_d != 0, since 0/1
   * might be packetised mode but variable framerate */
  if (filter->in_fps_n != 0) {

I guess the logic is correct, since if numerator is 0, it will be considered as a single image. In that case FIXME should be removed right?

And i am getting confused, with the logic used in pngdec element

  if (GST_VIDEO_INFO_FPS_N (info) != 1 && GST_VIDEO_INFO_FPS_D (info) != 1)
    gst_video_decoder_set_packetized (decoder, TRUE);

Isn't this wrong? 1/1 framerate is also packetized mode right?
Shouldn't the condition be, to check for numerator != 0, similar to gdkpixbufdec?

  if (GST_VIDEO_INFO_FPS_N (info) != 0 && GST_VIDEO_INFO_FPS_D (info) != 1)
    gst_video_decoder_set_packetized (decoder, TRUE);
Comment 1 Thiago Sousa Santos 2014-09-11 18:15:47 UTC
(In reply to comment #0)
> To check packetized mode the logic being used is 
> 
>   /* packetised mode? *//* FIXME: shouln't this be fps_d != 0, since 0/1
>    * might be packetised mode but variable framerate */
>   if (filter->in_fps_n != 0) {
> 
> I guess the logic is correct, since if numerator is 0, it will be considered as
> a single image. In that case FIXME should be removed right?

I'd leave the FIXME there, there doesn't seem to be a consensus on how to detect packetized input atm. Well, one could use the parsed boolean in caps but I guess this isn't everywhere yet.

> 
> And i am getting confused, with the logic used in pngdec element
> 
>   if (GST_VIDEO_INFO_FPS_N (info) != 1 && GST_VIDEO_INFO_FPS_D (info) != 1)
>     gst_video_decoder_set_packetized (decoder, TRUE);
> 
> Isn't this wrong? 1/1 framerate is also packetized mode right?
> Shouldn't the condition be, to check for numerator != 0, similar to
> gdkpixbufdec?

Yes, this is wrong. Can you provide a fix? I'd keep the FPS_D != 1 check as this is comparing against the default value of 0/1, meaning that no framerate was provided in caps (likely).

> 
>   if (GST_VIDEO_INFO_FPS_N (info) != 0 && GST_VIDEO_INFO_FPS_D (info) != 1)
>     gst_video_decoder_set_packetized (decoder, TRUE);
Comment 2 Vineeth 2014-09-12 04:00:19 UTC
Created attachment 285979 [details] [review]
patch for pngdec
Comment 3 Vineeth 2014-09-12 04:00:45 UTC
Created attachment 285980 [details] [review]
patch for jpegdec
Comment 4 Vineeth 2014-09-12 04:01:15 UTC
Created attachment 285981 [details] [review]
patch for webpdec
Comment 5 Sebastian Dröge (slomo) 2014-09-12 13:37:42 UTC
0/1 is variable framerate, so this also doesn't make sense. To fix this properly we should add packetized/parsed fields to the caps everywhere. This would be a backwards compatible change as without the field the only effect would be that the decoders parse data that is already parsed.
Comment 6 Tim-Philipp Müller 2014-09-12 13:44:06 UTC
For all these formats you can probably assume that if the input segment is in TIME that it's packetised, and if it's in BYTES, then it's not packetised, no?
Comment 7 Sebastian Dröge (slomo) 2014-09-12 13:45:09 UTC
Good point, that should work
Comment 8 Vineeth 2014-09-13 04:41:51 UTC
Created attachment 286100 [details] [review]
Modified as per input segement format

Hi,
Thanks for the review.
I have modified pngdec as per the input segment format.
Please review if this is proper, so that i can apply to other decoders.


Regards,
Vineeth
Comment 9 Sebastian Dröge (slomo) 2014-09-16 07:27:47 UTC
Comment on attachment 286100 [details] [review]
Modified as per input segement format

Seems correct, thanks! Please update the other patches too :)

Also please fix your name and mail address in GIT and recreate this patch then.
Comment 10 Vineeth 2014-09-16 07:58:48 UTC
Created attachment 286263 [details] [review]
modified as per input segment format
Comment 11 Vineeth 2014-09-16 07:59:12 UTC
Created attachment 286264 [details] [review]
modified as per input segment format
Comment 12 Vineeth 2014-09-16 07:59:45 UTC
Created attachment 286265 [details] [review]
modified as per input segment format
Comment 13 Vineeth 2014-09-16 08:00:12 UTC
Created attachment 286266 [details] [review]
modified as per input segment format
Comment 14 Vineeth 2014-09-16 08:02:01 UTC
Made the changes for all decoders.

But the same cannot be applied to gdkpixbufdec right?

should we rewrite gdkpixbufdec by using VideoDecoder base class instead of GstElement?
Comment 15 Sebastian Dröge (slomo) 2014-09-16 08:23:50 UTC
(In reply to comment #14)
> Made the changes for all decoders.
> 
> But the same cannot be applied to gdkpixbufdec right?

Why not? It can also do that logic based on the input segment format

> should we rewrite gdkpixbufdec by using VideoDecoder base class instead of
> GstElement?

Yes, that would be good :)
Comment 16 Vineeth 2014-09-16 08:35:05 UTC
Thanks for the review.
sorry about the mistake in jpegdec :)


i will raise a new bug for gdkpixbufdec porting to VideoDecoder base class
Comment 17 Sebastian Dröge (slomo) 2014-09-16 08:43:45 UTC
Porting gdkpixbufdec to the base class is independent of fixing this though. You can just check the segment format as with the others :)
Comment 18 Vineeth 2014-09-16 11:19:48 UTC
Created attachment 286283 [details] [review]
gdkpixbufdec packetized logic

Please review the changes for modifying packetized mode logic in gdkpixbufdec
Comment 19 Sebastian Dröge (slomo) 2014-09-16 11:51:30 UTC
commit 89b9313e200b8de8d34241a1119340af84f518c1
Author: Vineeth T M <vineeth.tm@samsung.com>
Date:   Tue Sep 16 16:46:07 2014 +0530

    gdkpixbufdec: modify wrong packetized mode logic
    
    packetized mode is being set when framerate is being set
    which is not correct. Changing the same by checking the
    input segement format. If input segment is in TIME it is
    Packetized, and if it is in BYTES it is not.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736252
Comment 20 Nicolas Dufresne (ndufresne) 2016-06-06 20:44:42 UTC
All those patches are wrong, because the CAPS arrives before the segment. The test dec->input_segment.format will always be undefined until you re-negotiate. Combine with the poor quality of the parser (which call memory_map/unmap multiple time for the same buffer), this cause a massive performance regression with v4l2src/dmabuf jpegs.
Comment 21 Nicolas Dufresne (ndufresne) 2016-06-06 21:04:39 UTC
Created attachment 329230 [details] [review]
jpegdec: Wait for segment event before checking it

The heuristic to choose between packetise or not was change to use the
segment format. The problem is that this change is reading the segment
during the caps event handling. The segment event will only be sent
after. That prevented the decoder to go in packetize mode, and avoid
useless parsing.
Comment 22 Nicolas Dufresne (ndufresne) 2016-06-06 21:06:59 UTC
We need to fix for all the others now (should be copy paste exercise).
Comment 23 Sebastian Dröge (slomo) 2016-06-07 06:15:51 UTC
Nicolas, are you also doing the others? Should get this into 1.8.2 really :) Thanks for spotting this (how did you?)
Comment 24 Nicolas Dufresne (ndufresne) 2016-06-07 13:57:26 UTC
Yes, I'll do that today. I notice a huge performance regression with:

  v4l2src io-mode=dmabuf ! jpegdec ! fakesink

It was caused by the parser in there being badly implemented. For each buffer, it will map/unmap hundreds of time (through calling the scan function), which endup using a full CPU (since map/unmap in this case actually map the dmabuf). But then Olivier made me realized it shouldn't be parsing for this case, since we know that the stream from V4L2 is packetized already. That's how we found it. I'll file a bug for the parser later.
Comment 25 Nicolas Dufresne (ndufresne) 2016-06-07 21:30:57 UTC
I can only finish this one tomorrow morning, though if needed go ahead, it's simple enough.
Comment 26 Nicolas Dufresne (ndufresne) 2016-06-08 00:55:26 UTC
Created attachment 329351 [details] [review]
pngdec: Wait for segment event before checking it

The heuristic to choose between packetise or not was changed to use the
segment format. The problem is that this change is reading the segment
during the caps event handling. The segment event will only be sent
after. That prevented the decoder to go in packetize mode, and avoid
useless parsing.
Comment 27 Nicolas Dufresne (ndufresne) 2016-06-08 01:05:44 UTC
Created attachment 329352 [details] [review]
vmncdec: Wait for segment event before checking it

The heuristic to choose between packetise or not was changed to use the
segment format. The problem is that this change is reading the segment
during the caps event handling. The segment event will only be sent
after. That prevented the decoder to go in packetize mode, and avoid
useless parsing.
Comment 28 Nicolas Dufresne (ndufresne) 2016-06-08 01:38:04 UTC
Created attachment 329359 [details] [review]
webpdec: Wait for segment event before checking it

The heuristic to choose between packetise or not was changed to use the
segment format. The problem is that this change is reading the segment
during the caps event handling. The segment event will only be sent
after. That prevented the decoder to go in packetize mode, and avoid
useless parsing.
Comment 29 Nicolas Dufresne (ndufresne) 2016-06-08 01:40:26 UTC
All tested, except for vmnc, for which I don't have an encoder or a test file.
Comment 30 Nicolas Dufresne (ndufresne) 2016-06-08 01:41:03 UTC
Attachment 329230 [details] pushed as a6008fd - jpegdec: Wait for segment event before checking it
Attachment 329351 [details] pushed as 7af9271 - pngdec: Wait for segment event before checking it
Comment 31 Nicolas Dufresne (ndufresne) 2016-06-08 01:41:36 UTC
Attachment 329352 [details] pushed as 50537e2 - vmncdec: Wait for segment event before checking it
Attachment 329359 [details] pushed as d33352e - webpdec: Wait for segment event before checking it
Comment 32 Nicolas Dufresne (ndufresne) 2016-06-08 01:45:19 UTC
Branch 1.8

Bad
WebP Commit: 55297c7df662c8316312110104ee806742226db2
VMNC Commit: c511e0c223817de89a85b5614c8c58c83ede2d00

Good
PNG Commit: c0fec05e5c95c9391278695f0b5ebbef81f1f009
JPG Commit: 81060df8baca29084c46431441e032a585062e6a
Comment 33 Sebastian Dröge (slomo) 2016-06-08 06:31:17 UTC
Thanks!