MythTV  master
Classes | Macros | Typedefs | Enumerations | Functions | Variables
pxsup2dast.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <errno.h>
#include <ctype.h>
#include <setjmp.h>
#include <zlib.h>
#include <dirent.h>
#include <stdint.h>
Include dependency graph for pxsup2dast.c:

Go to the source code of this file.

Classes

struct  exc__state
 
struct  Png4File
 
struct  BoundStr
 

Macros

#define GCCATTR_PRINTF(m, n)
 
#define GCCATTR_UNUSED
 
#define GCCATTR_NORETURN
 
#define GCCATTR_CONST
 
#define CUS   (const unsigned char *)
 
#define exc_try(x)
 
#define exc_ftry(x)
 
#define exc_catch(x, t)   else if ((t) == exc_type##x)
 
#define exc_end(x)   else __exc_throw(exc_type##x); EXC.m_last = exc_s##x.m_prev; } while (0)
 
#define exc_return(x)   for (EXC.m_last = exc_p##x;) return
 
#define exc_fthrow(x)   for (EXC.m_last = exc_p##x;) ex_throw
 
#define exc_catchall   else
 
#define exc_endall(x)   EXC.m_last = exc_s##x.m_prev; } while (0)
 
#define exc_cleanup()   EXC.m_last = NULL;
 
#define xxfwriteCS(f, s)   xxfwrite(f, CUS s, sizeof (s) - 1)
 

Typedefs

typedef unsigned char bool8
 
typedef int8_t ei8
 
typedef uint8_t eu8
 
typedef int16_t ei16
 
typedef uint16_t eu16
 
typedef int32_t ei32
 
typedef uint32_t eu32
 
typedef int_least8_t li8
 
typedef uint_least8_t lu8
 
typedef int_least16_t li16
 
typedef uint_least16_t lu16
 
typedef int_least32_t li32
 
typedef uint_least32_t lu32
 
typedef int_fast8_t fi8
 
typedef uint_fast8_t fu8
 
typedef int_fast16_t fi16
 
typedef uint_fast16_t fu16
 
typedef int_fast32_t fi32
 
typedef uint_fast32_t fu32
 
typedef struct Png4File Png4File
 
typedef struct BoundStr BoundStr
 

Enumerations

enum  bool { false = 0, true = 1 }
 
enum  { MiscError = 1, EOFIndicator, IndexError }
 

Functions

int sup2dast (const char *supfile, const char *ifofile, int delay_ms)
 
static void __exc_throw (int type)
 
static void exc_throw (int type, const char *format,...)
 
static eu8xxfread (FILE *stream, eu8 *ptr, size_t size)
 
static void xxfwrite (FILE *stream, const eu8 *ptr, size_t size)
 
static void yuv2rgb (int y, int cr, int cb, eu8 *r, eu8 *g, eu8 *b)
 
static void rgb2yuv (eu8 r, eu8 g, eu8 b, eu8 *y, eu8 *cr, eu8 *cb)
 
static FILE * xfopen (const char *filename, const char *mode)
 
static void xfseek0 (FILE *stream, long offset)
 
static void xmkdir (const char *path, int mode)
 
static bool fexists (const char *filename)
 
static bool dexists (const char *filename)
 
static fu32 get_uint32_be (const eu8 *bytes)
 
static fu16 get_uint16_be (const eu8 *bytes)
 
static fu32 get_uint32_le (const eu8 *bytes)
 
static void set_uint32_be (eu8 *ptr, eu32 value)
 
static void set_uint16_le (eu8 *ptr, eu16 value)
 
static void xxfwrite_uint32_be (FILE *fh, eu32 value)
 
static void ifopalette (const char *filename, eu8 yuvpalette[16][3], eu8 rgbpalette[16][3])
 
static void set2palettes (int value, eu8 *yuvpalpart, eu8 *rgbpalpart)
 
static void argpalette (const char *arg, eu8 yuvpalette[16][3], eu8 rgbpalette[16][3])
 
static void png4file_init (Png4File *self, eu8 palette[4][3])
 
static void png4file_open (Png4File *self, const char *filename, int height, int width)
 
static void png4file_flush (Png4File *self)
 
static void png4file_addpixel (Png4File *self, eu8 pixel)
 
static void png4file_endrow (Png4File *self)
 
static void png4file_close (Png4File *self)
 
static eu8 getnibble (eu8 **data, int *nibble)
 
static void getpixelline (eu8 **data, int width, Png4File *picfile)
 
