hvirtual/quicktime/ffmpeg/libavcodec/svq1.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "common.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "bswap.h"
#include <assert.h>
#include "svq1_cb.h"
#include "svq1_vlc.h"

Include dependency graph for svq1.c:

Go to the source code of this file.

Data Structures

struct  SVQ1Context
struct  svq1_pmv_s

Defines

#define SVQ1_BLOCK_SKIP   0
#define SVQ1_BLOCK_INTER   1
#define SVQ1_BLOCK_INTER_4V   2
#define SVQ1_BLOCK_INTRA   3
#define SVQ1_PROCESS_VECTOR()
#define SVQ1_ADD_CODEBOOK()
#define SVQ1_DO_CODEBOOK_INTRA()
#define SVQ1_DO_CODEBOOK_NONINTRA()
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)
#define QUALITY_THRESHOLD   100
#define THRESHOLD_MULTIPLIER   0.6

Typedefs

typedef struct svq1_pmv_s svq1_pmv_t

Functions

static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch)
static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch)
static int svq1_decode_motion_vector (GetBitContext *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv)
static void svq1_skip_block (uint8_t *current, uint8_t *previous, int pitch, int x, int y)
static int svq1_motion_inter_block (MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv_t *motion, int x, int y)
static int svq1_motion_inter_4v_block (MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv_t *motion, int x, int y)
static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv_t *motion, int x, int y)
static uint16_t svq1_packet_checksum (uint8_t *data, int length, int value)
static void svq1_parse_string (GetBitContext *bitbuf, uint8_t *out)
static int svq1_decode_frame_header (GetBitContext *bitbuf, MpegEncContext *s)
static int svq1_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
static int svq1_decode_init (AVCodecContext *avctx)
static int svq1_decode_end (AVCodecContext *avctx)
static void svq1_write_header (SVQ1Context *s, int frame_type)
static int encode_block (SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *decoded, int stride, int level, int threshold, int lambda, int intra)

Variables

const uint8_t mvtab [33][2]
static VLC svq1_block_type
static VLC svq1_motion_component
static VLC svq1_intra_multistage [6]
static VLC svq1_inter_multistage [6]
static VLC svq1_intra_mean
static VLC svq1_inter_mean
static const uint16_t checksum_table [256]
static const uint8_t string_table [256]
struct {
   int   width
   int   height
svq1_frame_size_table [8]
AVCodec 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 svq1.c.


Define Documentation

#define QUALITY_THRESHOLD   100

Definition at line 928 of file svq1.c.

 
#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);\
          }

Definition at line 191 of file svq1.c.

#define SVQ1_BLOCK_INTER   1

Definition at line 61 of file svq1.c.

Referenced by svq1_decode_delta_block().

#define SVQ1_BLOCK_INTER_4V   2

Definition at line 62 of file svq1.c.

Referenced by svq1_decode_delta_block().

#define SVQ1_BLOCK_INTRA   3

Definition at line 63 of file svq1.c.

Referenced by svq1_decode_delta_block().

#define SVQ1_BLOCK_SKIP   0

Definition at line 60 of file svq1.c.

Referenced by svq1_decode_delta_block().

#define SVQ1_CALC_CODEBOOK_ENTRIES ( cbook   ) 

Value:

codebook = (const uint32_t *) cbook[level];\
      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 + (mean >> 31)) << 16) | (mean & 0xFFFF);

Definition at line 240 of file svq1.c.

Referenced by svq1_decode_block_intra(), and svq1_decode_block_non_intra().

 
#define SVQ1_DO_CODEBOOK_INTRA (  ) 

Value:

for (y=0; y < height; y++) {\
        for (x=0; x < (width / 4); x++, codebook++) {\
        n1 = n4;\
        n2 = n4;\
        SVQ1_ADD_CODEBOOK()\
        /* store result */\
        dst[x] = (n1 << 8) | n2;\
        }\
        dst += (pitch / 4);\
      }

Definition at line 214 of file svq1.c.

Referenced by svq1_decode_block_intra().

 
#define SVQ1_DO_CODEBOOK_NONINTRA (  ) 

Value:

for (y=0; y < height; y++) {\
        for (x=0; x < (width / 4); x++, codebook++) {\
        n3 = dst[x];\
        /* add mean value to vector */\
        n1 = ((n3 & 0xFF00FF00) >> 8) + n4;\
        n2 =  (n3 & 0x00FF00FF)   + n4;\
        SVQ1_ADD_CODEBOOK()\
        /* store result */\
        dst[x] = (n1 << 8) | n2;\
        }\
        dst += (pitch / 4);\
      }

Definition at line 226 of file svq1.c.

Referenced by svq1_decode_block_non_intra().

 
#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_bits (bitbuf, 1) == 0)\
        break;\
      /* add child nodes */\
      list[n++] = list[i];\
      list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1));\
    }

Definition at line 175 of file svq1.c.

Referenced by svq1_decode_block_intra(), and svq1_decode_block_non_intra().

#define THRESHOLD_MULTIPLIER   0.6

Definition at line 929 of file svq1.c.


Typedef Documentation

typedef struct svq1_pmv_s svq1_pmv_t


