FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
hqx.c File Reference
#include <inttypes.h>
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "canopus.h"
#include "codec_internal.h"
#include "get_bits.h"
#include "thread.h"
#include "vlc.h"
#include "hqxdsp.h"
#include "hqxvlc.h"

Go to the source code of this file.

Data Structures

struct  HQXSlice
 
struct  HQXContext
 

Macros

#define HQX_HEADER_SIZE   59
 
#define AC_IDX(q)
 
#define Q(q)   ((unsigned)AC_IDX(q) << 29 | (q))
 

Typedefs

typedef int(* mb_decode_func) (struct HQXContext *ctx, int slice_no, int x, int y)
 

Enumerations

enum  HQXFormat { HQX_422 = 0, HQX_444, HQX_422A, HQX_444A }
 

Functions

static void put_blocks (HQXContext *ctx, int plane, int x, int y, int ilace, int16_t *block0, int16_t *block1, const uint8_t *quant)
 
static void hqx_get_ac (GetBitContext *gb, const HQXAC *ac, int *runp, int *lev)
 
static int decode_block (GetBitContext *gb, const VLCElem vlc[], const unsigned *quants, int dcb, int16_t block[64], int *last_dc)
 
static int hqx_decode_422 (HQXContext *ctx, int slice_no, int x, int y)
 
static int hqx_decode_422a (HQXContext *ctx, int slice_no, int x, int y)
 
static int hqx_decode_444 (HQXContext *ctx, int slice_no, int x, int y)
 
static int hqx_decode_444a (HQXContext *ctx, int slice_no, int x, int y)
 
static int decode_slice (HQXContext *ctx, int slice_no)
 
static int decode_slice_thread (AVCodecContext *avctx, void *arg, int slice_no, int threadnr)
 
static int hqx_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_picture_ptr, AVPacket *avpkt)
 
static av_cold int hqx_decode_close (AVCodecContext *avctx)
 
static av_cold int hqx_decode_init (AVCodecContext *avctx)
 

Variables

static const unsigned hqx_quants [16][4]
 
static const uint8_t hqx_quant_luma [64]
 
static const uint8_t hqx_quant_chroma [64]
 
static const int shuffle_16 [16]
 
const FFCodec ff_hqx_decoder
 

Macro Definition Documentation

◆ HQX_HEADER_SIZE

#define HQX_HEADER_SIZE   59

Definition at line 76 of file hqx.c.

◆ AC_IDX

#define AC_IDX (   q)
Value:
((q) >= 128 ? HQX_AC_Q128 : (q) >= 64 ? HQX_AC_Q64 : \
(q) >= 32 ? HQX_AC_Q32 : (q) >= 16 ? HQX_AC_Q16 : \
(q) >= 8 ? HQX_AC_Q8 : HQX_AC_Q0)

Definition at line 78 of file hqx.c.

◆ Q

#define Q (   q)    ((unsigned)AC_IDX(q) << 29 | (q))

Typedef Documentation

◆ mb_decode_func

typedef int(* mb_decode_func) (struct HQXContext *ctx, int slice_no, int x, int y)

Definition at line 49 of file hqx.c.

Enumeration Type Documentation

◆ HQXFormat

enum HQXFormat
Enumerator
HQX_422 
HQX_444 
HQX_422A 
HQX_444A 

Definition at line 40 of file hqx.c.

Function Documentation

◆ put_blocks()

static void put_blocks ( HQXContext ctx,
int  plane,
int  x,
int  y,
int  ilace,
int16_t *  block0,
int16_t *  block1,
const uint8_t *  quant 
)
inlinestatic

Definition at line 123 of file hqx.c.

Referenced by hqx_decode_422(), hqx_decode_422a(), hqx_decode_444(), and hqx_decode_444a().

◆ hqx_get_ac()

static void hqx_get_ac ( GetBitContext gb,
const HQXAC ac,
int *  runp,
int *  lev 
)
inlinestatic

Definition at line 138 of file hqx.c.

Referenced by decode_block().

◆ decode_block()

static int decode_block ( GetBitContext gb,
const VLCElem  vlc[],
const unsigned *  quants,
int  dcb,
int16_t  block[64],
int *  last_dc 
)
static

Definition at line 151 of file hqx.c.

Referenced by hqx_decode_422(), hqx_decode_422a(), hqx_decode_444(), and hqx_decode_444a().

◆ hqx_decode_422()

static int hqx_decode_422 ( HQXContext ctx,
int  slice_no,
int  x,
int  y 
)
static

Definition at line 180 of file hqx.c.

Referenced by hqx_decode_frame().

◆ hqx_decode_422a()

static int hqx_decode_422a ( HQXContext ctx,
int  slice_no,
int  x,
int  y 
)
static

Definition at line 215 of file hqx.c.

Referenced by hqx_decode_frame().

◆ hqx_decode_444()

static int hqx_decode_444 ( HQXContext ctx,
int  slice_no,
int  x,
int  y 
)
static

Definition at line 264 of file hqx.c.

Referenced by hqx_decode_frame().

◆ hqx_decode_444a()

static int hqx_decode_444a ( HQXContext ctx,
int  slice_no,
int  x,
int  y 
)
static

Definition at line 301 of file hqx.c.

Referenced by hqx_decode_frame().

◆ decode_slice()

static int decode_slice ( HQXContext ctx,
int  slice_no 
)
static

Definition at line 353 of file hqx.c.

Referenced by decode_slice_thread().

◆ decode_slice_thread()

static int decode_slice_thread ( AVCodecContext avctx,
void *  arg,
int  slice_no,
int  threadnr 
)
static

