FFmpeg
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
sanm.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/bswap.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "copy_block.h"
#include "codec_internal.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SANMVideoContext
 
struct  SANMFrameHeader
 

Macros

#define NGLYPHS   256
 
#define GLYPH_COORD_VECT_SIZE   16
 
#define PALETTE_SIZE   256
 
#define PALETTE_DELTA   768
 

Typedefs

typedef int(* frm_decoder) (SANMVideoContext *ctx)
 

Enumerations

enum  GlyphEdge {
  LEFT_EDGE, TOP_EDGE, RIGHT_EDGE, BOTTOM_EDGE,
  NO_EDGE
}
 
enum  GlyphDir {
  DIR_LEFT, DIR_UP, DIR_RIGHT, DIR_DOWN,
  NO_DIR
}
 

Functions

static enum GlyphEdge which_edge (int x, int y, int edge_size)
 Return enum GlyphEdge of box where point (x, y) lies. More...
 
static enum GlyphDir which_direction (enum GlyphEdge edge0, enum GlyphEdge edge1)
 
static void interp_point (int8_t *points, int x0, int y0, int x1, int y1, int pos, int npoints)
 
static void make_glyphs (int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec, const int side_length)
 Construct glyphs by iterating through vector coordinates. More...
 
static void init_sizes (SANMVideoContext *ctx, int width, int height)
 
static void destroy_buffers (SANMVideoContext *ctx)
 
static av_cold int init_buffers (SANMVideoContext *ctx)
 
static void rotate_bufs (SANMVideoContext *ctx, int rotate_code)
 
static av_cold int decode_init (AVCodecContext *avctx)
 
static av_cold int decode_end (AVCodecContext *avctx)
 
static int rle_decode (SANMVideoContext *ctx, uint8_t *dst, const int out_size)
 
static int old_codec1 (SANMVideoContext *ctx, int top, int left, int width, int height)
 
static void codec37_mv (uint8_t *dst, const uint8_t *src, int height, int stride, int x, int y)
 
static int old_codec37 (SANMVideoContext *ctx, int top, int left, int width, int height)
 
static int process_block (SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, uint8_t *prev2, int stride, int tbl, int size)
 
static int old_codec47 (SANMVideoContext *ctx, int top, int left, int width, int height)
 
static int process_frame_obj (SANMVideoContext *ctx)
 
static int decode_0 (SANMVideoContext *ctx)
 
static int decode_nop (SANMVideoContext *ctx)
 
static void copy_block (uint16_t *pdest, uint16_t *psrc, int block_size, ptrdiff_t pitch)
 
static void fill_block (uint16_t *pdest, uint16_t color, int block_size, ptrdiff_t pitch)
 
static int draw_glyph (SANMVideoContext *ctx, uint16_t *dst, int index, uint16_t fg_color, uint16_t bg_color, int block_size, ptrdiff_t pitch)
 
static int opcode_0xf7 (SANMVideoContext *ctx, int cx, int cy, int block_size, ptrdiff_t pitch)
 
static int opcode_0xf8 (SANMVideoContext *ctx, int cx, int cy, int block_size, ptrdiff_t pitch)
 
static int good_mvec (SANMVideoContext *ctx, int cx, int cy, int mx, int my, int block_size)
 
static int codec2subblock (SANMVideoContext *ctx, int cx, int cy, int blk_size)
 
static int decode_2 (SANMVideoContext *ctx)
 
static int decode_3 (SANMVideoContext *ctx)
 
static int decode_4 (SANMVideoContext *ctx)
 
static int decode_5 (SANMVideoContext *ctx)
 
static int decode_6 (SANMVideoContext *ctx)
 
static int decode_8 (SANMVideoContext *ctx)
 
static int read_frame_header (SANMVideoContext *ctx, SANMFrameHeader *hdr)
 
static void fill_frame (uint16_t *pbuf, int buf_size, uint16_t color)
 
static int copy_output (SANMVideoContext *ctx, SANMFrameHeader *hdr)
 
