FFmpeg  4.0
Data Structures | Macros | Functions | Variables
4xm.c File Reference

4XM codec. More...

#include <inttypes.h>
#include "libavutil/avassert.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "bswapdsp.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  CFrameBuffer
 
struct  FourXContext
 

Macros

#define BLOCK_TYPE_VLC_BITS   5
 
#define ACDC_VLC_BITS   9
 
#define CFRAME_BUFFER_COUNT   100
 
#define FIX_1_082392200   70936
 
#define FIX_1_414213562   92682
 
#define FIX_1_847759065   121095
 
#define FIX_2_613125930   171254
 
#define MULTIPLY(var, const)   (((var) * (const)) >> 16)
 
#define LE_CENTRIC_MUL(dst, src, scale, dc)
 

Functions

static void idct (int16_t block[64])
 
static av_cold void init_vlcs (FourXContext *f)
 
static void init_mv (FourXContext *f, int linesize)
 
static void mcdc (uint16_t *dst, const uint16_t *src, int log2w, int h, int stride, int scale, unsigned dc)
 
static int decode_p_block (FourXContext *f, uint16_t *dst, const uint16_t *src, int log2w, int log2h, int stride)
 
static int decode_p_frame (FourXContext *f, const uint8_t *buf, int length)
 
static int decode_i_block (FourXContext *f, int16_t *block)
 decode block and dequantize. More...
 
static void idct_put (FourXContext *f, int x, int y)
 
static int decode_i_mb (FourXContext *f)
 
static const uint8_tread_huffman_tables (FourXContext *f, const uint8_t *const buf, int buf_size)
 
static int mix (int c0, int c1)
 
static int decode_i2_frame (FourXContext *f, const uint8_t *buf, int length)
 
static int decode_i_frame (FourXContext *f, const uint8_t *buf, int length)
 
static int decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
static av_cold int decode_end (AVCodecContext *avctx)
 
static av_cold int decode_init (AVCodecContext *avctx)
 

Variables

static const uint8_t block_type_tab [2][4][8][2]
 
static const uint8_t size2index [4][4]
 
static const int8_t mv [256][2]
 
static const uint8_t dequant_table [64]
 
static VLC block_type_vlc [2][4]
 
AVCodec ff_fourxm_decoder
 

Detailed Description

4XM codec.

Definition in file 4xm.c.

Macro Definition Documentation

◆ BLOCK_TYPE_VLC_BITS

#define BLOCK_TYPE_VLC_BITS   5

Definition at line 41 of file 4xm.c.

Referenced by decode_p_block(), and init_vlcs().

◆ ACDC_VLC_BITS

#define ACDC_VLC_BITS   9

Definition at line 42 of file 4xm.c.

Referenced by decode_i_block(), decode_i_frame(), and read_huffman_tables().

◆ CFRAME_BUFFER_COUNT

#define CFRAME_BUFFER_COUNT   100

Definition at line 44 of file 4xm.c.

Referenced by decode_end(), and decode_frame().

◆ FIX_1_082392200

#define FIX_1_082392200   70936

Definition at line 156 of file 4xm.c.

Referenced by column_fidct_c(), idct(), and row_idct_c().

◆ FIX_1_414213562

#define FIX_1_414213562   92682

Definition at line 157 of file 4xm.c.

Referenced by column_fidct_c(), idct(), and row_idct_c().

◆ FIX_1_847759065

#define FIX_1_847759065   121095

Definition at line 158 of file 4xm.c.

Referenced by column_fidct_c(), idct(), and row_idct_c().

◆ FIX_2_613125930

#define FIX_2_613125930   171254

Definition at line 159 of file 4xm.c.

Referenced by column_fidct_c(), idct(), and row_idct_c().

◆ MULTIPLY

#define MULTIPLY (   var,
  const 
)    (((var) * (const)) >> 16)

Definition at line 161 of file 4xm.c.

Referenced by idct().

◆ LE_CENTRIC_MUL

#define LE_CENTRIC_MUL (   dst,
  src,
  scale,
  dc 
)
Value:
{ \
unsigned tmpval = AV_RN32(src) * (scale) + (dc); \
AV_WN32A(dst, tmpval); \
}
#define src
Definition: vp8dsp.c:254
#define AV_RN32(p)
Definition: intreadwrite.h:364
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc

Definition at line 287 of file 4xm.c.

Referenced by mcdc().

Function Documentation

◆ idct()

static void idct ( int16_t  block[64])
static

◆ init_vlcs()

static av_cold void init_vlcs ( FourXContext f)
static

Definition at line 248 of file 4xm.c.

Referenced by decode_init().

◆ init_mv()

static void init_mv ( FourXContext f,
int  linesize 
)
static

Definition at line 265 of file 4xm.c.

Referenced by decode_p_frame().

◆ mcdc()

static void mcdc ( uint16_t *  dst,
const uint16_t *  src,
int  log2w,
int  h,
int  stride,
int  scale,
unsigned  dc 
)
inlinestatic

Definition at line 294 of file 4xm.c.

Referenced by decode_p_block().

