#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"

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 |
Definition in 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);\ }
| #define SVQ1_BLOCK_INTER 1 |
| #define SVQ1_BLOCK_INTER_4V 2 |
| #define SVQ1_BLOCK_INTRA 3 |
| #define SVQ1_BLOCK_SKIP 0 |
| #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().
| typedef struct svq1_pmv_s svq1_pmv_t |
| 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] |
Definition at line 935 of file svq1.c.
References offset, put_bits(), SVQ1Context::reorder_pb, svq1_inter_codebook_sum, svq1_inter_codebooks, svq1_inter_mean_vlc, svq1_inter_multistage_vlc, svq1_intra_codebook_sum, svq1_intra_codebooks, svq1_intra_mean_vlc, and svq1_intra_multistage_vlc.

| 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().

| 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().

| 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] |
Definition at line 529 of file svq1.c.
References av_log(), AV_LOG_INFO, MpegEncContext::avctx, get_vlc2(), SVQ1_BLOCK_INTER, SVQ1_BLOCK_INTER_4V, SVQ1_BLOCK_INTRA, SVQ1_BLOCK_SKIP, svq1_decode_block_intra(), svq1_decode_block_non_intra(), svq1_motion_inter_4v_block(), svq1_motion_inter_block(), svq1_skip_block(), VLC::table, svq1_pmv_s::x, and svq1_pmv_s::y.
Referenced by svq1_decode_frame().

| 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.

| static int svq1_decode_frame | ( | AVCodecContext * | avctx, | |
| void * | data, | |||
| int * | data_size, | |||
| uint8_t * | buf, | |||
| int | buf_size | |||
| ) | [static] |
Definition at line 709 of file svq1.c.
References av_log(), AV_LOG_INFO, MpegEncContext::avctx, AVDISCARD_ALL, AVDISCARD_NONKEY, AVDISCARD_NONREF, B_TYPE, CODEC_FLAG_GRAY, MpegEncContext::current_picture, MpegEncContext::f_code, MpegEncContext::flags, MpegEncContext::gb, get_bits(), MpegEncContext::height, AVCodecContext::hurry_up, I_TYPE, init_get_bits(), MpegEncContext::last_picture, MpegEncContext::last_picture_ptr, MpegEncContext::linesize, MPV_frame_end(), MPV_frame_start(), MpegEncContext::next_picture, NULL, MpegEncContext::pict_type, AVCodecContext::priv_data, s, AVCodecContext::skip_frame, src, svq1_decode_block_intra(), svq1_decode_delta_block(), svq1_decode_frame_header(), MpegEncContext::uvlinesize, MpegEncContext::width, svq1_pmv_s::x, and svq1_pmv_s::y.

| static int svq1_decode_frame_header | ( | GetBitContext * | bitbuf, | |
| MpegEncContext * | s | |||
| ) | [static] |
Definition at line 634 of file svq1.c.
References av_log(), AV_LOG_INFO, MpegEncContext::avctx, GetBitContext::buffer, MpegEncContext::f_code, get_bits(), MpegEncContext::height, I_TYPE, MpegEncContext::pict_type, GetBitContext::size_in_bits, skip_bits(), skip_bits1(), svq1_frame_size_table, svq1_packet_checksum(), svq1_parse_string(), and MpegEncContext::width.
Referenced by svq1_decode_frame().

| static int svq1_decode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 831 of file svq1.c.
References MpegEncContext::avctx, AVCodecContext::codec, MpegEncContext::codec_id, AVCodecContext::flags, MpegEncContext::flags, AVCodecContext::has_b_frames, AVCodecContext::height, MpegEncContext::height, AVCodec::id, init_vlc(), MPV_common_init(), MPV_decode_defaults(), mvtab, AVCodecContext::pix_fmt, PIX_FMT_YUV410P, AVCodecContext::priv_data, s, svq1_block_type_vlc, svq1_inter_mean_vlc, svq1_inter_multistage_vlc, svq1_intra_mean_vlc, svq1_intra_multistage_vlc, AVCodecContext::width, and MpegEncContext::width.

| 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().

| 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().

| 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] |
Definition at line 387 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(), MpegEncContext::width, svq1_pmv_s::x, and svq1_pmv_s::y.
Referenced by svq1_decode_delta_block().

| 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().

| static void svq1_skip_block | ( | uint8_t * | current, | |
| uint8_t * | previous, | |||
| int | pitch, | |||
| int | x, | |||
| int | y | |||
| ) | [static] |
| 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.

const uint16_t checksum_table[256] [static] |
| const uint8_t mvtab[33][2] |
Definition at line 81 of file h263data.h.
const uint8_t string_table[256] [static] |
VLC svq1_block_type [static] |
Initial value:
{
"svq1",
CODEC_TYPE_VIDEO,
CODEC_ID_SVQ1,
sizeof(MpegEncContext),
svq1_decode_init,
NULL,
svq1_decode_end,
svq1_decode_frame,
CODEC_CAP_DR1,
.flush= ff_mpeg_flush,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV410P, -1},
}
Definition at line 1391 of file svq1.c.
Referenced by avcodec_register_all().
struct { ... } svq1_frame_size_table[8] [static] |
Referenced by svq1_decode_frame_header(), and svq1_write_header().
VLC svq1_inter_mean [static] |
VLC svq1_inter_multistage[6] [static] |
VLC svq1_intra_mean [static] |
VLC svq1_intra_multistage[6] [static] |
VLC svq1_motion_component [static] |
1.5.5