static int decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
 

Variables

static const int8_t glyph4_x [GLYPH_COORD_VECT_SIZE]
 
static const int8_t glyph4_y [GLYPH_COORD_VECT_SIZE]
 
static const int8_t glyph8_x [GLYPH_COORD_VECT_SIZE]
 
static const int8_t glyph8_y [GLYPH_COORD_VECT_SIZE]
 
static const int8_t motion_vectors [256][2]
 
static const int8_t c37_mv []
 
static const frm_decoder v1_decoders []
 
const FFCodec ff_sanm_decoder
 

Macro Definition Documentation

◆ NGLYPHS

#define NGLYPHS   256

Definition at line 33 of file sanm.c.

◆ GLYPH_COORD_VECT_SIZE

#define GLYPH_COORD_VECT_SIZE   16

Definition at line 34 of file sanm.c.

◆ PALETTE_SIZE

#define PALETTE_SIZE   256

Definition at line 35 of file sanm.c.

◆ PALETTE_DELTA

#define PALETTE_DELTA   768

Definition at line 36 of file sanm.c.

Typedef Documentation

◆ frm_decoder

typedef int(* frm_decoder) (SANMVideoContext *ctx)

Definition at line 1313 of file sanm.c.

Enumeration Type Documentation

◆ GlyphEdge

enum GlyphEdge
Enumerator
LEFT_EDGE 
TOP_EDGE 
RIGHT_EDGE 
BOTTOM_EDGE 
NO_EDGE 

Definition at line 304 of file sanm.c.

◆ GlyphDir

enum GlyphDir
Enumerator
DIR_LEFT 
DIR_UP 
DIR_RIGHT 
DIR_DOWN 
NO_DIR 

Definition at line 312 of file sanm.c.

Function Documentation

◆ which_edge()

static enum GlyphEdge which_edge ( int  x,
int  y,
int  edge_size 
)
static

Return enum GlyphEdge of box where point (x, y) lies.

Parameters
xx point coordinate
yy point coordinate
edge_sizebox width/height.

Definition at line 327 of file sanm.c.

Referenced by make_glyphs().

◆ which_direction()

static enum GlyphDir which_direction ( enum GlyphEdge  edge0,
enum GlyphEdge  edge1 
)
static

Definition at line 343 of file sanm.c.

Referenced by make_glyphs().

◆ interp_point()

static void interp_point ( int8_t *  points,
int  x0,
int  y0,
int  x1,
int  y1,
int  pos,
int  npoints 
)
static

Definition at line 366 of file sanm.c.

Referenced by make_glyphs().

◆ make_glyphs()

static void make_glyphs ( int8_t *  pglyphs,
const int8_t *  xvec,
const int8_t *  yvec,
const int  side_length 
)
static

Construct glyphs by iterating through vector coordinates.

Parameters
pglyphspointer to table where glyphs are stored
xvecpointer to x component of vector coordinates
yvecpointer to y component of vector coordinates
side_lengthglyph width/height.

Definition at line 386 of file sanm.c.

Referenced by decode_init().

◆ init_sizes()

static void init_sizes ( SANMVideoContext ctx,
int  width,
int  height 
)
static

Definition at line 438 of file sanm.c.

Referenced by decode_init(), destroy_buffers(), and process_frame_obj().

◆ destroy_buffers()

static void destroy_buffers ( SANMVideoContext ctx)
static

Definition at line 451 of file sanm.c.

Referenced by decode_end(), and init_buffers().

◆ init_buffers()

static av_cold int init_buffers ( SANMVideoContext ctx)
static

Definition at line 464 of file sanm.c.

Referenced by decode_init(), and process_frame_obj().

◆ rotate_bufs()

static void rotate_bufs ( SANMVideoContext ctx,
int  rotate_code 
)
static

Definition at line 482 of file sanm.c.

Referenced by decode_frame(), and old_codec37().

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 489 of file sanm.c.

◆ decode_end()

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 523 of file sanm.c.

