pgssubdec.c File Reference

PGS subtitle decoder. More...

#include "avcodec.h"
#include "dsputil.h"
#include "bytestream.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
Include dependency graph for pgssubdec.c:

Go to the source code of this file.

Data Structures

struct  PGSSubPictureReference
 
struct  PGSSubPresentation
 
struct  PGSSubPicture
 
struct  PGSSubContext
 

Macros

#define RGBA(r, g, b, a)   (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
 
#define OFFSET(x)   offsetof(PGSSubContext, x)
 
#define SD   AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Typedefs

typedef struct PGSSubPictureReference PGSSubPictureReference
 
typedef struct PGSSubPresentation PGSSubPresentation
 
typedef struct PGSSubPicture PGSSubPicture
 
typedef struct PGSSubContext PGSSubContext
 

Enumerations

enum  SegmentType {
  PALETTE_SEGMENT = 0x14, PICTURE_SEGMENT = 0x15, PRESENTATION_SEGMENT = 0x16, WINDOW_SEGMENT = 0x17,
  DISPLAY_SEGMENT = 0x80
}
 

Functions

static av_cold int init_decoder (AVCodecContext *avctx)
 
static av_cold int close_decoder (AVCodecContext *avctx)
 
static int decode_rle (AVCodecContext *avctx, AVSubtitle *sub, int rect, const uint8_t *buf, unsigned int buf_size)
 Decode the RLE data. More...
 
static int parse_picture_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 Parse the picture segment packet. More...
 
static void parse_palette_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 Parse the palette segment packet. More...
 
static void parse_presentation_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size, int64_t pts)
 Parse the presentation segment packet. More...
 
static int display_end_segment (AVCodecContext *avctx, void *data, const uint8_t *buf, int buf_size)
 Parse the display segment packet. More...
 
static int decode (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 

Variables

static const AVOption options []
 
static const AVClass pgsdec_class
 
AVCodec ff_pgssub_decoder
 

Detailed Description

PGS subtitle decoder.

Definition in file pgssubdec.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(PGSSubContext, x)

Definition at line 525 of file pgssubdec.c.

#define RGBA (   r,
  g,
  b,
  a 
)    (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))

Definition at line 34 of file pgssubdec.c.

Referenced by parse_palette_segment().

Definition at line 526 of file pgssubdec.c.

Typedef Documentation

typedef struct PGSSubContext PGSSubContext
typedef struct PGSSubPicture PGSSubPicture

Enumeration Type Documentation

Enumerator
PALETTE_SEGMENT 
PICTURE_SEGMENT 
PRESENTATION_SEGMENT 
WINDOW_SEGMENT 
DISPLAY_SEGMENT 

Definition at line 36 of file pgssubdec.c.

Function Documentation

static av_cold int close_decoder ( AVCodecContext avctx)
static

Definition at line 81 of file pgssubdec.c.

static int decode ( AVCodecContext avctx,
void data,
int *  data_size,
AVPacket avpkt 
)
static

Definition at line 449 of file pgssubdec.c.

static int decode_rle ( AVCodecContext avctx,
AVSubtitle sub,
int  rect,
const uint8_t buf,
unsigned int  buf_size 
)
static

Decode the RLE data.

The subtitle is stored as an Run Length Encoded image.

Parameters
avctxcontains the current codec context
subpointer to the processed subtitle data
bufpointer to the RLE data to process
buf_sizesize of the RLE data to process

Definition at line 108 of file pgssubdec.c.

Referenced by display_end_segment().

static int display_end_segment ( AVCodecContext avctx,
void data,
const uint8_t buf,
int  buf_size 
)
static

Parse the display segment packet.

The display segment controls the updating of the display.

Parameters
avctxcontains the current codec context
datapointer to the data pertaining the subtitle to display
bufpointer to the packet to process
buf_sizesize of packet to process
Todo:

TODO: Fix start time, relies on correct PTS, currently too late

segment, which is currently ignored as it clears

the subtitle too early.

Todo:
TODO: Fix end time, normally cleared by a second display

Definition at line 385 of file pgssubdec.c.

Referenced by decode().

static av_cold int init_decoder ( AVCodecContext avctx)
static

Definition at line 74 of file pgssubdec.c.

static void parse_palette_segment ( AVCodecContext avctx,
const uint8_t buf,
int  buf_size 
)
static

Parse the palette segment packet.

The palette segment contains details of the palette, a maximum of 256 colors can be defined.

Parameters
avctxcontains the current codec context
bufpointer to the packet to process
buf_sizesize of packet to process

Definition at line 255 of file pgssubdec.c.

Referenced by decode().

static int parse_picture_segment ( AVCodecContext avctx,
const uint8_t buf,
int  buf_size 
)
static

Parse the picture segment packet.

The picture segment contains details on the sequence id, width, height and Run Length Encoded (RLE) bitmap data.

Parameters
avctxcontains the current codec context
bufpointer to the packet to process
buf_sizesize of packet to process
Todo:
TODO: Enable support for RLE data over multiple packets

Definition at line 175 of file pgssubdec.c.

Referenced by decode().

static void parse_presentation_segment ( AVCodecContext avctx,
const uint8_t buf,
int  buf_size,
int64_t  pts 
)
static

Parse the presentation segment packet.

The presentation segment contains details on the video width, video height, x & y subtitle position.

Parameters
avctxcontains the current codec context
bufpointer to the packet to process
buf_sizesize of packet to process
Todo:
TODO: Implement cropping

Definition at line 297 of file pgssubdec.c.

Referenced by decode().

Variable Documentation

AVCodec ff_pgssub_decoder
Initial value:
= {
.name = "pgssub",
.priv_data_size = sizeof(PGSSubContext),
.long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
.priv_class = &pgsdec_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static const AVClass pgsdec_class
Definition: pgssubdec.c:532
static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: pgssubdec.c:449
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int close_decoder(AVCodecContext *avctx)
Definition: pgssubdec.c:81
struct PGSSubContext PGSSubContext
static av_cold int init_decoder(AVCodecContext *avctx)
Definition: pgssubdec.c:74
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375

Definition at line 539 of file pgssubdec.c.

const AVOption options[]
static
Initial value:
= {
{"forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD},
{ NULL },
}
#define OFFSET(x)
Definition: pgssubdec.c:525
NULL
Definition: eval.c:55
#define SD
Definition: pgssubdec.c:526

Definition at line 527 of file pgssubdec.c.

const AVClass pgsdec_class
static
Initial value:
= {
.class_name = "PGS subtitle decoder",
.item_name = av_default_item_name,
.option = options,
}
av_default_item_name
static const AVOption options[]
Definition: pgssubdec.c:527
LIBAVUTIL_VERSION_INT
Definition: eval.c:55

Definition at line 532 of file pgssubdec.c.