FFmpeg
Loading...
Searching...
No Matches
svq1dec.c File Reference

Sorenson Vector Quantizer #1 (SVQ1) video codec. More...

#include "libavutil/attributes.h"
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "h263data.h"
#include "hpeldsp.h"
#include "mathops.h"
#include "svq1.h"

Go to the source code of this file.

Data Structures

struct  svq1_pmv
 
struct  SVQ1Context
 

Macros

#define SVQ1_BLOCK_TYPE_VLC_BITS   3
 
#define SVQ1_PROCESS_VECTOR()
 
#define SVQ1_ADD_CODEBOOK()
 
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)
 

Functions

static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, ptrdiff_t pitch)
 
static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, ptrdiff_t pitch, int buggy)
 
static int svq1_decode_motion_vector (GetBitContext *bitbuf, svq1_pmv *mv, svq1_pmv **pmv)
 
static void svq1_skip_block (uint8_t *current, uint8_t *previous, ptrdiff_t pitch, int x, int y)
 
static int svq1_motion_inter_block (HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, ptrdiff_t pitch, svq1_pmv *motion, int x, int y, int width, int height)
 
static int svq1_motion_inter_4v_block (HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, ptrdiff_t pitch, svq1_pmv *motion, int x, int y, int width, int height)
 
static int svq1_decode_delta_block (AVCodecContext *avctx, HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, ptrdiff_t pitch, svq1_pmv *motion, int x, int y, int width, int height, int buggy)
 
static void svq1_parse_string (GetBitContext *bitbuf, uint8_t out[257])
 
static int svq1_decode_frame_header (AVCodecContext *avctx, AVFrame *frame, int *buggy)
 
static int svq1_decode_frame (AVCodecContext *avctx, AVFrame *cur, int *got_frame, AVPacket *avpkt)
 
static av_cold void svq1_static_init (void)
 
static av_cold int svq1_decode_init (AVCodecContext *avctx)
 
static av_cold int svq1_decode_end (AVCodecContext *avctx)
 
static av_cold void svq1_flush (AVCodecContext *avctx)
 

Variables

static VLCElem svq1_block_type [8]
 
static VLCElem svq1_motion_component [176]
 
static const VLCElemsvq1_intra_multistage [6]
 
static const VLCElemsvq1_inter_multistage [6]
 
static VLCElem svq1_intra_mean [632]
 
static VLCElem svq1_inter_mean [1434]
 
static const uint8_t string_table [256]
 
const FFCodec ff_svq1_decoder
 

Detailed Description

Sorenson Vector Quantizer #1 (SVQ1) video codec.

For more information of the SVQ1 algorithm, visit: http://www.pcisys.net/~melanson/codecs/

Definition in file svq1dec.c.

Macro Definition Documentation

◆ SVQ1_BLOCK_TYPE_VLC_BITS

#define SVQ1_BLOCK_TYPE_VLC_BITS   3

Definition at line 49 of file svq1dec.c.

Referenced by svq1_decode_delta_block(), and svq1_static_init().

◆ SVQ1_PROCESS_VECTOR

#define SVQ1_PROCESS_VECTOR ( )
Value:
for (; level > 0; i++) { \
/* process next depth */ \
if (i == m) { \
m = n; \
if (--level == 0) \
break; \
} \
/* divide block if next bit set */ \
if (!get_bits1(bitbuf)) \
break; \
/* add child nodes */ \
list[n++] = list[i]; \
list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level >> 1) + 1));\
}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
uint8_t level
Definition svq3.c:208

Definition at line 117 of file svq1dec.c.

Referenced by svq1_decode_block_intra(), and svq1_decode_block_non_intra().

◆ SVQ1_ADD_CODEBOOK