◆ rle_decode()

static int rle_decode ( SANMVideoContext ctx,
uint8_t *  dst,
const int  out_size 
)
static

Definition at line 532 of file sanm.c.

Referenced by decode_5(), decode_8(), old_codec37(), and old_codec47().

◆ old_codec1()

static int old_codec1 ( SANMVideoContext ctx,
int  top,
int  left,
int  width,
int  height 
)
static

Definition at line 558 of file sanm.c.

Referenced by process_frame_obj().

◆ codec37_mv()

static void codec37_mv ( uint8_t *  dst,
const uint8_t *  src,
int  height,
int  stride,
int  x,
int  y 
)
inlinestatic

Definition at line 605 of file sanm.c.

Referenced by old_codec37().

◆ old_codec37()

static int old_codec37 ( SANMVideoContext ctx,
int  top,
int  left,
int  width,
int  height 
)
static

Definition at line 624 of file sanm.c.

Referenced by process_frame_obj().

◆ process_block()

static int process_block ( SANMVideoContext ctx,
uint8_t *  dst,
uint8_t *  prev1,
uint8_t *  prev2,
int  stride,
int  tbl,
int  size 
)
static

Definition at line 770 of file sanm.c.

Referenced by old_codec47().

◆ old_codec47()

static int old_codec47 ( SANMVideoContext ctx,
int  top,
int  left,
int  width,
int  height 
)
static

Definition at line 860 of file sanm.c.

Referenced by process_frame_obj().

◆ process_frame_obj()

static int process_frame_obj ( SANMVideoContext ctx)
static

Definition at line 951 of file sanm.c.

Referenced by decode_frame().

◆ decode_0()

static int decode_0 ( SANMVideoContext ctx)
static

Definition at line 992 of file sanm.c.

◆ decode_nop()

static int decode_nop ( SANMVideoContext ctx)
static

Definition at line 1009 of file sanm.c.

◆ copy_block()

static void copy_block ( uint16_t *  pdest,
uint16_t *  psrc,
int  block_size,
ptrdiff_t  pitch 
)
static

Definition at line 1015 of file sanm.c.

Referenced by codec2subblock().

◆ fill_block()

static void fill_block ( uint16_t *  pdest,
uint16_t  color,
int  block_size,
ptrdiff_t  pitch 
)
static

Definition at line 1034 of file sanm.c.

Referenced by codec2subblock().

◆ draw_glyph()

static int draw_glyph ( SANMVideoContext ctx,
uint16_t *  dst,
int  index,
uint16_t  fg_color,
uint16_t  bg_color,
int  block_size,
ptrdiff_t  pitch 
)
static

Definition at line 1044 of file sanm.c.

Referenced by opcode_0xf7(), and opcode_0xf8().

◆ opcode_0xf7()

static int opcode_0xf7 ( SANMVideoContext ctx,
int  cx,
int  cy,
int  block_size,
ptrdiff_t  pitch 
)
static

Definition at line 1066 of file sanm.c.

Referenced by codec2subblock().

◆ opcode_0xf8()

static int opcode_0xf8 ( SANMVideoContext ctx,
int  cx,
int  cy,
int  block_size,
ptrdiff_t  pitch 
)
static

Definition at line 1100 of file sanm.c.

Referenced by codec2subblock().

◆ good_mvec()

static int good_mvec ( SANMVideoContext ctx,
int  cx,
int  cy,
int  mx,
int  my,
int  block_size 
)
static

Definition at line 1128 of file sanm.c.

Referenced by codec2subblock().

◆ codec2subblock()

static int codec2subblock ( SANMVideoContext ctx,
int  cx,
int  cy,
int  blk_size 
)
static

Definition at line 1144 of file sanm.c.

Referenced by decode_2().

◆ decode_2()

static int decode_2 ( SANMVideoContext ctx)
static

Definition at line 1229 of file sanm.c.

◆ decode_3()

static int decode_3 ( SANMVideoContext ctx)
static

