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 692933 - [API] codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments
[API] codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other Linux
: Normal enhancement
: 1.1.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 664274
 
 
Reported: 2013-01-31 11:52 UTC by Gwenole Beauchesne
Modified: 2013-07-08 09:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments (20.93 KB, patch)
2013-01-31 11:52 UTC, Gwenole Beauchesne
none Details | Review
codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments (20.93 KB, patch)
2013-01-31 14:25 UTC, Gwenole Beauchesne
none Details | Review
codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments (22.73 KB, patch)
2013-07-04 12:36 UTC, Gwenole Beauchesne
committed Details | Review
mpegvideoparse: cope with new parser API (6.49 KB, patch)
2013-07-04 12:37 UTC, Gwenole Beauchesne
none Details | Review
mpegvideoparse: cope with new parser API (6.51 KB, patch)
2013-07-04 16:56 UTC, Gwenole Beauchesne
committed Details | Review

Description Gwenole Beauchesne 2013-01-31 11:52:13 UTC
Created attachment 234899 [details] [review]
codecparsers: mpeg2: add new API that takes  GstMpegVideoPacket arguments

Hi,

This patch adds new interface to MPEG-2 video parser so that functions take a GstMpegVideoPacket argument instead of data, size and offset. New functions are called after gst_mpeg_video_packet_*() and provide the default implementation.

Older API is moved to the deprecated API and re-use the new functions.

The new API is more convenient in practice, since we normally get a correct packet out of gst_mpeg_video_parse(). i.e. we just need to re-use it as is when each individual parser is called. This also makes it possible to add an API for slice() header which is more consistent/in-line with the rest of the mpeg2 codec parser.
Comment 1 Tim-Philipp Müller 2013-01-31 12:05:14 UTC
I think this makes sense and is nicer API too.

Not entirely sure about the naming and order of arguments though (the inevitable bikeshedding, apologies): if the API is called gst_blah_packet_parse_foo() then the first argument should probably be the packet. That way bindings can map it to packet.parse_foo(). Or you make it gst_blah_parse_foo_from_packet(), then packet is the last arg.
Comment 2 Gwenole Beauchesne 2013-01-31 12:55:43 UTC
(In reply to comment #1)
> Not entirely sure about the naming and order of arguments though (the
> inevitable bikeshedding, apologies): if the API is called
> gst_blah_packet_parse_foo() then the first argument should probably be the
> packet. That way bindings can map it to packet.parse_foo(). Or you make it
> gst_blah_parse_foo_from_packet(), then packet is the last arg.

I am not sure about the naming of the functions either. :)

(i) If we make it gst_mpeg_video_packet_parse_something(packet, hdr, ...), then there could be cases where 1st arg (packet) is an input arg, second arg (the parsed header) an output arg, and extra args as input. e.g. for the slice() parser in particular, which requires an additional seqhdr for example.

(ii) If we make it gst_mpeg_video_parse_something_from_packet(), then this is also fine but the names become very long.

I would be tempted by (i) + fixing up the args order, but I definitely have no clear preference. Opinions?
Comment 3 Gwenole Beauchesne 2013-01-31 14:25:18 UTC
Created attachment 234913 [details] [review]
codecparsers: mpeg2: add new API that takes  GstMpegVideoPacket arguments

Implemented solution (i) with GstVideoMpegPacket args swapped.
Comment 4 Tim-Philipp Müller 2013-02-18 11:12:44 UTC
Looks good to me.

Could you also update the mpegvideoparser in gst/videoparsers/ to the new API ?
Comment 5 Tim-Philipp Müller 2013-02-18 11:13:30 UTC
Oh, and could you add

 * Since: 1.2
 */

markers at the end of gtk-doc chunks for the new API you added?
Comment 6 Gwenole Beauchesne 2013-07-04 12:36:03 UTC
Created attachment 248372 [details] [review]
codecparsers: mpeg2: add new API that takes  GstMpegVideoPacket arguments

Here is the updated patch to match current git master branch.

Diff of the patches shows the addition of "Since: 1.2" tags and minor fixes to function names for gtk-doc.
Comment 7 Gwenole Beauchesne 2013-07-04 12:37:50 UTC
Created attachment 248373 [details] [review]
mpegvideoparse: cope with new parser API

Patch to update the mpegvideoparser with newer APIs. I also tried to optimize gst_mpegv_parse_process_config() along the way by determining the extension_start_code_identifier before calling into the extension packet parser.
Comment 8 Gwenole Beauchesne 2013-07-04 12:45:18 UTC
Review of attachment 248373 [details] [review]:

::: gst/videoparsers/gstmpegvideoparse.c
@@ +318,3 @@
     mpvparse->config_flags |= FLAG_MPEG2;
+    if (packet.size > 1) {
+      packet.type = packet.data[packet.offset] >> 4;

Note: I am abusing packet.type here. It should be GST_MPEG_VIDEO_PACKET_EXTENSION and the sub_type parsed separately, but packet.type is not used in the codec parser library. But anyway, I will probably just fix it to the correct way to be on the safe side.
Comment 9 Gwenole Beauchesne 2013-07-04 16:56:37 UTC
Created attachment 248401 [details] [review]
mpegvideoparse: cope with new parser API
Comment 10 sreerenj 2013-07-05 11:25:26 UTC
You have to add them to docs/libs/gst-plugins-bad-libs-sections.txt :)
Comment 11 Tim-Philipp Müller 2013-07-05 11:44:53 UTC
Looks fine to me, feel free to push after adding the new functions to the docs. Thanks for updating the patches.

Regarding comment #8 - yes, if in doubt it's best to write code with readability and maintainability in mind IMHO, or to at least add a comment about the abuse.
Comment 12 sreerenj 2013-07-08 08:12:44 UTC
The patches have committed. Please close the bug.
Comment 13 Gwenole Beauchesne 2013-07-08 08:17:27 UTC
commit daddc1d7d61e9edd918ca3b4f404a655459fce44
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Thu Jan 31 11:57:54 2013 +0100

    codecparsers: mpeg2: update test program with new GstMpegVideoPacket API.
    
    This is the lost hunk from:
    https://bugzilla.gnome.org/show_bug.cgi?id=692933
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>

commit d10acd38790cd0f3d7b1318ff694281d67ddf473
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Thu Jul 4 14:22:14 2013 +0200

    mpegvideoparse: cope with new parser API.
    
    Migrate the code to use the new parser API based on GstMpegVideoPacket.
    
    Also try to optimize gst_mpegv_parse_process_config() by using more of
    GstMpegVideoPacket and determining the extension_start_code_identifier
    prior to calling the parser function for that extension packet.
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>

commit 1a5265ef72375fc1cf383b9e707a998e7c293887
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Thu Jan 31 11:57:54 2013 +0100

    codecparsers: mpeg2: add new API that takes GstMpegVideoPacket arguments.
    
    Add new interface to MPEG-2 video parser that takes GstMpegVideoPacket
    arguments instead of data, size, and offset. New functions are called
    after gst_mpeg_video_packet_*() and provide the default implementation.
    
    Older API is moved to the deprecated namespace and uses the new functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692933
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>