Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so that it's below existing decoders.
Original commit message from CVS:
* configure.ac:
* gst/mpeg1videoparse/Makefile.am:
* gst/mpeg1videoparse/gstmp1videoparse.c:
* gst/mpeg1videoparse/gstmp1videoparse.h:
* gst/mpeg1videoparse/mp1videoparse.vcproj:
* gst/mpegvideoparse/Makefile.am:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_packetiser_init),
(mpeg_packetiser_free), (mpeg_packetiser_add_buf),
(mpeg_packetiser_flush), (mpeg_find_start_code),
(get_next_free_block), (complete_current_block),
(append_to_current_block), (start_new_block), (handle_packet),
(collect_packets), (mpeg_packetiser_handle_eos),
(mpeg_packetiser_get_block), (mpeg_packetiser_next_block):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c: (mpegvideoparse_get_type),
(gst_mpegvideoparse_base_init), (gst_mpegvideoparse_class_init),
(mpv_parse_reset), (gst_mpegvideoparse_init),
(gst_mpegvideoparse_dispose), (set_par_from_dar),
(set_fps_from_code), (mpegvideoparse_parse_seq),
(gst_mpegvideoparse_time_code), (gst_mpegvideoparse_flush),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (gst_mpegvideoparse_change_state),
(plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
* gst/mpegvideoparse/mpegvideoparse.vcproj:
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so
that it's below existing decoders.
Rename it to mpegvideoparse to reflect that it handles MPEG-1 and
MPEG-2 now.
Re-write the parsing code so that it collects packets differently
and timestamps Picture packets correctly.
Add a list of FIXME's at the top.
2007-03-15 20:48:08 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2007> Jan Schmidt <thaytan@mad.scientist.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#ifndef __MPEGPACKETISER_H__
|
|
|
|
#define __MPEGPACKETISER_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/base/gstadapter.h>
|
|
|
|
|
|
|
|
typedef struct MPEGPacketiser MPEGPacketiser;
|
|
|
|
typedef struct MPEGBlockInfo MPEGBlockInfo;
|
gst/mpegvideoparse/: Move the MPEG specific byte parsing into the mpegpacketiser code.
Original commit message from CVS:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_util_find_start_code),
(collect_packets), (set_par_from_dar), (set_fps_from_code),
(mpeg_util_parse_extension_packet), (mpeg_util_parse_sequence_hdr),
(mpeg_util_parse_picture_hdr):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c:
(mpegvideoparse_handle_sequence), (mpegvideoparse_handle_picture),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
Move the MPEG specific byte parsing into the mpegpacketiser code.
Add parsing of picture types, that just feeds into a debug message
for now.
Fix some 64-bit format strings.
2007-03-16 11:22:47 +00:00
|
|
|
typedef struct MPEGSeqHdr MPEGSeqHdr;
|
|
|
|
typedef struct MPEGPictureHdr MPEGPictureHdr;
|
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so that it's below existing decoders.
Original commit message from CVS:
* configure.ac:
* gst/mpeg1videoparse/Makefile.am:
* gst/mpeg1videoparse/gstmp1videoparse.c:
* gst/mpeg1videoparse/gstmp1videoparse.h:
* gst/mpeg1videoparse/mp1videoparse.vcproj:
* gst/mpegvideoparse/Makefile.am:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_packetiser_init),
(mpeg_packetiser_free), (mpeg_packetiser_add_buf),
(mpeg_packetiser_flush), (mpeg_find_start_code),
(get_next_free_block), (complete_current_block),
(append_to_current_block), (start_new_block), (handle_packet),
(collect_packets), (mpeg_packetiser_handle_eos),
(mpeg_packetiser_get_block), (mpeg_packetiser_next_block):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c: (mpegvideoparse_get_type),
(gst_mpegvideoparse_base_init), (gst_mpegvideoparse_class_init),
(mpv_parse_reset), (gst_mpegvideoparse_init),
(gst_mpegvideoparse_dispose), (set_par_from_dar),
(set_fps_from_code), (mpegvideoparse_parse_seq),
(gst_mpegvideoparse_time_code), (gst_mpegvideoparse_flush),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (gst_mpegvideoparse_change_state),
(plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
* gst/mpegvideoparse/mpegvideoparse.vcproj:
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so
that it's below existing decoders.
Rename it to mpegvideoparse to reflect that it handles MPEG-1 and
MPEG-2 now.
Re-write the parsing code so that it collects packets differently
and timestamps Picture packets correctly.
Add a list of FIXME's at the top.
2007-03-15 20:48:08 +00:00
|
|
|
|
|
|
|
/* Packet ID codes for different packet types we
|
|
|
|
* care about */
|
|
|
|
#define MPEG_PACKET_PICTURE 0x00
|
|
|
|
#define MPEG_PACKET_SLICE_MIN 0x01
|
|
|
|
#define MPEG_PACKET_SLICE_MAX 0xaf
|
|
|
|
#define MPEG_PACKET_SEQUENCE 0xb3
|
|
|
|
#define MPEG_PACKET_EXTENSION 0xb5
|
|
|
|
#define MPEG_PACKET_SEQUENCE_END 0xb7
|
|
|
|
#define MPEG_PACKET_GOP 0xb8
|
|
|
|
#define MPEG_PACKET_NONE 0xff
|
|
|
|
|
|
|
|
/* Extension codes we care about */
|
|
|
|
#define MPEG_PACKET_EXT_SEQUENCE 0x01
|
|
|
|
#define MPEG_PACKET_EXT_SEQUENCE_DISPLAY 0x02
|
|
|
|
#define MPEG_PACKET_EXT_QUANT_MATRIX 0x03
|
|
|
|
|
|
|
|
/* Flags indicating what type of packets are in this block, some are mutually
|
|
|
|
* exclusive though - ie, sequence packs are accumulated separately. GOP &
|
|
|
|
* Picture may occur together or separately */
|
|
|
|
#define MPEG_BLOCK_FLAG_SEQUENCE 0x01
|
|
|
|
#define MPEG_BLOCK_FLAG_PICTURE 0x02
|
|
|
|
#define MPEG_BLOCK_FLAG_GOP 0x04
|
|
|
|
|
gst/mpegvideoparse/: Move the MPEG specific byte parsing into the mpegpacketiser code.
Original commit message from CVS:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_util_find_start_code),
(collect_packets), (set_par_from_dar), (set_fps_from_code),
(mpeg_util_parse_extension_packet), (mpeg_util_parse_sequence_hdr),
(mpeg_util_parse_picture_hdr):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c:
(mpegvideoparse_handle_sequence), (mpegvideoparse_handle_picture),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
Move the MPEG specific byte parsing into the mpegpacketiser code.
Add parsing of picture types, that just feeds into a debug message
for now.
Fix some 64-bit format strings.
2007-03-16 11:22:47 +00:00
|
|
|
#define MPEG_PICTURE_TYPE_I 0x01
|
|
|
|
#define MPEG_PICTURE_TYPE_P 0x02
|
|
|
|
#define MPEG_PICTURE_TYPE_B 0x03
|
|
|
|
#define MPEG_PICTURE_TYPE_D 0x04
|
|
|
|
|
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so that it's below existing decoders.
Original commit message from CVS:
* configure.ac:
* gst/mpeg1videoparse/Makefile.am:
* gst/mpeg1videoparse/gstmp1videoparse.c:
* gst/mpeg1videoparse/gstmp1videoparse.h:
* gst/mpeg1videoparse/mp1videoparse.vcproj:
* gst/mpegvideoparse/Makefile.am:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_packetiser_init),
(mpeg_packetiser_free), (mpeg_packetiser_add_buf),
(mpeg_packetiser_flush), (mpeg_find_start_code),
(get_next_free_block), (complete_current_block),
(append_to_current_block), (start_new_block), (handle_packet),
(collect_packets), (mpeg_packetiser_handle_eos),
(mpeg_packetiser_get_block), (mpeg_packetiser_next_block):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c: (mpegvideoparse_get_type),
(gst_mpegvideoparse_base_init), (gst_mpegvideoparse_class_init),
(mpv_parse_reset), (gst_mpegvideoparse_init),
(gst_mpegvideoparse_dispose), (set_par_from_dar),
(set_fps_from_code), (mpegvideoparse_parse_seq),
(gst_mpegvideoparse_time_code), (gst_mpegvideoparse_flush),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (gst_mpegvideoparse_change_state),
(plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
* gst/mpegvideoparse/mpegvideoparse.vcproj:
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so
that it's below existing decoders.
Rename it to mpegvideoparse to reflect that it handles MPEG-1 and
MPEG-2 now.
Re-write the parsing code so that it collects packets differently
and timestamps Picture packets correctly.
Add a list of FIXME's at the top.
2007-03-15 20:48:08 +00:00
|
|
|
struct MPEGBlockInfo {
|
|
|
|
guint8 first_pack_type;
|
|
|
|
guint8 flags;
|
|
|
|
|
|
|
|
guint64 offset;
|
|
|
|
guint32 length;
|
|
|
|
|
|
|
|
GstClockTime ts;
|
|
|
|
};
|
|
|
|
|
gst/mpegvideoparse/: Move the MPEG specific byte parsing into the mpegpacketiser code.
Original commit message from CVS:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_util_find_start_code),
(collect_packets), (set_par_from_dar), (set_fps_from_code),
(mpeg_util_parse_extension_packet), (mpeg_util_parse_sequence_hdr),
(mpeg_util_parse_picture_hdr):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c:
(mpegvideoparse_handle_sequence), (mpegvideoparse_handle_picture),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
Move the MPEG specific byte parsing into the mpegpacketiser code.
Add parsing of picture types, that just feeds into a debug message
for now.
Fix some 64-bit format strings.
2007-03-16 11:22:47 +00:00
|
|
|
struct MPEGSeqHdr
|
|
|
|
{
|
|
|
|
/* 0 for unknown, else 1 or 2 */
|
|
|
|
guint8 mpeg_version;
|
|
|
|
|
|
|
|
/* Pixel-Aspect Ratio from DAR code via set_par_from_dar */
|
|
|
|
gint par_w, par_h;
|
|
|
|
/* Width and Height of the video */
|
|
|
|
gint width, height;
|
|
|
|
/* Framerate */
|
|
|
|
gint fps_n, fps_d;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MPEGPictureHdr
|
|
|
|
{
|
|
|
|
guint8 pic_type;
|
|
|
|
};
|
|
|
|
|
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so that it's below existing decoders.
Original commit message from CVS:
* configure.ac:
* gst/mpeg1videoparse/Makefile.am:
* gst/mpeg1videoparse/gstmp1videoparse.c:
* gst/mpeg1videoparse/gstmp1videoparse.h:
* gst/mpeg1videoparse/mp1videoparse.vcproj:
* gst/mpegvideoparse/Makefile.am:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_packetiser_init),
(mpeg_packetiser_free), (mpeg_packetiser_add_buf),
(mpeg_packetiser_flush), (mpeg_find_start_code),
(get_next_free_block), (complete_current_block),
(append_to_current_block), (start_new_block), (handle_packet),
(collect_packets), (mpeg_packetiser_handle_eos),
(mpeg_packetiser_get_block), (mpeg_packetiser_next_block):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c: (mpegvideoparse_get_type),
(gst_mpegvideoparse_base_init), (gst_mpegvideoparse_class_init),
(mpv_parse_reset), (gst_mpegvideoparse_init),
(gst_mpegvideoparse_dispose), (set_par_from_dar),
(set_fps_from_code), (mpegvideoparse_parse_seq),
(gst_mpegvideoparse_time_code), (gst_mpegvideoparse_flush),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (gst_mpegvideoparse_change_state),
(plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
* gst/mpegvideoparse/mpegvideoparse.vcproj:
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so
that it's below existing decoders.
Rename it to mpegvideoparse to reflect that it handles MPEG-1 and
MPEG-2 now.
Re-write the parsing code so that it collects packets differently
and timestamps Picture packets correctly.
Add a list of FIXME's at the top.
2007-03-15 20:48:08 +00:00
|
|
|
struct MPEGPacketiser {
|
|
|
|
GstAdapter *adapter;
|
|
|
|
/* position in the adapter */
|
|
|
|
guint64 adapter_offset;
|
|
|
|
|
|
|
|
/* Sync word accumulator */
|
|
|
|
guint32 sync_word;
|
|
|
|
|
|
|
|
/* Offset since the last flush (unrelated to incoming buffer offsets) */
|
|
|
|
guint64 tracked_offset;
|
|
|
|
|
|
|
|
/* Number of picture packets currently collected */
|
|
|
|
guint n_pictures;
|
|
|
|
|
|
|
|
/* 2 sets of timestamps + offsets used to mark picture blocks
|
|
|
|
* The first is used when a sync word overlaps packet boundaries
|
|
|
|
* and comes from some buffer in the past. The next one comes from current
|
|
|
|
* buffer. These are only ever valid when handling streams from a demuxer,
|
|
|
|
* of course. */
|
|
|
|
GstClockTime prev_buf_ts;
|
|
|
|
GstClockTime cur_buf_ts;
|
|
|
|
|
|
|
|
/* MPEG id of the previous SEQUENCE, PICTURE or GOP packet.
|
|
|
|
MPEG_PACKET_NONE after a flush */
|
|
|
|
guint8 prev_sync_packet;
|
|
|
|
|
|
|
|
/* Indices into the blocks array. cur_block_idx is where we're writing and
|
|
|
|
indicates the end of the populated block entries.
|
|
|
|
first_block_idx is the read ptr. It may be -1 to indicate there are no
|
|
|
|
complete blocks available */
|
|
|
|
gint cur_block_idx;
|
|
|
|
gint first_block_idx;
|
|
|
|
|
|
|
|
/* An array of MPEGBlockInfo entries, used as a growable circular buffer
|
|
|
|
* indexed by cur_block_idx and bounded by last_block_idx */
|
|
|
|
gint n_blocks;
|
|
|
|
MPEGBlockInfo *blocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
void mpeg_packetiser_init (MPEGPacketiser *p);
|
|
|
|
void mpeg_packetiser_free (MPEGPacketiser *p);
|
|
|
|
|
|
|
|
void mpeg_packetiser_add_buf (MPEGPacketiser *p, GstBuffer *buf);
|
|
|
|
void mpeg_packetiser_handle_eos (MPEGPacketiser *p);
|
|
|
|
|
|
|
|
void mpeg_packetiser_flush (MPEGPacketiser *p);
|
|
|
|
|
|
|
|
/* Get the blockinfo and buffer for the block at the head of the queue */
|
|
|
|
MPEGBlockInfo *mpeg_packetiser_get_block (MPEGPacketiser *p, GstBuffer **buf);
|
|
|
|
|
|
|
|
/* Advance to the next data block */
|
|
|
|
void mpeg_packetiser_next_block (MPEGPacketiser *p);
|
|
|
|
|
gst/mpegvideoparse/: Move the MPEG specific byte parsing into the mpegpacketiser code.
Original commit message from CVS:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_util_find_start_code),
(collect_packets), (set_par_from_dar), (set_fps_from_code),
(mpeg_util_parse_extension_packet), (mpeg_util_parse_sequence_hdr),
(mpeg_util_parse_picture_hdr):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c:
(mpegvideoparse_handle_sequence), (mpegvideoparse_handle_picture),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
Move the MPEG specific byte parsing into the mpegpacketiser code.
Add parsing of picture types, that just feeds into a debug message
for now.
Fix some 64-bit format strings.
2007-03-16 11:22:47 +00:00
|
|
|
/* Utility functions for parsing MPEG packets */
|
|
|
|
guint8 *mpeg_util_find_start_code (guint32 *sync_word,
|
|
|
|
guint8 *cur, guint8 *end);
|
|
|
|
gboolean mpeg_util_parse_sequence_hdr (MPEGSeqHdr *hdr,
|
|
|
|
guint8 *data, guint8 *end);
|
|
|
|
gboolean mpeg_util_parse_picture_hdr (MPEGPictureHdr *hdr,
|
|
|
|
guint8 *data, guint8 *end);
|
|
|
|
|
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so that it's below existing decoders.
Original commit message from CVS:
* configure.ac:
* gst/mpeg1videoparse/Makefile.am:
* gst/mpeg1videoparse/gstmp1videoparse.c:
* gst/mpeg1videoparse/gstmp1videoparse.h:
* gst/mpeg1videoparse/mp1videoparse.vcproj:
* gst/mpegvideoparse/Makefile.am:
* gst/mpegvideoparse/mpegpacketiser.c: (mpeg_packetiser_init),
(mpeg_packetiser_free), (mpeg_packetiser_add_buf),
(mpeg_packetiser_flush), (mpeg_find_start_code),
(get_next_free_block), (complete_current_block),
(append_to_current_block), (start_new_block), (handle_packet),
(collect_packets), (mpeg_packetiser_handle_eos),
(mpeg_packetiser_get_block), (mpeg_packetiser_next_block):
* gst/mpegvideoparse/mpegpacketiser.h:
* gst/mpegvideoparse/mpegvideoparse.c: (mpegvideoparse_get_type),
(gst_mpegvideoparse_base_init), (gst_mpegvideoparse_class_init),
(mpv_parse_reset), (gst_mpegvideoparse_init),
(gst_mpegvideoparse_dispose), (set_par_from_dar),
(set_fps_from_code), (mpegvideoparse_parse_seq),
(gst_mpegvideoparse_time_code), (gst_mpegvideoparse_flush),
(mpegvideoparse_drain_avail), (gst_mpegvideoparse_chain),
(mpv_parse_sink_event), (gst_mpegvideoparse_change_state),
(plugin_init):
* gst/mpegvideoparse/mpegvideoparse.h:
* gst/mpegvideoparse/mpegvideoparse.vcproj:
Port mpeg1videoparse to 0.10 and give it rank SECONDARY-1, so
that it's below existing decoders.
Rename it to mpegvideoparse to reflect that it handles MPEG-1 and
MPEG-2 now.
Re-write the parsing code so that it collects packets differently
and timestamps Picture packets correctly.
Add a list of FIXME's at the top.
2007-03-15 20:48:08 +00:00
|
|
|
#endif
|