#define SVQ1_ADD_CODEBOOK ( )
Value:
/* add codebook entries to vector */ \
for (j = 0; j < stages; j++) { \
n3 = codebook[entries[j]] ^ 0x80808080; \
n1 += (n3 & 0xFF00FF00) >> 8; \
n2 += n3 & 0x00FF00FF; \
} \
\
/* clip to [0..255] */ \
if (n1 & 0xFF00FF00) { \
n3 = (n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n1 += 0x7F007F00; \
n1 |= (~n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n1 &= n3 & 0x00FF00FF; \
} \
\
if (n2 & 0xFF00FF00) { \
n3 = (n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n2 += 0x7F007F00; \
n2 |= (~n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n2 &= n3 & 0x00FF00FF; \
}
static const unsigned codebook[256][2]
Definition cfhdenc.c:41

Definition at line 133 of file svq1dec.c.

Referenced by svq1_decode_block_intra(), and svq1_decode_block_non_intra().

◆ SVQ1_CALC_CODEBOOK_ENTRIES

#define SVQ1_CALC_CODEBOOK_ENTRIES ( cbook)
Value:
codebook = (const uint32_t *)cbook[level]; \
if (stages > 0) \
bit_cache = get_bits(bitbuf, 4 * stages); \
/* calculate codebook entries for this vector */ \
for (j = 0; j < stages; j++) { \
entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) + \
16 * j) << (level + 1); \
} \
mean -= stages * 128; \
n4 = (mean << 16) + mean;
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
static float mean(const float *input, int size)
Definition vf_nnedi.c:861

Definition at line 156 of file svq1dec.c.

Referenced by svq1_decode_block_intra(), and svq1_decode_block_non_intra().

Function Documentation

◆ svq1_decode_block_intra()

static int svq1_decode_block_intra ( GetBitContext * bitbuf,
uint8_t * pixels,
ptrdiff_t pitch )
static

Definition at line 168 of file svq1dec.c.

Referenced by svq1_decode_delta_block(), and svq1_decode_frame().

◆ svq1_decode_block_non_intra()

static int svq1_decode_block_non_intra ( GetBitContext * bitbuf,
uint8_t * pixels,
ptrdiff_t pitch,
int buggy )
static

Definition at line 235 of file svq1dec.c.

Referenced by svq1_decode_delta_block().

◆ svq1_decode_motion_vector()

static int svq1_decode_motion_vector ( GetBitContext * bitbuf,
svq1_pmv * mv,
svq1_pmv ** pmv )
static

Definition at line 304 of file svq1dec.c.

Referenced by svq1_motion_inter_4v_block(), and svq1_motion_inter_block().

◆ svq1_skip_block()

static void svq1_skip_block ( uint8_t * current,
uint8_t * previous,
ptrdiff_t pitch,
int x,
int y )
static

Definition at line 330 of file svq1dec.c.

Referenced by svq1_decode_delta_block().

◆ svq1_motion_inter_block()

static int svq1_motion_inter_block ( HpelDSPContext * hdsp,
GetBitContext * bitbuf,
uint8_t * current,
uint8_t * previous,
ptrdiff_t pitch,
svq1_pmv * motion,
int x,
int y,
int width,
int height )
static

Definition at line 347 of file svq1dec.c.

Referenced by svq1_decode_delta_block().

◆ svq1_motion_inter_4v_block()

static int svq1_motion_inter_4v_block ( HpelDSPContext * hdsp,
GetBitContext * bitbuf,
uint8_t * current,
uint8_t * previous,
ptrdiff_t pitch,
svq1_pmv * motion,
int x,
int y,
int width,
int height )
static

Definition at line 390 of file svq1dec.c.

Referenced by svq1_decode_delta_block().

◆ svq1_decode_delta_block()

static int svq1_decode_delta_block ( AVCodecContext * avctx,
HpelDSPContext * hdsp,
GetBitContext * bitbuf,
uint8_t * current,
uint8_t * previous,
ptrdiff_t pitch,
svq1_pmv * motion,
int x,
int y,
int width,
int height,
int buggy )
static

Definition at line 467 of file svq1dec.c.

Referenced by svq1_decode_frame().

◆ svq1_parse_string()

static void svq1_parse_string ( GetBitContext * bitbuf,
uint8_t out[257] )
static

Definition at line 525 of file svq1dec.c.

Referenced by svq1_decode_frame_header().

◆ svq1_decode_frame_header()

static int svq1_decode_frame_header ( AVCodecContext * avctx,
AVFrame * frame,
int * buggy )
static

Definition at line 540 of file svq1dec.c.

Referenced by svq1_decode_frame().

◆ svq1_decode_frame()

static int svq1_decode_frame ( AVCodecContext * avctx,
AVFrame * cur,
int * got_frame,
AVPacket * avpkt )
static

Definition at line 637 of file svq1dec.c.

◆ svq1_static_init()

static av_cold void svq1_static_init ( void )
static

Definition at line 788 of file svq1dec.c.

Referenced by svq1_decode_init().

◆ svq1_decode_init()

static av_cold int svq1_decode_init ( AVCodecContext * avctx)
static

Definition at line 821 of file svq1dec.c.

◆ svq1_decode_end()

static av_cold int svq1_decode_end ( AVCodecContext * avctx)
static

Definition at line 843 of file svq1dec.c.

◆ svq1_flush()

static av_cold void svq1_flush ( AVCodecContext * avctx)
static

Definition at line 856 of file svq1dec.c.

Variable Documentation

◆ svq1_block_type

VLCElem svq1_block_type[8]
static

Definition at line 50 of file svq1dec.c.

Referenced by svq1_decode_delta_block(), and svq1_static_init().

◆ svq1_motion_component

VLCElem svq1_motion_component[176]
static

Definition at line 51 of file svq1dec.c.

Referenced by svq1_decode_motion_vector(), and svq1_static_init().

◆ svq1_intra_multistage

const VLCElem* svq1_intra_multistage[6]
static

Definition at line 52 of file svq1dec.c.

Referenced by svq1_decode_block_intra(), and svq1_static_init().

◆ svq1_inter_multistage

const VLCElem* svq1_inter_multistage[6]
static

Definition at line 53 of file svq1dec.c.

Referenced by svq1_decode_block_non_intra(), and svq1_static_init().

◆ svq1_intra_mean

VLCElem svq1_intra_mean[632]
static

Definition at line 54 of file svq1dec.c.

Referenced by svq1_decode_block_intra(), and svq1_static_init().

◆ svq1_inter_mean

VLCElem svq1_inter_mean[1434]
static

Definition at line 55 of file svq1dec.c.

Referenced by svq1_decode_block_non_intra(), and svq1_static_init().

◆ string_table

const uint8_t string_table[256]
static

Definition at line 82 of file svq1dec.c.

Referenced by svq1_parse_string().

◆ ff_svq1_decoder

const FFCodec ff_svq1_decoder
Initial value:
= {
.p.name = "svq1",
CODEC_LONG_NAME("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(SVQ1Context),
.p.capabilities = AV_CODEC_CAP_DR1,
.flush = svq1_flush,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_SVQ1
Definition codec_id.h:72
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold int svq1_decode_end(AVCodecContext *avctx)
Definition svq1dec.c:843
static av_cold int svq1_decode_init(AVCodecContext *avctx)
Definition svq1dec.c:821
static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur, int *got_frame, AVPacket *avpkt)
Definition svq1dec.c:637
static av_cold void svq1_flush(AVCodecContext *avctx)
Definition svq1dec.c:856

Definition at line 863 of file svq1dec.c.