FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
lagarith.c File Reference
#include <inttypes.h>
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "get_bits.h"
#include "mathops.h"
#include "lagarithrac.h"
#include "lossless_videodsp.h"
#include "thread.h"

Go to the source code of this file.

Data Structures

struct  LagarithContext
 

Macros

#define VLC_BITS   7
 

Enumerations

enum  LagarithFrameType {
  FRAME_RAW = 1, FRAME_U_RGB24 = 2, FRAME_ARITH_YUY2 = 3, FRAME_ARITH_RGB24 = 4,
  FRAME_SOLID_GRAY = 5, FRAME_SOLID_COLOR = 6, FRAME_OLD_ARITH_RGB = 7, FRAME_ARITH_RGBA = 8,
  FRAME_SOLID_RGBA = 9, FRAME_ARITH_YV12 = 10, FRAME_REDUCED_RES = 11
}
 

Functions

static av_cold void lag_init_static_data (void)
 
static uint64_t softfloat_reciprocal (uint32_t denom)
 Compute the 52-bit mantissa of 1/(double)denom. More...
 
static uint32_t softfloat_mul (uint32_t x, uint64_t mantissa)
 (uint32_t)(x*f), where f has the given mantissa, and exponent 0 Used in combination with softfloat_reciprocal computes x/(double)denom. More...
 
static uint8_t lag_calc_zero_run (int8_t x)
 
static int lag_decode_prob (GetBitContext *gb, uint32_t *value)
 
static int lag_read_prob_header (lag_rac *rac, GetBitContext *gb)
 
static void add_lag_median_prediction (uint8_t *dst, uint8_t *src1, uint8_t *diff, int w, int *left, int *left_top)
 
static void lag_pred_line (LagarithContext *l, uint8_t *buf, int width, int stride, int line)
 
static void lag_pred_line_yuy2 (LagarithContext *l, uint8_t *buf, int width, int stride, int line, int is_luma)
 
static int lag_decode_line (LagarithContext *l, lag_rac *rac, uint8_t *dst, int width, int stride, int esc_count)
 
static int lag_decode_zero_run_line (LagarithContext *l, uint8_t *dst, const uint8_t *src, const uint8_t *src_end, int width, int esc_count)
 
static int lag_decode_arith_plane (LagarithContext *l, uint8_t *dst, int width, int height, int stride, const uint8_t *src, int src_size)
 