Definition at line 406 of file hqx.c.

Referenced by hqx_decode_frame().

◆ hqx_decode_frame()

static int hqx_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int *  got_picture_ptr,
AVPacket avpkt 
)
static

Definition at line 429 of file hqx.c.

◆ hqx_decode_close()

static av_cold int hqx_decode_close ( AVCodecContext avctx)
static

Definition at line 540 of file hqx.c.

◆ hqx_decode_init()

static av_cold int hqx_decode_init ( AVCodecContext avctx)
static

Definition at line 549 of file hqx.c.

Variable Documentation

◆ hqx_quants

const unsigned hqx_quants[16][4]
static
Initial value:
= {
#define Q(q)
{ Q( 0x1), Q( 0x2), Q( 0x4), Q( 0x8) }, { Q( 0x1), Q( 0x3), Q( 0x6), Q( 0xC) },
{ Q( 0x2), Q( 0x4), Q( 0x8), Q( 0x10) }, { Q( 0x3), Q( 0x6), Q( 0xC), Q( 0x18) },
{ Q( 0x4), Q( 0x8), Q( 0x10), Q( 0x20) }, { Q( 0x6), Q( 0xC), Q( 0x18), Q( 0x30) },
{ Q( 0x8), Q( 0x10), Q( 0x20), Q( 0x40) },
{ Q(0xA), Q(0x14), Q(0x28), Q(0x50) },
{ Q( 0xC), Q(0x18), Q( 0x30), Q( 0x60) },
{ Q(0x10), Q( 0x20), Q( 0x40), Q( 0x80) }, { Q(0x18), Q(0x30), Q( 0x60), Q( 0xC0) },
{ Q(0x20), Q( 0x40), Q( 0x80), Q(0x100) }, { Q(0x30), Q(0x60), Q( 0xC0), Q(0x180) },
{ Q(0x40), Q( 0x80), Q(0x100), Q(0x200) }, { Q(0x60), Q(0xC0), Q(0x180), Q(0x300) },
{ Q(0x80), Q(0x100), Q(0x200), Q(0x400) }
}

Definition at line 87 of file hqx.c.

Referenced by hqx_decode_422(), hqx_decode_422a(), hqx_decode_444(), and hqx_decode_444a().

◆ hqx_quant_luma

const uint8_t hqx_quant_luma[64]
static
Initial value:
= {
16, 16, 16, 19, 19, 19, 42, 44,
16, 16, 19, 19, 19, 38, 43, 45,
16, 19, 19, 19, 40, 41, 45, 48,
19, 19, 19, 40, 41, 42, 46, 49,
19, 19, 40, 41, 42, 43, 48, 101,
19, 38, 41, 42, 43, 44, 98, 104,
42, 43, 45, 46, 48, 98, 109, 116,
44, 45, 48, 49, 101, 104, 116, 123,
}

Definition at line 101 of file hqx.c.

Referenced by hqx_decode_422(), hqx_decode_422a(), hqx_decode_444(), and hqx_decode_444a().

◆ hqx_quant_chroma

const uint8_t hqx_quant_chroma[64]
static
Initial value:
= {
16, 16, 19, 25, 26, 26, 42, 44,
16, 19, 25, 25, 26, 38, 43, 91,
19, 25, 26, 27, 40, 41, 91, 96,
25, 25, 27, 40, 41, 84, 93, 197,
26, 26, 40, 41, 84, 86, 191, 203,
26, 38, 41, 84, 86, 177, 197, 209,
42, 43, 91, 93, 191, 197, 219, 232,
44, 91, 96, 197, 203, 209, 232, 246,
}

Definition at line 112 of file hqx.c.

Referenced by hqx_decode_422(), hqx_decode_422a(), hqx_decode_444(), and hqx_decode_444a().

◆ shuffle_16

const int shuffle_16[16]
static
Initial value:
= {
0, 5, 11, 14, 2, 7, 9, 13, 1, 4, 10, 15, 3, 6, 8, 12
}

Definition at line 349 of file hqx.c.

Referenced by decode_slice().

◆ ff_hqx_decoder

const FFCodec ff_hqx_decoder
Initial value:
= {
.p.name = "hqx",
CODEC_LONG_NAME("Canopus HQX"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_HQX,
.priv_data_size = sizeof(HQXContext),
.close = hqx_decode_close,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 566 of file hqx.c.

hqx_decode_init
static av_cold int hqx_decode_init(AVCodecContext *avctx)
Definition: hqx.c:549
HQX_AC_Q64
@ HQX_AC_Q64
Definition: hqxvlc.h:39
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
HQX_AC_Q0
@ HQX_AC_Q0
Definition: hqxvlc.h:35
hqx_decode_close
static av_cold int hqx_decode_close(AVCodecContext *avctx)
Definition: hqx.c:540
HQX_AC_Q8
@ HQX_AC_Q8
Definition: hqxvlc.h:36
Q
#define Q(q)
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:341
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
HQX_AC_Q16
@ HQX_AC_Q16
Definition: hqxvlc.h:37
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
HQXContext
Definition: hqx.c:57
AV_CODEC_ID_HQX
@ AV_CODEC_ID_HQX
Definition: codec_id.h:240
HQX_AC_Q32
@ HQX_AC_Q32
Definition: hqxvlc.h:38
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
hqx_decode_frame
static int hqx_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_picture_ptr, AVPacket *avpkt)
Definition: hqx.c:429
HQX_AC_Q128
@ HQX_AC_Q128
Definition: hqxvlc.h:40