Definition at line 1241 of file sanm.c.

◆ decode_4()

static int decode_4 ( SANMVideoContext ctx)
static

Definition at line 1247 of file sanm.c.

◆ decode_5()

static int decode_5 ( SANMVideoContext ctx)
static

Definition at line 1253 of file sanm.c.

◆ decode_6()

static int decode_6 ( SANMVideoContext ctx)
static

Definition at line 1276 of file sanm.c.

◆ decode_8()

static int decode_8 ( SANMVideoContext ctx)
static

Definition at line 1291 of file sanm.c.

◆ read_frame_header()

static int read_frame_header ( SANMVideoContext ctx,
SANMFrameHeader hdr 
)
static

Definition at line 1320 of file sanm.c.

Referenced by decode_frame().

◆ fill_frame()

static void fill_frame ( uint16_t *  pbuf,
int  buf_size,
uint16_t  color 
)
static

Definition at line 1360 of file sanm.c.

Referenced by decode_frame().

◆ copy_output()

static int copy_output ( SANMVideoContext ctx,
SANMFrameHeader hdr 
)
static

Definition at line 1368 of file sanm.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame_ptr,
AVPacket pkt 
)
static

Definition at line 1390 of file sanm.c.

Variable Documentation

◆ glyph4_x

const int8_t glyph4_x[GLYPH_COORD_VECT_SIZE]
static
Initial value:
= {
0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1
}

Definition at line 38 of file sanm.c.

Referenced by decode_init().

◆ glyph4_y

const int8_t glyph4_y[GLYPH_COORD_VECT_SIZE]
static
Initial value:
= {
0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2
}

Definition at line 42 of file sanm.c.

Referenced by decode_init().

◆ glyph8_x

const int8_t glyph8_x[GLYPH_COORD_VECT_SIZE]
static
Initial value:
= {
0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0
}

Definition at line 46 of file sanm.c.

Referenced by decode_init().

◆ glyph8_y

const int8_t glyph8_y[GLYPH_COORD_VECT_SIZE]
static
Initial value:
= {
0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1
}

Definition at line 50 of file sanm.c.

Referenced by decode_init().

◆ motion_vectors

const int8_t motion_vectors[256][2]
static

Definition at line 54 of file sanm.c.

Referenced by codec2subblock(), and process_block().

◆ c37_mv

const int8_t c37_mv[]
static

Definition at line 108 of file sanm.c.

Referenced by old_codec37().

◆ v1_decoders

const frm_decoder v1_decoders[]
static
Initial value:

Definition at line 1315 of file sanm.c.

Referenced by decode_frame().

◆ ff_sanm_decoder

const FFCodec ff_sanm_decoder
Initial value:
= {
.p.name = "sanm",
.p.long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/Smush video"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(SANMVideoContext),
.close = decode_end,
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 1519 of file sanm.c.

AV_CODEC_ID_SANM
@ AV_CODEC_ID_SANM
Definition: codec_id.h:232
decode_0
static int decode_0(SANMVideoContext *ctx)
Definition: sanm.c:992
decode_5
static int decode_5(SANMVideoContext *ctx)
Definition: sanm.c:1253
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: sanm.c:523
decode_3
static int decode_3(SANMVideoContext *ctx)
Definition: sanm.c:1241
init
static int init
Definition: av_tx.c:47
decode_2
static int decode_2(SANMVideoContext *ctx)
Definition: sanm.c:1229
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:254
decode_6
static int decode_6(SANMVideoContext *ctx)
Definition: sanm.c:1276
decode_nop
static int decode_nop(SANMVideoContext *ctx)
Definition: sanm.c:1009
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:116
SANMVideoContext
Definition: sanm.c:264
decode_4
static int decode_4(SANMVideoContext *ctx)
Definition: sanm.c:1247
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: sanm.c:489
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: codec_internal.h:31
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
decode_8
static int decode_8(SANMVideoContext *ctx)
Definition: sanm.c:1291
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
Definition: sanm.c:1390