FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Enumerations | Functions | Variables
lagarith.c File Reference

Lagarith lossless decoder. More...

#include <inttypes.h>
#include "avcodec.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
 

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 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, void *data, int *got_frame, AVPacket *avpkt)
 Decode a frame. More...
 
static av_cold int lag_decode_init (AVCodecContext *avctx)
 
static av_cold int lag_decode_end (AVCodecContext *avctx)
 

Variables

AVCodec ff_lagarith_decoder
 

Detailed Description

Lagarith lossless decoder.

Author
Nathan Caldwell

Definition in file lagarith.c.

Enumeration Type Documentation

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 37 of file lagarith.c.

Function Documentation

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 69 of file lagarith.c.

Referenced by lag_read_prob_header().

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 88 of file lagarith.c.

Referenced by lag_read_prob_header().

static uint8_t lag_calc_zero_run ( int8_t  x)
static

Definition at line 99 of file lagarith.c.

Referenced by lag_decode_line(), and lag_decode_zero_run_line().

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

Definition at line 104 of file lagarith.c.

Referenced by lag_read_prob_header().

static int lag_read_prob_header ( lag_rac rac,
GetBitContext gb 
)
static

Definition at line 138 of file lagarith.c.

Referenced by lag_decode_arith_plane().

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 234 of file lagarith.c.

Referenced by lag_pred_line().

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

Definition at line 258 of file lagarith.c.

Referenced by lag_decode_arith_plane().

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

Definition at line 284 of file lagarith.c.

Referenced by lag_decode_arith_plane().

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

Definition at line 321 of file lagarith.c.

Referenced by lag_decode_arith_plane().

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 363 of file lagarith.c.

Referenced by 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 421 of file lagarith.c.

Referenced by lag_decode_frame().

static int lag_decode_frame ( AVCodecContext avctx,
void data,
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 529 of file lagarith.c.

static av_cold int lag_decode_init ( AVCodecContext avctx)
static

Definition at line 727 of file lagarith.c.

static av_cold int lag_decode_end ( AVCodecContext avctx)
static

Definition at line 747 of file lagarith.c.

Variable Documentation

AVCodec ff_lagarith_decoder
Initial value:
= {
.name = "lagarith",
.long_name = NULL_IF_CONFIG_SMALL("Lagarith lossless"),
.priv_data_size = sizeof(LagarithContext),
.init_thread_copy = ONLY_IF_THREADS_ENABLED(lag_decode_init_thread_copy),
.close = lag_decode_end,
.decode = lag_decode_frame,
}
static int init_thread_copy(AVCodecContext *avctx)
Definition: tta.c:392
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1015
static av_cold int lag_decode_init(AVCodecContext *avctx)
Definition: lagarith.c:727
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:225
static int lag_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Decode a frame.
Definition: lagarith.c:529
static av_cold int lag_decode_end(AVCodecContext *avctx)
Definition: lagarith.c:747
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

Definition at line 756 of file lagarith.c.