hqx.h 1.91 KB
Newer Older
Vittorio Giovara's avatar
Vittorio Giovara committed
1 2 3
/*
 * Canopus HQX decoder
 *
4
 * This file is part of FFmpeg.
Vittorio Giovara's avatar
Vittorio Giovara committed
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
Vittorio Giovara's avatar
Vittorio Giovara committed
7 8 9 10
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
Vittorio Giovara's avatar
Vittorio Giovara committed
12 13 14 15 16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
Vittorio Giovara's avatar
Vittorio Giovara committed
18 19 20 21 22 23 24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVCODEC_HQX_H
#define AVCODEC_HQX_H

#include <stdint.h>
25 26

#include "libavutil/frame.h"
Vittorio Giovara's avatar
Vittorio Giovara committed
27 28
#include "libavutil/mem.h"
#include "get_bits.h"
29
#include "hqxdsp.h"
Vittorio Giovara's avatar
Vittorio Giovara committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

enum HQXACMode {
    HQX_AC_Q0 = 0,
    HQX_AC_Q8,
    HQX_AC_Q16,
    HQX_AC_Q32,
    HQX_AC_Q64,
    HQX_AC_Q128,
    NUM_HQX_AC
};

typedef struct HQXLUT {
    int16_t lev;
    uint8_t run;
    int8_t  bits;
} HQXLUT;

typedef struct HQXAC {
    int lut_bits, extra_bits;
    const HQXLUT *lut;
} HQXAC;

52 53
struct HQXContext;

54 55 56 57 58 59 60
typedef int (*mb_decode_func)(struct HQXContext *ctx,
                              int slice_no, int x, int y);

typedef struct HQXSlice {
    GetBitContext gb;
    DECLARE_ALIGNED(16, int16_t, block)[16][64];
} HQXSlice;
61

Vittorio Giovara's avatar
Vittorio Giovara committed
62
typedef struct HQXContext {
63
    HQXDSPContext hqxdsp;
64
    HQXSlice slice[16];
65

66 67 68
    AVFrame *pic;
    mb_decode_func decode_func;

Vittorio Giovara's avatar
Vittorio Giovara committed
69 70 71
    int format, dcb, width, height;
    int interlaced;

72 73 74 75
    uint8_t *src;
    unsigned int data_size;
    uint32_t slice_off[17];

Vittorio Giovara's avatar
Vittorio Giovara committed
76 77 78 79 80 81 82 83 84 85 86
    VLC cbp_vlc;
    VLC dc_vlc[3];
} HQXContext;

#define HQX_DC_VLC_BITS 9

extern const HQXAC ff_hqx_ac[NUM_HQX_AC];

int ff_hqx_init_vlcs(HQXContext *ctx);

#endif /* AVCODEC_HQX_H */