static int lag_decode_frame (AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
 Decode a frame. More...
 
static av_cold int lag_decode_init (AVCodecContext *avctx)
 

Variables

static VLCElem lag_tab [1<< VLC_BITS]
 
static const uint8_t lag_bits []
 
static const uint8_t lag_codes []
 
static const uint8_t lag_symbols []
 
const FFCodec ff_lagarith_decoder
 

Detailed Description

Lagarith lossless decoder

Author
Nathan Caldwell

Definition in file lagarith.c.

Macro Definition Documentation

◆ VLC_BITS

#define VLC_BITS   7

Definition at line 40 of file lagarith.c.

Enumeration Type Documentation

◆ LagarithFrameType

Enumerator
FRAME_RAW 

uncompressed

FRAME_U_RGB24 

unaligned RGB24

FRAME_ARITH_YUY2 

arithmetic coded YUY2

FRAME_ARITH_RGB24 

arithmetic coded RGB24

FRAME_SOLID_GRAY 

solid grayscale color frame

FRAME_SOLID_COLOR 

solid non-grayscale color frame

FRAME_OLD_ARITH_RGB 

obsolete arithmetic coded RGB (no longer encoded by upstream since version 1.1.0)

FRAME_ARITH_RGBA 

arithmetic coded RGBA

FRAME_SOLID_RGBA 

solid RGBA color frame

FRAME_ARITH_YV12 

arithmetic coded YV12

FRAME_REDUCED_RES 

reduced resolution YV12 frame

Definition at line 42 of file lagarith.c.

Function Documentation

◆ lag_init_static_data()

static av_cold void lag_init_static_data ( void  )
static

Definition at line 86 of file lagarith.c.

Referenced by lag_decode_init().

◆ softfloat_reciprocal()

static uint64_t softfloat_reciprocal ( uint32_t  denom)
static

Compute the 52-bit mantissa of 1/(double)denom.

This crazy format uses floats in an entropy coder and we have to match x86 rounding exactly, thus ordinary floats aren't portable enough.

Parameters
denomdenominator
Returns
52-bit mantissa
See also
softfloat_mul

Definition at line 100 of file lagarith.c.

Referenced by lag_read_prob_header().

◆ softfloat_mul()

static uint32_t softfloat_mul ( uint32_t  x,
uint64_t  mantissa 
)
static

(uint32_t)(x*f), where f has the given mantissa, and exponent 0 Used in combination with softfloat_reciprocal computes x/(double)denom.

Parameters
x32-bit integer factor
mantissamantissa of f with exponent 0
Returns
32-bit integer value (x*f)
See also
softfloat_reciprocal

Definition at line 119 of file lagarith.c.

Referenced by lag_read_prob_header().

◆ lag_calc_zero_run()

static uint8_t lag_calc_zero_run ( int8_t  x)
static

Definition at line 130 of file lagarith.c.

Referenced by lag_decode_line(), and lag_decode_zero_run_line().

◆ lag_decode_prob()

static int lag_decode_prob ( GetBitContext gb,
uint32_t *  value 
)
static

Definition at line 135 of file lagarith.c.

Referenced by lag_read_prob_header().

◆ lag_read_prob_header()

static int lag_read_prob_header ( lag_rac rac,
GetBitContext gb 
)
static

Definition at line 156 of file lagarith.c.

Referenced by lag_decode_arith_plane().

◆ add_lag_median_prediction()

static void add_lag_median_prediction ( uint8_t *  dst,
uint8_t *  src1,
uint8_t *  diff,
int  w,
int *  left,
int *  left_top 
)
static

Definition at line 262 of file lagarith.c.

Referenced by lag_pred_line().

◆ lag_pred_line()

static void lag_pred_line ( LagarithContext l,
uint8_t *  buf,
int  width,
int  stride,
int  line 
)
static

Definition at line 286 of file lagarith.c.

Referenced by lag_decode_arith_plane().

◆ lag_pred_line_yuy2()

static void lag_pred_line_yuy2 ( LagarithContext l,
uint8_t *  buf,
int  width,
int  stride,
int  line,
int  is_luma 
)
static

Definition at line 312 of file lagarith.c.

Referenced by lag_decode_arith_plane().

◆ lag_decode_line()

static int lag_decode_line ( LagarithContext l,
lag_rac rac,
uint8_t *  dst,
int  width,
int  stride,
int  esc_count 
)
static

Definition at line 349 of file lagarith.c.

Referenced by lag_decode_arith_plane().

◆ lag_decode_zero_run_line()

static int lag_decode_zero_run_line ( LagarithContext l,
uint8_t *  dst,
const uint8_t *  src,
const uint8_t *  src_end,
int  width,
int  esc_count 
)
static

Definition at line 391 of file lagarith.c.

Referenced by lag_decode_arith_plane().

◆ lag_decode_arith_plane()

static int lag_decode_arith_plane ( LagarithContext l,
uint8_t *  dst,
int  width,
int  height,
int  stride,
const uint8_t *  src,
int  src_size 
)
static

Definition at line 452 of file lagarith.c.

Referenced by lag_decode_frame().

◆ lag_decode_frame()

static int lag_decode_frame ( AVCodecContext avctx,
AVFrame p,
int *  got_frame,
AVPacket avpkt 
)
static

Decode a frame.

Parameters
avctxcodec context
dataoutput AVFrame
data_sizesize of output data or 0 if no picture is returned
avpktinput packet
Returns
number of consumed bytes on success or negative if decode fails

Definition at line 560 of file lagarith.c.

◆ lag_decode_init()

static av_cold int lag_decode_init ( AVCodecContext avctx)
static

Definition at line 738 of file lagarith.c.

Variable Documentation

◆ lag_tab

VLCElem lag_tab[1<< VLC_BITS]
static

Definition at line 63 of file lagarith.c.

Referenced by lag_decode_prob(), and lag_init_static_data().

◆ lag_bits

const uint8_t lag_bits[]
static
Initial value:
= {
7, 7, 2, 7, 3, 4, 5, 6, 7, 7, 7, 7, 7, 6, 7, 4, 5, 7, 7, 7, 7,
5, 6, 7, 7, 7, 7, 7, 7, 6, 7, 7, 7, 7, 7, 6, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
}

Definition at line 65 of file lagarith.c.

Referenced by lag_init_static_data().

◆ lag_codes

const uint8_t lag_codes[]
static
Initial value:
= {
0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05,
0x08, 0x09, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x10, 0x11, 0x12, 0x13,
0x13, 0x13, 0x14, 0x15, 0x20, 0x21, 0x22, 0x23, 0x23, 0x24, 0x25,
0x28, 0x29, 0x2A, 0x2B, 0x2B, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
0x48, 0x49, 0x4A, 0x4B, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
}

Definition at line 71 of file lagarith.c.

Referenced by lag_init_static_data().

◆ lag_symbols

const uint8_t lag_symbols[]
static
Initial value:
= {
20, 12, 0, 12, 1, 2, 4, 7, 7, 28, 4, 25, 17,
10, 17, 3, 6, 2, 23, 15, 15, 5, 9, 10, 31, 1, 22,
14, 14, 8, 9, 30, 6, 27, 19, 11, 19, 0, 21, 13, 13,
8, 29, 5, 26, 18, 18, 3, 24, 16, 16, 11, 32,
}

Definition at line 79 of file lagarith.c.

Referenced by lag_init_static_data().

◆ ff_lagarith_decoder

const FFCodec ff_lagarith_decoder
Initial value:
= {
.p.name = "lagarith",
CODEC_LONG_NAME("Lagarith lossless"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(LagarithContext),
}

Definition at line 750 of file lagarith.c.

AV_CODEC_ID_LAGARITH
@ AV_CODEC_ID_LAGARITH
Definition: codec_id.h:199
lag_decode_init
static av_cold int lag_decode_init(AVCodecContext *avctx)
Definition: lagarith.c:738
lag_decode_frame
static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Decode a frame.
Definition: lagarith.c:560
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
LagarithContext
Definition: lagarith.c:56
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201