Function Documentation

static int encode_block ( SVQ1Context s,
uint8_t *  src,
uint8_t *  ref,
uint8_t *  decoded,
int  stride,
int  level,
int  threshold,
int  lambda,
int  intra 
) [static]

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

Definition at line 250 of file svq1.c.

References av_log(), AV_LOG_INFO, get_vlc2(), height, level, s, SVQ1_CALC_CODEBOOK_ENTRIES, SVQ1_DO_CODEBOOK_INTRA, svq1_intra_codebooks, SVQ1_PROCESS_VECTOR, VLC::table, and width.

Referenced by svq1_decode_delta_block(), and svq1_decode_frame().

Here is the call graph for this function:

static int svq1_decode_block_non_intra ( GetBitContext bitbuf,
uint8_t *  pixels,
int  pitch 
) [static]

Definition at line 305 of file svq1.c.

References av_log(), AV_LOG_INFO, get_vlc2(), height, level, s, SVQ1_CALC_CODEBOOK_ENTRIES, SVQ1_DO_CODEBOOK_NONINTRA, svq1_inter_codebooks, SVQ1_PROCESS_VECTOR, VLC::table, and width.

Referenced by svq1_decode_delta_block().

Here is the call graph for this function:

static int svq1_decode_delta_block ( MpegEncContext s,
GetBitContext bitbuf,
uint8_t *  current,
uint8_t *  previous,
int  pitch,
svq1_pmv_t motion,
int  x,
int  y 
) [static]

static int svq1_decode_end ( AVCodecContext avctx  )  [static]

Definition at line 875 of file svq1.c.

References MPV_common_end(), AVCodecContext::priv_data, and s.

Here is the call graph for this function:

static int svq1_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t *  buf,
int  buf_size 
) [static]

static int svq1_decode_frame_header ( GetBitContext bitbuf,
MpegEncContext s 
) [static]

static int svq1_decode_init ( AVCodecContext avctx  )  [static]

static int svq1_decode_motion_vector ( GetBitContext bitbuf,
svq1_pmv_t mv,
svq1_pmv_t **  pmv 
) [static]

Definition at line 348 of file svq1.c.

References get_bits1(), get_vlc2(), VLC::table, svq1_pmv_s::x, and svq1_pmv_s::y.

Referenced by svq1_motion_inter_4v_block(), and svq1_motion_inter_block().

Here is the call graph for this function:

static int svq1_motion_inter_4v_block ( MpegEncContext s,
GetBitContext bitbuf,
uint8_t *  current,
uint8_t *  previous,
int  pitch,
svq1_pmv_t motion,
int  x,
int  y 
) [static]

XXX /FIXME cliping or padding?

Definition at line 439 of file svq1.c.

References av_log(), AV_LOG_INFO, MpegEncContext::avctx, MpegEncContext::dsp, MpegEncContext::height, mv, DSPContext::put_pixels_tab, src, svq1_decode_motion_vector(), and MpegEncContext::width.

Referenced by svq1_decode_delta_block().

Here is the call graph for this function:

static int svq1_motion_inter_block ( MpegEncContext s,
GetBitContext bitbuf,
uint8_t *  current,
uint8_t *  previous,
int  pitch,
svq1_pmv_t motion,
int  x,
int  y 
) [static]

static uint16_t svq1_packet_checksum ( uint8_t *  data,
int  length,
int  value 
) [static]

Definition at line 593 of file svq1.c.

References checksum_table.

Referenced by svq1_decode_frame_header().

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

Definition at line 620 of file svq1.c.

References get_bits(), and string_table.

Referenced by svq1_decode_frame_header().

Here is the call graph for this function:

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

Definition at line 372 of file svq1.c.

References memcpy, and src.

Referenced by svq1_decode_delta_block().

static void svq1_write_header ( SVQ1Context s,
int  frame_type 
) [static]

Definition at line 883 of file svq1.c.

References SVQ1Context::frame_height, SVQ1Context::frame_width, I_TYPE, SVQ1Context::pb, put_bits(), and svq1_frame_size_table.

Here is the call graph for this function:


Variable Documentation

const uint16_t checksum_table[256] [static]

Definition at line 105 of file svq1.c.

Referenced by svq1_packet_checksum().

int height

Definition at line 588 of file svq1.c.

const uint8_t mvtab[33][2]

Definition at line 81 of file h263data.h.

const uint8_t string_table[256] [static]

Definition at line 140 of file svq1.c.

Referenced by svq1_parse_string().

VLC svq1_block_type [static]

Definition at line 53 of file svq1.c.

Initial value:

Definition at line 1391 of file svq1.c.

Referenced by avcodec_register_all().

struct { ... } svq1_frame_size_table[8] [static]

VLC svq1_inter_mean [static]

Definition at line 58 of file svq1.c.

Definition at line 56 of file svq1.c.

VLC svq1_intra_mean [static]

Definition at line 57 of file svq1.c.

Definition at line 55 of file svq1.c.

Definition at line 54 of file svq1.c.

int width

Definition at line 588 of file svq1.c.


Generated on Mon Apr 28 14:06:18 2008 for Cinelerra by  doxygen 1.5.5