FFmpeg
|
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "jpeg2000htdec.h"
#include "jpeg2000.h"
#include "jpeg2000dec.h"
Go to the source code of this file.
Data Structures | |
struct | StateVars |
struct | MelDecoderState |
Macros | |
#define | J2K_Q1 0 |
#define | J2K_Q2 1 |
#define | HT_SHIFT_SIGMA 0 |
#define | HT_SHIFT_SCAN 4 |
#define | HT_SHIFT_REF 3 |
#define | HT_SHIFT_REF_IND 2 |
Functions | |
static av_always_inline uint32_t | is_divisible (uint32_t n, uint64_t c) |
Given a precomputed c, checks whether n % d == 0. More... | |
static av_always_inline uint64_t | precompute_c (uint32_t d) |
Precompute the number c used by is_divisible(). More... | |
static void | jpeg2000_init_zero (StateVars *s) |
static void | jpeg2000_init_mel (StateVars *s, uint32_t Pcup) |
static void | jpeg2000_init_mag_ref (StateVars *s, uint32_t Lref) |
static void | jpeg2000_init_mel_decoder (MelDecoderState *mel_state) |
static int | jpeg2000_bitbuf_refill_backwards (StateVars *buffer, const uint8_t *array) |
Refill the buffer backwards in little endian while skipping over stuffing bits. More... | |
static void | jpeg2000_bitbuf_refill_forward (StateVars *buffer, const uint8_t *array, uint32_t length) |
Refill the bit-buffer reading new bits going forward in the stream while skipping over stuffed bits. More... | |
static av_always_inline void | jpeg2000_bitbuf_drop_bits_lsb (StateVars *buf, uint8_t nbits) |
Drops bits from lower bits in the bit buffer. More... | |
static av_always_inline uint64_t | jpeg2000_bitbuf_get_bits_lsb (StateVars *bit_stream, uint8_t nbits, const uint8_t *buf) |
Get bits from the bit buffer reading them from the least significant bits moving to the most significant bits. More... | |
static av_always_inline uint64_t | jpeg2000_bitbuf_get_bits_lsb_forward (StateVars *bit_stream, uint8_t nbits, const uint8_t *buf, uint32_t length) |
Get bits from the bit buffer reading them from the least significant bits moving to the most significant bits. More... | |
static av_always_inline uint64_t | jpeg2000_bitbuf_peek_bits_lsb (StateVars *stream, uint8_t nbits) |
Look ahead bit buffer without discarding bits. More... | |
static void | jpeg2000_init_vlc (StateVars *s, uint32_t Lcup, uint32_t Pcup, const uint8_t *Dcup) |
static av_always_inline int | jpeg2000_decode_ctx_vlc (const Jpeg2000DecoderContext *s, StateVars *vlc_stream, const uint16_t *table, const uint8_t *Dcup, uint8_t *sig_pat, uint8_t *res_off, uint8_t *emb_pat_k, uint8_t *emb_pat_1, uint8_t pos, uint32_t Pcup, uint16_t context) |
Decode prefix codes for VLC segment. More... | |
static av_always_inline uint8_t | vlc_decode_u_prefix (StateVars *vlc_stream, const uint8_t *refill_array) |
Decode variable length u-vlc prefix. More... | |
static av_always_inline uint8_t | vlc_decode_u_suffix (StateVars *vlc_stream, uint8_t suffix, const uint8_t *refill_array) |
Decode variable length u-vlc suffix. More... | |
static av_always_inline uint8_t | vlc_decode_u_extension (StateVars *vlc_stream, uint8_t suffix, const uint8_t *refill_array) |
Decode u-vlc extension values. More... | |
static av_always_inline int32_t | jpeg2000_decode_mag_sgn (StateVars *mag_sgn_stream, int32_t m_n, int32_t i_n, const uint8_t *buf, uint32_t length) |
Magnitude and Sign decode procedures. More... | |
static av_always_inline void | recover_mag_sgn (StateVars *mag_sgn, uint8_t pos, uint16_t q, int32_t m_n[2], int32_t known_1[2], const uint8_t emb_pat_1[2], int32_t v[2][4], int32_t m[2][4], uint8_t *E, uint32_t *mu_n, const uint8_t *Dcup, uint32_t Pcup, uint32_t pLSB) |
static int | jpeg2000_import_bit (StateVars *stream, const uint8_t *array, uint32_t length) |
static int | jpeg2000_peek_bit (StateVars *stream, const uint8_t *array, uint32_t length) |
static int | jpeg2000_decode_mel_sym (MelDecoderState *mel_state, StateVars *mel_stream, const uint8_t *Dcup, uint32_t Lcup) |
static av_always_inline int | jpeg2000_import_magref_bit (StateVars *stream, const uint8_t *array, uint32_t length) |
Magref decoding procedures. More... | |
static int | jpeg2000_decode_sig_emb (const Jpeg2000DecoderContext *s, MelDecoderState *mel_state, StateVars *mel_stream, StateVars *vlc_stream, const uint16_t *vlc_table, const uint8_t *Dcup, uint8_t *sig_pat, uint8_t *res_off, uint8_t *emb_pat_k, uint8_t *emb_pat_1, uint8_t pos, uint16_t context, uint32_t Lcup, uint32_t Pcup) |
Signal EMB decode. More... | |
static av_always_inline int | jpeg2000_get_state (int x1, int x2, int stride, int shift_by, const uint8_t *block_states) |
static av_always_inline void | jpeg2000_modify_state (int x1, int x2, int stride, int value, uint8_t *block_states) |
static av_always_inline int | jpeg2000_decode_ht_cleanup_segment (const Jpeg2000DecoderContext *s, Jpeg2000Cblk *cblk, Jpeg2000T1Context *t1, MelDecoderState *mel_state, StateVars *mel_stream, StateVars *vlc_stream, StateVars *mag_sgn_stream, const uint8_t *Dcup, uint32_t Lcup, uint32_t Pcup, uint8_t pLSB, int width, int height, const int stride, int32_t *sample_buf, uint8_t *block_states) |
static void | jpeg2000_calc_mbr (uint8_t *mbr, const uint16_t i, const uint16_t j, const uint32_t mbr_info, uint8_t causal_cond, uint8_t *block_states, int stride) |
static void | jpeg2000_process_stripes_block (StateVars *sig_prop, int i_s, int j_s, int width, int height, int stride, int pLSB, int32_t *sample_buf, uint8_t *block_states, uint8_t *magref_segment, uint32_t magref_length, uint8_t is_causal) |
static av_noinline void | jpeg2000_decode_sigprop_segment (Jpeg2000Cblk *cblk, uint16_t width, uint16_t height, const int stride, uint8_t *magref_segment, uint32_t magref_length, uint8_t pLSB, int32_t *sample_buf, uint8_t *block_states) |
See procedure decodeSigPropMag at Rec. More... | |
static void | jpeg2000_decode_magref_segment (uint16_t width, uint16_t block_height, const int stride, uint8_t *magref_segment, uint32_t magref_length, uint8_t pLSB, int32_t *sample_buf, uint8_t *block_states) |
See procedure decodeSigPropMag at Rec. More... | |
int | ff_jpeg2000_decode_htj2k (const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int M_b, uint8_t roi_shift) |
HT Block decoder as specified in Rec. More... | |
Variables | |
const static uint8_t | mel_e [13] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5 } |
static const uint16_t | dec_cxt_vlc_table1 [1024] |
CtxVLC tables (see Rec. More... | |
static const uint16_t | dec_cxt_vlc_table0 [1024] |
#define J2K_Q1 0 |
Definition at line 59 of file jpeg2000htdec.c.
#define J2K_Q2 1 |
Definition at line 60 of file jpeg2000htdec.c.
#define HT_SHIFT_SIGMA 0 |
Definition at line 62 of file jpeg2000htdec.c.
#define HT_SHIFT_SCAN 4 |
Definition at line 63 of file jpeg2000htdec.c.
#define HT_SHIFT_REF 3 |
Definition at line 64 of file jpeg2000htdec.c.
#define HT_SHIFT_REF_IND 2 |
Definition at line 65 of file jpeg2000htdec.c.
|
static |
Given a precomputed c, checks whether n % d == 0.
c is precomputed from d using precompute_c().
Definition at line 93 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Precompute the number c used by is_divisible().
Definition at line 102 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Definition at line 107 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k(), jpeg2000_decode_sigprop_segment(), and jpeg2000_init_mel().
|
static |
Definition at line 117 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
|
static |
Definition at line 123 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_magref_segment().
|
static |
Definition at line 133 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
|
static |
Refill the buffer backwards in little endian while skipping over stuffing bits.
Stuffing bits are those that appear in the position of any byte whose LSBs are all 1's if the last consumed byte was larger than 0x8F.
Unstuff bits. Load a temporary byte, which precedes the position we currently at, to ensure that we can also un-stuff if the stuffed bit is the bottom most bits.
Definition at line 145 of file jpeg2000htdec.c.
Referenced by jpeg2000_bitbuf_get_bits_lsb(), jpeg2000_decode_ctx_vlc(), jpeg2000_decode_ht_cleanup_segment(), jpeg2000_init_vlc(), vlc_decode_u_prefix(), and vlc_decode_u_suffix().
|
static |
Refill the bit-buffer reading new bits going forward in the stream while skipping over stuffed bits.
Definition at line 207 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k(), and jpeg2000_bitbuf_get_bits_lsb_forward().
|
static |
Drops bits from lower bits in the bit buffer.
buf contains the bit buffers. nbits is the number of bits to remove.
Definition at line 228 of file jpeg2000htdec.c.
Referenced by jpeg2000_bitbuf_get_bits_lsb(), jpeg2000_bitbuf_get_bits_lsb_forward(), jpeg2000_decode_ctx_vlc(), jpeg2000_init_vlc(), vlc_decode_u_prefix(), and vlc_decode_u_suffix().
|
static |
Get bits from the bit buffer reading them from the least significant bits moving to the most significant bits.
In case there are fewer bits, refill from buf moving backwards.
Definition at line 241 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment(), jpeg2000_import_magref_bit(), and vlc_decode_u_extension().
|
static |
Get bits from the bit buffer reading them from the least significant bits moving to the most significant bits.
In case there are fewer bits, refill from buf moving forward.
Definition at line 259 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_mag_sgn().
|
static |
Look ahead bit buffer without discarding bits.
Definition at line 277 of file jpeg2000htdec.c.
Referenced by vlc_decode_u_prefix(), and vlc_decode_u_suffix().
|
static |
Definition at line 283 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
|
static |
Decode prefix codes for VLC segment.
See Rec. ITU-T T.814, 7.3.5.
Definition at line 301 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_sig_emb().
|
static |
Decode variable length u-vlc prefix.
See decodeUPrefix procedure at Rec. ITU-T T.814, 7.3.6.
Definition at line 338 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Decode variable length u-vlc suffix.
See decodeUSuffix procedure at Rec. ITU-T T.814, 7.3.6.
Definition at line 359 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Decode u-vlc extension values.
See decodeUExtension procedure at Rec. ITU-T T.814, 7.3.6.
Definition at line 384 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Magnitude and Sign decode procedures.
See decodeMagSgnValue procedure at Rec. ITU-T T.814, 7.3.8.
Definition at line 395 of file jpeg2000htdec.c.
Referenced by recover_mag_sgn().
|
static |
Definition at line 407 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Definition at line 429 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_mel_sym().
|
static |
Definition at line 442 of file jpeg2000htdec.c.
Referenced by jpeg2000_process_stripes_block().
|
static |
Definition at line 462 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment(), and jpeg2000_decode_sig_emb().
|
static |
Magref decoding procedures.
Definition at line 501 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_magref_segment().
|
static |
Signal EMB decode.
Definition at line 510 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Definition at line 534 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_magref_segment(), and jpeg2000_process_stripes_block().
|
static |
Definition at line 541 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment(), jpeg2000_decode_magref_segment(), and jpeg2000_process_stripes_block().
|
static |
Initial line pair end. As an optimization, we can replace modulo operations with checking if a number is divisible , since that's the only thing we need. This is paired with is_divisible. Credits to Daniel Lemire blog post [1].
It's UB on zero, but the spec doesn't allow a quad being zero, so we error out early in case that's the case.
Definition at line 548 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
|
static |
Definition at line 1016 of file jpeg2000htdec.c.
Referenced by jpeg2000_process_stripes_block().
|
static |
Definition at line 1034 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_sigprop_segment().
|
static |
See procedure decodeSigPropMag at Rec.
ITU-T T.814, 7.4.
Definition at line 1083 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
|
static |
See procedure decodeSigPropMag at Rec.
ITU-T T.814, 7.5.
We move column wise, going from one quad to another. See Rec. ITU-T T.814, Figure 7.
Definition at line 1137 of file jpeg2000htdec.c.
Referenced by ff_jpeg2000_decode_htj2k().
int ff_jpeg2000_decode_htj2k | ( | const Jpeg2000DecoderContext * | s, |
Jpeg2000CodingStyle * | codsty, | ||
Jpeg2000T1Context * | t1, | ||
Jpeg2000Cblk * | cblk, | ||
int | width, | ||
int | height, | ||
int | M_b, | ||
uint8_t | roi_shift | ||
) |
HT Block decoder as specified in Rec.
ITU-T T.814 | ISO/IEC 15444-15
Definition at line 1189 of file jpeg2000htdec.c.
Referenced by tile_codeblocks().
|
static |
Definition at line 68 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_mel_sym().
|
static |
CtxVLC tables (see Rec.
ITU-T T.800, Annex C) as found at https://github.com/osamu620/OpenHTJ2K (author: Osamu Watanabe)
Definition at line 70 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().
|
static |
Definition at line 71 of file jpeg2000htdec.c.
Referenced by jpeg2000_decode_ht_cleanup_segment().