Libav
Data Structures | Macros | Enumerations | Functions | Variables
pgssubdec.c File Reference

PGS subtitle decoder. More...

#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "mathops.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"

Go to the source code of this file.

Data Structures

struct  PGSSubObjectRef
 
struct  PGSSubPresentation
 
struct  PGSSubObject
 
struct  PGSSubObjects
 
struct  PGSSubPalette
 
struct  PGSSubPalettes
 
struct  PGSSubContext
 

Macros

#define RGBA(r, g, b, a)   (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
 
#define MAX_EPOCH_PALETTES   8
 
#define MAX_EPOCH_OBJECTS   64
 
#define MAX_OBJECT_REFS   2
 

Enumerations

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

Functions

static void flush_cache (AVCodecContext *avctx)
 
static PGSSubObjectfind_object (int id, PGSSubObjects *objects)
 
static PGSSubPalettefind_palette (int id, PGSSubPalettes *palettes)
 
static av_cold int init_decoder (AVCodecContext *avctx)
 
static av_cold int close_decoder (AVCodecContext *avctx)
 
static int decode_rle (AVCodecContext *avctx, AVSubtitleRect *rect, const uint8_t *buf, unsigned int buf_size)
 Decode the RLE data. More...
 
static int parse_object_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 Parse the picture segment packet. More...
 
static int parse_palette_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 Parse the palette segment packet. More...
 
static int 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

AVCodec ff_pgssub_decoder
 

Detailed Description

PGS subtitle decoder.

Definition in file pgssubdec.c.

Macro Definition Documentation

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

Definition at line 35 of file pgssubdec.c.

Referenced by parse_palette_segment().

#define MAX_EPOCH_PALETTES   8

Definition at line 36 of file pgssubdec.c.

Referenced by parse_palette_segment().

#define MAX_EPOCH_OBJECTS   64

Definition at line 37 of file pgssubdec.c.

Referenced by parse_object_segment().

#define MAX_OBJECT_REFS   2

Definition at line 38 of file pgssubdec.c.

Referenced by parse_presentation_segment().

Enumeration Type Documentation

Enumerator
PALETTE_SEGMENT 
OBJECT_SEGMENT 
PRESENTATION_SEGMENT 
WINDOW_SEGMENT 
DISPLAY_SEGMENT 

Definition at line 40 of file pgssubdec.c.

Function Documentation

static void flush_cache ( AVCodecContext avctx)
static

Definition at line 98 of file pgssubdec.c.

Referenced by close_decoder(), and parse_presentation_segment().

static PGSSubObject* find_object ( int  id,
PGSSubObjects objects 
)
static

Definition at line 112 of file pgssubdec.c.

Referenced by display_end_segment(), and parse_object_segment().

static PGSSubPalette* find_palette ( int  id,
PGSSubPalettes palettes 
)
static

Definition at line 123 of file pgssubdec.c.

Referenced by display_end_segment(), and parse_palette_segment().

static av_cold int init_decoder ( AVCodecContext avctx)
static

Definition at line 134 of file pgssubdec.c.

static av_cold int close_decoder ( AVCodecContext avctx)
static

Definition at line 141 of file pgssubdec.c.

static int decode_rle ( AVCodecContext avctx,
AVSubtitleRect 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 158 of file pgssubdec.c.

Referenced by display_end_segment().

static int parse_object_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

Definition at line 228 of file pgssubdec.c.

Referenced by decode().

static int 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 320 of file pgssubdec.c.

Referenced by decode().

static int 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 376 of file pgssubdec.c.

Referenced by decode().

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

Definition at line 478 of file pgssubdec.c.

Referenced by decode().

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

Definition at line 579 of file pgssubdec.c.

Variable Documentation

AVCodec ff_pgssub_decoder
Initial value:
= {
.name = "pgssub",
.long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
.priv_data_size = sizeof(PGSSubContext),
}
static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: pgssubdec.c:579
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:150
static av_cold int close_decoder(AVCodecContext *avctx)
Definition: pgssubdec.c:141
static av_cold int init_decoder(AVCodecContext *avctx)
Definition: pgssubdec.c:134
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:490
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:499

Definition at line 660 of file pgssubdec.c.