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 673976 - pbutils: codec description should include profile
pbutils: codec description should include profile
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: 2012-04-12 10:21 UTC by Christian Fredrik Kalager Schaller
Modified: 2015-02-27 20:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Fredrik Kalager Schaller 2012-04-12 10:21:43 UTC
When you pass a caps like video/x-h264,profile=main to pbutils it would be nice if it returned a string with information about the profile level and not just H.264.
Comment 1 Christian Fredrik Kalager Schaller 2014-04-15 08:31:55 UTC
I am referring to the human readable string you get get from pbutils here, in case it is unclear.
Comment 2 Tim-Philipp Müller 2015-02-15 20:13:20 UTC
commit 6af7b7016216ea9e92c23ec1baf827ffce72a645
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sun Feb 15 20:08:36 2015 +0000

    pbutils: description: move some code into utility function

commit 4e1a43d4eafaa3966f5a57c61ad4c6d960f30515
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sun Feb 15 20:05:13 2015 +0000

    pbutils: descriptions: add H.265 profile to description if available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673976

commit 58d19cb7ca9cb73e2ccce2f33e6f689f73ab0b44
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sun Feb 15 19:03:38 2015 +0000

    pbutils: descriptions: add MPEG-4 video profile to description if available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673976

commit 001bd7895799d77ac96b2ad0d02391b5b2942433
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sun Feb 15 18:37:38 2015 +0000

    pbutils: descriptions: add Dirac/VC-2 profile to description if available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673976

commit 1d528459bed7fcafabab9471eef98429442e941d
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sun Feb 15 18:14:18 2015 +0000

    pbutils: descriptions: add H.264 profile to description if available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673976
Comment 3 Olivier Crête 2015-02-27 01:56:54 UTC
You got the string manipulations wrong..

Can we replace the horribly ugly strings with \000 in it with a array of 2-element tuples, something like

struct Names {
const gchar *nick;
const gchar *name;
};

static const struct Names names[] = {{"high","High"}, .... , {NULL, NULL}};


Test program:

#include <gst/gst.h>

int
main (int   argc,
      char *argv[])
{
  GstCaps *caps;

  gst_init(&argc, &argv);

  caps = gst_caps_from_string ("video/x-h264, profile=(string)high");
  g_printf("%s\n", gst_pb_utils_get_codec_description(caps));

  return 0;
}
Comment 4 Olivier Crête 2015-02-27 01:58:08 UTC
This causes invalid UTF-8 to be output and spews out scary g_warnings(), so blockering it, worse-case we can just revert your patches.
Comment 5 Tim-Philipp Müller 2015-02-27 12:18:51 UTC
Thanks, I'll have a look.

The idea behind the strings was to avoid relocations, I would like to keep them if possible.
Comment 6 Tim-Philipp Müller 2015-02-27 19:20:00 UTC
I can't reproduce this at all. Works fine for me and is valgrind-clean on all systems/architectures I've tried (Linux 64-bit, 32-bit, ppc32, rpi; OS/X).

What OS/architecture/compiler is this with? Could you put some printfs into the code to see where in those 5 lines of code it goes wrong please?
Comment 7 Tim-Philipp Müller 2015-02-27 19:21:45 UTC
This should also be covered by the libs/pbutils unit test by the way, does it fail for you as well?
Comment 8 Olivier Crête 2015-02-27 19:59:41 UTC
I'm using Fedora 21 x86-64, so nothign special, and it breaks in the unit test too:
0:00:00.029324051  7823      0x1558ea0 LOG                    check libs/pbutils.c:418:test_pb_utils_get_codec_description: Caps video/x-h264, profile=(string)high-4:4:4-intra:
0:00:00.029354584  7823      0x1558ea0 LOG                    check libs/pbutils.c:421:test_pb_utils_get_codec_description:  - codec   : H.264 ( Profile)
0:00:00.029394859  7823      0x1558ea0 LOG                    check libs/pbutils.c:425:test_pb_utils_get_codec_description:  - decoder : H.264 ( Profile) decoder
0:00:00.029431095  7823      0x1558ea0 LOG                    check libs/pbutils.c:429:test_pb_utils_get_codec_description:  - encoder : H.264 ( Profile) encoder

I'll try to investigate further.
Comment 9 Olivier Crête 2015-02-27 20:11:21 UTC
It was a linking problem, you didn't make the strings static, so on my system, the space was just re-used after returning from the function.

That said, I'm not sure my fix is enough, as I think that they should be made into global constants. I'm not certain the C spec guarantees that a static const inside a function is valid when leaving the scope.

At least this makes it work:

commit 6046421ecc086db350c6f193bcb6a737934b1069
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Fri Feb 27 15:07:36 2015 -0500

    pbutils: description: Make static strings static
    
    Otherwise, they're not guaranteed to still be valid when leaving the scope.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673976
Comment 10 Sebastian Dröge (slomo) 2015-02-27 20:12:48 UTC
It does guarantee that, yes. Also we do that in many places :)
Comment 11 Tim-Philipp Müller 2015-02-27 20:17:10 UTC
Ah, d'oh. Thanks for investigating. Making them static should definitely be enough.