static void makebitmap (eu8 *data, int w, int h, int top, int bot, char *filename, eu8 palette[4][3])
 
static char * pts2ts (fu32 pts, char *rvbuf, bool is_png_filename)
 
static void boundstr_init (BoundStr *bs, eu8 *p, int l)
 
static eu8boundstr_read (BoundStr *bs, int l)
 
static void pxsubtitle (const char *supfile, FILE *ofh, eu8 palette[16][3], bool createpics, int delay_ms, char *fnbuf, char *fnbuf_fp)
 
static bool samepalette (char *filename, eu8 palette[16][3])
 

Variables

struct {
   struct exc__state *   m_last
 
   char   m_msgbuf [1024]
 
   int   m_buflen
 
EXC
 

Macro Definition Documentation

◆ GCCATTR_PRINTF

#define GCCATTR_PRINTF (   m,
 
)

Definition at line 75 of file pxsup2dast.c.

◆ GCCATTR_UNUSED

#define GCCATTR_UNUSED

Definition at line 76 of file pxsup2dast.c.

◆ GCCATTR_NORETURN

#define GCCATTR_NORETURN

Definition at line 77 of file pxsup2dast.c.

◆ GCCATTR_CONST

#define GCCATTR_CONST

Definition at line 78 of file pxsup2dast.c.

◆ CUS

#define CUS   (const unsigned char *)

Definition at line 82 of file pxsup2dast.c.

◆ exc_try

