gstreamer/gst/dvdspu/gstspu-pgs.h
Jan Schmidt b68a05dbfa gstspu: Implement PGS rendering and alpha blending
Refactor the DVD subpicture compositing, switching it to 8-bit alpha
calculations. Reuse some of the resulting code to implement PGS
subpicture blending.

Implement parsing and collecting of composition objects properly, but
assuming a single active window and colour palette for now. I need more
PGS samples.
2009-05-26 15:58:09 +01:00

106 lines
2.9 KiB
C

/* GStreamer Sub-Picture Unit - PGS handling
* Copyright (C) 2009 Jan Schmidt <thaytan@noraisin.net>
*
* 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 __GSTSPU_PGS_H__
#define __GSTSPU_PGS_H__
#include "gstspu-common.h"
typedef struct SpuPgsState SpuPgsState;
typedef enum PgsCompositionObjectFlags PgsCompositionObjectFlags;
typedef enum PgsPresentationSegmentFlags PgsPresentationSegmentFlags;
typedef enum PgsObjectUpdateFlags PgsObjectUpdateFlags;
typedef struct PgsPresentationSegment PgsPresentationSegment;
typedef struct PgsCompositionObject PgsCompositionObject;
enum PgsPresentationSegmentFlags
{
PGS_PRES_SEGMENT_FLAG_UPDATE_PALETTE = 0x80
};
enum PgsCompositionObjectFlags
{
PGS_COMPOSITION_OBJECT_FLAG_CROPPED = 0x80,
PGS_COMPOSITION_OBJECT_FLAG_FORCED = 0x40
};
enum PgsObjectUpdateFlags
{
/* Set in an object_update if this is the beginning of new RLE data.
* If not set, the data is a continuation to be appended */
PGS_OBJECT_UPDATE_FLAG_START_RLE = 0x80,
PGS_OBJECT_UPDATE_FLAG_END_RLE = 0x40 /* This one is a guess */
};
struct PgsPresentationSegment
{
guint16 composition_no;
guint8 composition_state;
PgsPresentationSegmentFlags flags;
guint8 palette_id;
guint16 vid_w, vid_h;
guint8 vid_fps_code;
GArray *objects;
};
struct PgsCompositionObject
{
guint16 id;
guint8 version;
PgsCompositionObjectFlags flags;
guint8 win_id;
guint8 rle_data_ver;
guint8 *rle_data;
guint32 rle_data_size;
guint32 rle_data_used;
/* Top left corner of this object */
guint16 x, y;
/* Only valid if PGS_COMPOSITION_OBJECT_FLAG_CROPPED is set */
guint16 crop_x, crop_y, crop_w, crop_h;
};
struct SpuPgsState {
GstBuffer *pending_cmd;
gboolean in_presentation_segment;
gboolean have_presentation_segment;
PgsPresentationSegment pres_seg;
SpuColour palette[256];
guint16 win_x, win_y, win_w, win_h;
};
void gstspu_pgs_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, GstBuffer *buf);
gboolean gstspu_pgs_execute_event (GstDVDSpu *dvdspu);
void gstspu_pgs_render (GstDVDSpu *dvdspu, GstBuffer *buf);
gboolean gstspu_pgs_handle_dvd_event (GstDVDSpu *dvdspu, GstEvent *event);
void gstspu_pgs_flush (GstDVDSpu *dvdspu);
#endif