◆ decode_p_block()

static int decode_p_block ( FourXContext f,
uint16_t *  dst,
const uint16_t *  src,
int  log2w,
int  log2h,
int  stride 
)
static

Definition at line 342 of file 4xm.c.

Referenced by decode_p_frame().

◆ decode_p_frame()

static int decode_p_frame ( FourXContext f,
const uint8_t buf,
int  length 
)
static

Definition at line 427 of file 4xm.c.

Referenced by decode_frame().

◆ decode_i_block()

static int decode_i_block ( FourXContext f,
int16_t *  block 
)
static

decode block and dequantize.

Note this is almost identical to MJPEG.

Definition at line 495 of file 4xm.c.

Referenced by decode_i_mb().

◆ idct_put()

static void idct_put ( FourXContext f,
int  x,
int  y 
)
inlinestatic

Definition at line 550 of file 4xm.c.

Referenced by decode_i_frame().

◆ decode_i_mb()

static int decode_i_mb ( FourXContext f)
static

Definition at line 596 of file 4xm.c.

Referenced by decode_i_frame().

◆ read_huffman_tables()

static const uint8_t* read_huffman_tables ( FourXContext f,
const uint8_t *const  buf,
int  buf_size 
)
static

Definition at line 610 of file 4xm.c.

Referenced by decode_i_frame().

◆ mix()

static int mix ( int  c0,
int  c1 
)
static

Definition at line 707 of file 4xm.c.

Referenced by decode_i2_frame(), and filter_frame().

◆ decode_i2_frame()

static int decode_i2_frame ( FourXContext f,
const uint8_t buf,
int  length 
)
static

Definition at line 715 of file 4xm.c.

Referenced by decode_frame().

◆ decode_i_frame()

static int decode_i_frame ( FourXContext f,
const uint8_t buf,
int  length 
)
static

Definition at line 763 of file 4xm.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
void data,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 827 of file 4xm.c.

◆ decode_end()

static av_cold int decode_end ( AVCodecContext avctx)
static

Definition at line 963 of file 4xm.c.

Referenced by decode_init().

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 981 of file 4xm.c.

Variable Documentation

◆ block_type_tab

const uint8_t block_type_tab[2][4][8][2]
static
Initial value:
= {
{
{
{ 0, 1 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 30, 5 }, { 31, 5 }, { 0, 0 }
}, {
{ 0, 1 }, { 0, 0 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 15, 4 }, { 0, 0 }
}, {
{ 0, 1 }, { 2, 2 }, { 0, 0 }, { 6, 3 }, { 14, 4 }, { 15, 4 }, { 0, 0 }
}, {
{ 0, 1 }, { 0, 0 }, { 0, 0 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 15, 4 }
}
}, {
{
{ 1, 2 }, { 4, 3 }, { 5, 3 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 }
}, {
{ 1, 2 }, { 0, 0 }, { 2, 2 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 }
}, {
{ 1, 2 }, { 2, 2 }, { 0, 0 }, { 0, 2 }, { 6, 3 }, { 7, 3 }, { 0, 0 }
}, {
{ 1, 2 }, { 0, 0 }, { 0, 0 }, { 0, 2 }, { 2, 2 }, { 6, 3 }, { 7, 3 }
}
}
}

Definition at line 46 of file 4xm.c.

Referenced by init_vlcs().

◆ size2index

const uint8_t size2index[4][4]
static
Initial value:
= {
{ -1, 3, 1, 1 },
{ 3, 0, 0, 0 },
{ 2, 0, 0, 0 },
{ 2, 0, 0, 0 },
}

Definition at line 70 of file 4xm.c.

Referenced by decode_p_block().

◆ mv

const int8_t mv[256][2]
static

◆ dequant_table

const uint8_t dequant_table[64]
static
Initial value:
= {
16, 15, 13, 19, 24, 31, 28, 17,
17, 23, 25, 31, 36, 63, 45, 21,
18, 24, 27, 37, 52, 59, 49, 20,
16, 28, 34, 40, 60, 80, 51, 20,
18, 31, 48, 66, 68, 86, 56, 21,
19, 38, 56, 59, 64, 64, 48, 20,
27, 48, 55, 55, 56, 51, 35, 15,
20, 35, 34, 32, 31, 22, 15, 8,
}

Definition at line 114 of file 4xm.c.

Referenced by decode_i_block(), and fill_tone_level_array().

◆ block_type_vlc

VLC block_type_vlc[2][4]
static

Definition at line 125 of file 4xm.c.

◆ ff_fourxm_decoder

AVCodec ff_fourxm_decoder
Initial value:
= {
.name = "4xm",
.long_name = NULL_IF_CONFIG_SMALL("4X Movie"),
.priv_data_size = sizeof(FourXContext),
.close = decode_end,
.capabilities = AV_CODEC_CAP_DR1,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static av_cold int decode_init(AVCodecContext *avctx)
Definition: 4xm.c:981
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: 4xm.c:827
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int decode_end(AVCodecContext *avctx)
Definition: 4xm.c:963
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

Definition at line 1020 of file 4xm.c.