#define exc_try (   x)
Value:
do { struct exc__state exc_s##x; int exc_type##x GCCATTR_UNUSED; \
exc_s##x.m_prev = EXC.m_last; EXC.m_last = &exc_s##x; if ((exc_type##x = setjmp(exc_s##x.m_env)) == 0)

Definition at line 107 of file pxsup2dast.c.

◆ exc_ftry

#define exc_ftry (   x)
Value:
do { struct exc__state exc_s##x, *exc_p##x = EXC.m_last; \
int exc_type##x GCCATTR_UNUSED; exc_s##x.prev = EXC.m_last; \
EXC.m_last = &exc_s##x; if ((exc_type##x = setjmp(exc_s##x.env)) == 0)

Definition at line 110 of file pxsup2dast.c.

◆ exc_catch

#define exc_catch (   x,
 
)    else if ((t) == exc_type##x)

Definition at line 114 of file pxsup2dast.c.

◆ exc_end

#define exc_end (   x)    else __exc_throw(exc_type##x); EXC.m_last = exc_s##x.m_prev; } while (0)

Definition at line 116 of file pxsup2dast.c.

◆ exc_return

#define exc_return (   x)    for (EXC.m_last = exc_p##x;) return

Definition at line 118 of file pxsup2dast.c.

◆ exc_fthrow

#define exc_fthrow (   x)    for (EXC.m_last = exc_p##x;) ex_throw

Definition at line 120 of file pxsup2dast.c.

◆ exc_catchall

#define exc_catchall   else

Definition at line 122 of file pxsup2dast.c.

◆ exc_endall

#define exc_endall (   x)    EXC.m_last = exc_s##x.m_prev; } while (0)

Definition at line 123 of file pxsup2dast.c.

◆ exc_cleanup

#define exc_cleanup ( )    EXC.m_last = NULL;

Definition at line 125 of file pxsup2dast.c.

◆ xxfwriteCS

#define xxfwriteCS (   f,
 
)    xxfwrite(f, CUS s, sizeof (s) - 1)

Definition at line 202 of file pxsup2dast.c.

Typedef Documentation

◆ bool8

typedef unsigned char bool8

Definition at line 31 of file pxsup2dast.c.

◆ ei8

typedef int8_t ei8

Definition at line 55 of file pxsup2dast.c.

◆ eu8

typedef uint8_t eu8

Definition at line 55 of file pxsup2dast.c.

◆ ei16

typedef int16_t ei16

Definition at line 56 of file pxsup2dast.c.

◆ eu16

typedef uint16_t eu16

Definition at line 56 of file pxsup2dast.c.

◆ ei32

typedef int32_t ei32

Definition at line 57 of file pxsup2dast.c.

◆ eu32

typedef uint32_t eu32

Definition at line 57 of file pxsup2dast.c.

◆ li8

typedef int_least8_t li8

Definition at line 59 of file pxsup2dast.c.

◆ lu8

typedef uint_least8_t lu8

Definition at line 59 of file pxsup2dast.c.

◆ li16

typedef int_least16_t li16

Definition at line 60 of file pxsup2dast.c.

◆ lu16

typedef uint_least16_t lu16

Definition at line 60 of file pxsup2dast.c.

◆ li32

typedef int_least32_t li32

Definition at line 61 of file pxsup2dast.c.

◆ lu32

typedef uint_least32_t lu32

Definition at line 61 of file pxsup2dast.c.

◆ fi8

typedef int_fast8_t fi8

Definition at line 63 of file pxsup2dast.c.

◆ fu8

typedef uint_fast8_t fu8

Definition at line 63 of file pxsup2dast.c.

◆ fi16

typedef int_fast16_t fi16

Definition at line 64 of file pxsup2dast.c.

◆ fu16

typedef uint_fast16_t fu16

Definition at line 64 of file pxsup2dast.c.

◆ fi32

typedef int_fast32_t fi32

Definition at line 65 of file pxsup2dast.c.

◆ fu32

typedef uint_fast32_t fu32

Definition at line 65 of file pxsup2dast.c.

◆ Png4File

typedef struct Png4File Png4File

◆ BoundStr

typedef struct BoundStr BoundStr

Enumeration Type Documentation

◆ bool

enum bool
Enumerator
false 
true 

Definition at line 30 of file pxsup2dast.c.

◆ anonymous enum

anonymous enum
Enumerator
MiscError 
EOFIndicator 
IndexError 

Definition at line 84 of file pxsup2dast.c.

Function Documentation

◆ sup2dast()

int sup2dast ( const char *  supfile,
const char *  ifofile,
int  delay_ms 
)

Definition at line 886 of file pxsup2dast.c.

Referenced by main_local().

◆ __exc_throw()

static void __exc_throw ( int  type)
static

Definition at line 127 of file pxsup2dast.c.

Referenced by exc_throw().

◆ exc_throw()

static void exc_throw ( int  type,
const char *  format,
  ... 
)
static

◆ xxfread()

static eu8* xxfread ( FILE *  stream,
eu8 ptr,
size_t  size 
)
static

Definition at line 180 of file pxsup2dast.c.

Referenced by ifopalette(), and pxsubtitle().

◆ xxfwrite()

static void xxfwrite ( FILE *  stream,
const eu8 ptr,
size_t  size 
)
static

Definition at line 191 of file pxsup2dast.c.

Referenced by png4file_close(), png4file_flush(), png4file_open(), and xxfwrite_uint32_be().

◆ yuv2rgb()

static void yuv2rgb ( int  y,
int  cr,
int  cb,
eu8 r,
eu8 g,
eu8 b 
)
static

Definition at line 204 of file pxsup2dast.c.

Referenced by ifopalette(), and MythVideoColourSpace::Update().

◆ rgb2yuv()

static void rgb2yuv ( eu8  r,
eu8  g,
eu8  b,
eu8 y,
eu8 cr,
eu8 cb 
)
static

Definition at line 217 of file pxsup2dast.c.

Referenced by set2palettes(), and MythVideoColourSpace::Update().

◆ xfopen()

static FILE* xfopen ( const char *  filename,
const char *  mode 
)
static

Definition at line 245 of file pxsup2dast.c.

Referenced by ifopalette(), png4file_open(), pxsubtitle(), samepalette(), and sup2dast().

◆ xfseek0()

static void xfseek0 ( FILE *  stream,
long  offset 
)
static

Definition at line 253 of file pxsup2dast.c.

Referenced by ifopalette(), and png4file_close().

◆ xmkdir()

static void xmkdir ( const char *  path,
int  mode 
)
static

Definition at line 259 of file pxsup2dast.c.

Referenced by sup2dast().

◆ fexists()

static bool fexists ( const char *  filename)
static

Definition at line 272 of file pxsup2dast.c.

Referenced by samepalette(), and sup2dast().

◆ dexists()

static bool dexists ( const char *  filename)
static

Definition at line 281 of file pxsup2dast.c.

Referenced by sup2dast().

◆ get_uint32_be()

static fu32 get_uint32_be ( const eu8 bytes)
static

Definition at line 291 of file pxsup2dast.c.

Referenced by ifopalette().

◆ get_uint16_be()

static fu16 get_uint16_be ( const eu8 bytes)
static

Definition at line 296 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ get_uint32_le()

static fu32 get_uint32_le ( const eu8 bytes)
static

Definition at line 301 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ set_uint32_be()

static void set_uint32_be ( eu8 ptr,
eu32  value 
)
static

Definition at line 312 of file pxsup2dast.c.

Referenced by png4file_close(), png4file_init(), png4file_open(), and xxfwrite_uint32_be().

◆ set_uint16_le()

static void set_uint16_le ( eu8 ptr,
eu16  value 
)
static

Definition at line 325 of file pxsup2dast.c.

Referenced by png4file_flush().

◆ xxfwrite_uint32_be()

static void xxfwrite_uint32_be ( FILE *  fh,
eu32  value 
)
static

Definition at line 330 of file pxsup2dast.c.

Referenced by png4file_close().

◆ ifopalette()

static void ifopalette ( const char *  filename,
eu8  yuvpalette[16][3],
eu8  rgbpalette[16][3] 
)
static

Definition at line 337 of file pxsup2dast.c.

Referenced by sup2dast().

◆ set2palettes()

static void set2palettes ( int  value,
eu8 yuvpalpart,
eu8 rgbpalpart 
)
static

Definition at line 368 of file pxsup2dast.c.

Referenced by argpalette().

◆ argpalette()

static void argpalette ( const char *  arg,
eu8  yuvpalette[16][3],
eu8  rgbpalette[16][3] 
)
static

Definition at line 382 of file pxsup2dast.c.

Referenced by sup2dast().

◆ png4file_init()

static void png4file_init ( Png4File self,
eu8  palette[4][3] 
)
static

Definition at line 416 of file pxsup2dast.c.

Referenced by makebitmap().

◆ png4file_open()

static void png4file_open ( Png4File self,
const char *  filename,
int  height,
int  width 
)
static

Definition at line 425 of file pxsup2dast.c.

Referenced by makebitmap().

◆ png4file_flush()

static void png4file_flush ( Png4File self)
static

Definition at line 458 of file pxsup2dast.c.

Referenced by png4file_addpixel(), and png4file_close().

◆ png4file_addpixel()

static void png4file_addpixel ( Png4File self,
eu8  pixel 
)
static

Definition at line 471 of file pxsup2dast.c.

Referenced by getpixelline().

◆ png4file_endrow()

static void png4file_endrow ( Png4File self)
static

Definition at line 484 of file pxsup2dast.c.

Referenced by getpixelline().

◆ png4file_close()

static void png4file_close ( Png4File self)
static

Definition at line 497 of file pxsup2dast.c.

Referenced by makebitmap().

◆ getnibble()

static eu8 getnibble ( eu8 **  data,
int *  nibble 
)
static

Definition at line 520 of file pxsup2dast.c.

Referenced by getpixelline().

◆ getpixelline()

static void getpixelline ( eu8 **  data,
int  width,
Png4File picfile 
)
static

Definition at line 534 of file pxsup2dast.c.

Referenced by makebitmap().

◆ makebitmap()

static void makebitmap ( eu8 data,
int  w,
int  h,
int  top,
int  bot,
char *  filename,
eu8  palette[4][3] 
)
static

Definition at line 593 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ pts2ts()

static char* pts2ts ( fu32  pts,
char *  rvbuf,
bool  is_png_filename 
)
static

Definition at line 612 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ boundstr_init()

static void boundstr_init ( BoundStr bs,
eu8 p,
int  l 
)
static

Definition at line 635 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ boundstr_read()

static eu8* boundstr_read ( BoundStr bs,
int  l 
)
static

Definition at line 641 of file pxsup2dast.c.

Referenced by pxsubtitle().

◆ pxsubtitle()

static void pxsubtitle ( const char *  supfile,
FILE *  ofh,
eu8  palette[16][3],
bool  createpics,
int  delay_ms,
char *  fnbuf,
char *  fnbuf_fp 
)
static

Definition at line 654 of file pxsup2dast.c.

Referenced by sup2dast().

◆ samepalette()

static bool samepalette ( char *  filename,
eu8  palette[16][3] 
)
static

Definition at line 864 of file pxsup2dast.c.

Referenced by sup2dast().

Variable Documentation

◆ m_last

struct exc__state* m_last

Definition at line 98 of file pxsup2dast.c.

◆ m_msgbuf

char m_msgbuf[1024]

Definition at line 99 of file pxsup2dast.c.

◆ m_buflen

int m_buflen

Definition at line 100 of file pxsup2dast.c.

◆ EXC

struct { ... } EXC

Referenced by __exc_throw(), exc_throw(), and sup2dast().

EXC
struct @87 EXC
exc__state
Definition: pxsup2dast.c:90
GCCATTR_UNUSED
#define GCCATTR_UNUSED
Definition: pxsup2dast.c:76