GNOME Bugzilla – Bug 673976
pbutils: codec description should include profile
Last modified: 2015-02-27 20:20:57 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.
I am referring to the human readable string you get get from pbutils here, in case it is unclear.
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
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; }
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.
Thanks, I'll have a look. The idea behind the strings was to avoid relocations, I would like to keep them if possible.
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?
This should also be covered by the libs/pbutils unit test by the way, does it fail for you as well?
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.
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
It does guarantee that, yes. Also we do that in many places :)
Ah, d'oh. Thanks for investigating. Making them static should definitely be enough.