Commit c81a7063 authored by Nicolas Bertrand's avatar Nicolas Bertrand Committed by Diego Biurrun

JPEG 2000 decoder for DCinema

Based on the 2007 GSoC project from Kamil Nowosad <k.nowosad@students.mimuw.edu.pl>
Updated to current programming standards, style and many more small
fixes by Diego Biurrun <diego@biurrun.de>.
Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent 0c15a9aa
......@@ -11,6 +11,7 @@ version 10:
filtergraph description to be read from a file
- uniform options syntax across all filters
- new interlace filter
- JPEG 2000 decoder
version 9:
......
......@@ -373,8 +373,8 @@ following image formats are supported:
@tab Digital Picture Exchange
@item JPEG @tab X @tab X
@tab Progressive JPEG is not supported.
@item JPEG 2000 @tab E @tab E
@tab decoding supported through external library libopenjpeg
@item JPEG 2000 @tab E @tab X
@tab encoding supported through external library libopenjpeg
@item JPEG-LS @tab X @tab X
@item LJPEG @tab X @tab
@tab Lossless JPEG
......
......@@ -205,6 +205,8 @@ OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi_common.o ivi_dsp.o
OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi_common.o ivi_dsp.o
OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
OBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dec.o jpeg2000.o \
jpeg2000dwt.o mqcdec.o mqc.o
OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o \
mjpegdec.o mjpeg.o
OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o
......
......@@ -160,6 +160,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(INDEO4, indeo4);
REGISTER_DECODER(INDEO5, indeo5);
REGISTER_DECODER(INTERPLAY_VIDEO, interplay_video);
REGISTER_DECODER(JPEG2000, jpeg2000);
REGISTER_ENCDEC (JPEGLS, jpegls);
REGISTER_DECODER(JV, jv);
REGISTER_DECODER(KGV1, kgv1);
......
......@@ -2570,6 +2570,12 @@ typedef struct AVCodecContext {
#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1
#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2
#define FF_PROFILE_JPEG2000_DCINEMA_2K 3
#define FF_PROFILE_JPEG2000_DCINEMA_4K 4
/**
* level
* - encoding: Set by user.
......
This diff is collapsed.
/*
* JPEG 2000 common defines, structures and functions
* Copyright (c) 2007 Kamil Nowosad
* Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* 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.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_JPEG2000_H
#define AVCODEC_JPEG2000_H
/**
* @file
* JPEG 2000 structures and defines common
* to encoder and decoder
*/
#include <stdint.h>
#include "avcodec.h"
#include "mqc.h"
#include "jpeg2000dwt.h"
enum Jpeg2000Markers {
JPEG2000_SOC = 0xff4f, // start of codestream
JPEG2000_SIZ = 0xff51, // image and tile size
JPEG2000_COD, // coding style default
JPEG2000_COC, // coding style component
JPEG2000_TLM = 0xff55, // packed packet headers, tile-part header
JPEG2000_PLM = 0xff57, // tile-part lengths
JPEG2000_PLT, // packet length, main header
JPEG2000_QCD = 0xff5c, // quantization default
JPEG2000_QCC, // quantization component
JPEG2000_RGN, // region of interest
JPEG2000_POC, // progression order change
JPEG2000_PPM, // packet length, tile-part header
JPEG2000_PPT, // packed packet headers, main header
JPEG2000_CRG = 0xff63, // component registration
JPEG2000_COM, // comment
JPEG2000_SOT = 0xff90, // start of tile-part
JPEG2000_SOP, // start of packet
JPEG2000_EPH, // end of packet header
JPEG2000_SOD, // start of data
JPEG2000_EOC = 0xffd9, // end of codestream
};
enum Jpeg2000Quantsty { // quantization style
JPEG2000_QSTY_NONE, // no quantization
JPEG2000_QSTY_SI, // scalar derived
JPEG2000_QSTY_SE // scalar expounded
};
#define JPEG2000_MAX_CBLKW 64
#define JPEG2000_MAX_CBLKH 64
#define JPEG2000_MAX_RESLEVELS 33
// T1 flags
// flags determining significance of neighbor coefficients
#define JPEG2000_T1_SIG_N 0x0001
#define JPEG2000_T1_SIG_E 0x0002
#define JPEG2000_T1_SIG_W 0x0004
#define JPEG2000_T1_SIG_S 0x0008
#define JPEG2000_T1_SIG_NE 0x0010
#define JPEG2000_T1_SIG_NW 0x0020
#define JPEG2000_T1_SIG_SE 0x0040
#define JPEG2000_T1_SIG_SW 0x0080
#define JPEG2000_T1_SIG_NB (JPEG2000_T1_SIG_N | JPEG2000_T1_SIG_E | \
JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_W | \
JPEG2000_T1_SIG_NE | JPEG2000_T1_SIG_NW | \
JPEG2000_T1_SIG_SE | JPEG2000_T1_SIG_SW)
// flags determining sign bit of neighbor coefficients
#define JPEG2000_T1_SGN_N 0x0100
#define JPEG2000_T1_SGN_S 0x0200
#define JPEG2000_T1_SGN_W 0x0400
#define JPEG2000_T1_SGN_E 0x0800
#define JPEG2000_T1_VIS 0x1000
#define JPEG2000_T1_SIG 0x2000
#define JPEG2000_T1_REF 0x4000
#define JPEG2000_T1_SGN 0x8000
// Codeblock coding styles
#define JPEG2000_CBLK_BYPASS 0x01 // Selective arithmetic coding bypass
#define JPEG2000_CBLK_RESET 0x02 // Reset context probabilities
#define JPEG2000_CBLK_TERMALL 0x04 // Terminate after each coding pass
#define JPEG2000_CBLK_VSC 0x08 // Vertical stripe causal context formation
#define JPEG2000_CBLK_PREDTERM 0x10 // Predictable termination
#define JPEG2000_CBLK_SEGSYM 0x20 // Segmentation symbols present
// Coding styles
#define JPEG2000_CSTY_PREC 0x01 // Precincts defined in coding style
#define JPEG2000_CSTY_SOP 0x02 // SOP marker present
#define JPEG2000_CSTY_EPH 0x04 // EPH marker present
// Progression orders
#define JPEG2000_PGOD_LRCP 0x00 // Layer-resolution level-component-position progression
#define JPEG2000_PGOD_RLCP 0x01 // Resolution level-layer-component-position progression
#define JPEG2000_PGOD_RPCL 0x02 // Resolution level-position-component-layer progression
#define JPEG2000_PGOD_PCRL 0x03 // Position-component-resolution level-layer progression
#define JPEG2000_PGOD_CPRL 0x04 // Component-position-resolution level-layer progression
typedef struct Jpeg2000T1Context {
int data[JPEG2000_MAX_CBLKW][JPEG2000_MAX_CBLKH];
int flags[JPEG2000_MAX_CBLKW + 2][JPEG2000_MAX_CBLKH + 2];
MqcState mqc;
} Jpeg2000T1Context;
typedef struct Jpeg2000TgtNode {
uint8_t val;
uint8_t vis;
struct Jpeg2000TgtNode *parent;
} Jpeg2000TgtNode;
typedef struct Jpeg2000CodingStyle {
uint8_t nreslevels; // number of resolution levels
uint8_t nreslevels2decode; // number of resolution levels to decode
uint8_t log2_cblk_width,
log2_cblk_height; // exponent of codeblock size
uint8_t transform; // DWT type
uint8_t csty; // coding style
uint8_t log2_prec_width,
log2_prec_height; // precinct size
uint8_t nlayers; // number of layers
uint8_t mct; // multiple component transformation
uint8_t cblk_style; // codeblock coding style
uint8_t prog_order; // progression order
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]; // precincts size according resolution levels
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]; // TODO: initialize prec_size array with 0?
} Jpeg2000CodingStyle;
typedef struct Jpeg2000QuantStyle {
uint8_t expn[32 * 3]; // quantization exponent
uint32_t mant[32 * 3]; // quantization mantissa
uint8_t quantsty; // quantization style
uint8_t nguardbits; // number of guard bits
} Jpeg2000QuantStyle;
typedef struct Jpeg2000Pass {
uint16_t rate;
int64_t disto;
} Jpeg2000Pass;
typedef struct Jpeg2000Cblk {
uint8_t npasses;
uint8_t ninclpasses; // number coding of passes included in codestream
uint8_t nonzerobits;
uint16_t length;
uint16_t lengthinc;
uint8_t lblock;
uint8_t zero;
uint8_t data[8192];
Jpeg2000Pass passes[100];
uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
} Jpeg2000Cblk; // code block
typedef struct Jpeg2000Prec {
uint16_t xi0, yi0; // codeblock indexes ([xi0, xi1))
uint16_t nb_codeblocks_width;
uint16_t nb_codeblocks_height;
Jpeg2000TgtNode *zerobits;
Jpeg2000TgtNode *cblkincl;
Jpeg2000Cblk *cblk;
uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
} Jpeg2000Prec; // precinct
/* TODO: stepsize can be float or integer depending on
* reversible or irreversible transformation. */
typedef struct Jpeg2000Band {
uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
uint16_t log2_cblk_width, log2_cblk_height;
uint16_t cblknx, cblkny;
float stepsize; // quantization stepsize
Jpeg2000Prec *prec;
} Jpeg2000Band; // subband
typedef struct Jpeg2000ResLevel {
uint8_t nbands;
uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
uint16_t num_precincts_x, num_precincts_y; // number of precincts in x/y direction
uint8_t log2_prec_width, log2_prec_height; // exponent of precinct size
Jpeg2000Band *band;
} Jpeg2000ResLevel; // resolution level
/* TODO: data can be float of integer depending of reversible/irreversible
* transformation.
*/
typedef struct Jpeg2000Component {
Jpeg2000ResLevel *reslevel;
DWTContext dwt;
float *data;
uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- can be reduced with lowres option
uint16_t coord_o[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- original values from jpeg2000 headers
} Jpeg2000Component;
/* misc tools */
static inline int ff_jpeg2000_ceildivpow2(int a, int b)
{
return (a + (1 << b) - 1) >> b;
}
static inline int ff_jpeg2000_ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
/* TIER-1 routines */
/* Set up lookup tables used in TIER-1. */
void ff_jpeg2000_init_tier1_luts(void);
/* Update significance of a coefficient at current position (x,y) and
* for neighbors. */
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1,
int x, int y, int negative);
extern uint8_t ff_jpeg2000_sigctxno_lut[256][4];
/* Get context label (number in range[0..8]) of a coefficient for significance
* propagation and cleanup coding passes. */
static inline int ff_jpeg2000_getsigctxno(int flag, int bandno)
{
return ff_jpeg2000_sigctxno_lut[flag & 255][bandno];
}
static const uint8_t refctxno_lut[2][2] = { { 14, 15 }, { 16, 16 } };
/* Get context label (number in range[14..16]) of a coefficient for magnitude
* refinement pass. */
static inline int ff_jpeg2000_getrefctxno(int flag)
{
return refctxno_lut[(flag >> 14) & 1][(flag & 255) != 0];
}
extern uint8_t ff_jpeg2000_sgnctxno_lut[16][16];
extern uint8_t ff_jpeg2000_xorbit_lut[16][16];
/* Get context label (number in range[9..13]) for sign decoding. */
static inline int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)
{
*xorbit = ff_jpeg2000_xorbit_lut[flag & 15][(flag >> 8) & 15];
return ff_jpeg2000_sgnctxno_lut[flag & 15][(flag >> 8) & 15];
}
int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *ctx);
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
#endif /* AVCODEC_JPEG2000_H */
This diff is collapsed.
This diff is collapsed.
/*
* Discrete wavelet transform
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* 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.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_JPEG2000DWT_H
#define AVCODEC_JPEG2000DWT_H
/**
* @file
* Discrete wavelet transform
*/
#include <stdint.h>
#define FF_DWT_MAX_DECLVLS 32 ///< max number of decomposition levels
enum DWTType {
FF_DWT97,
FF_DWT53,
FF_DWT97_INT
};
typedef struct DWTContext {
/// line lengths { horizontal, vertical } in consecutive decomposition levels
uint16_t linelen[FF_DWT_MAX_DECLVLS][2];
uint8_t mod[FF_DWT_MAX_DECLVLS][2]; ///< coordinates (x0, y0) of decomp. levels mod 2
uint8_t ndeclevels; ///< number of decomposition levels
uint8_t type; ///< 0 for 9/7; 1 for 5/3
int32_t *i_linebuf; ///< int buffer used by transform
float *f_linebuf; ///< float buffer used by transform
} DWTContext;
/**
* Initialize DWT.
* @param s DWT context
* @param border coordinates of transformed region {{x0, x1}, {y0, y1}}
* @param decomp_levels number of decomposition levels
* @param type 0 for DWT 9/7; 1 for DWT 5/3
*/
int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2],
int decomp_levels, int type);
int ff_dwt_decode(DWTContext *s, void *t);
void ff_dwt_destroy(DWTContext *s);
#endif /* AVCODEC_JPEG2000DWT_H */
/*
* MQ-coder encoder and decoder common functions
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* 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.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* MQ-coder common (decoder/encoder) functions
* @file
* @author Kamil Nowosad
*/
#include <string.h>
#include <stdint.h>
#include "mqc.h"
/* MQ coder context state structure */
typedef struct MqcCxState {
uint16_t qe;
uint8_t nmps;
uint8_t nlps;
uint8_t sw;
} MqcCxState;
static const MqcCxState cx_states[47] = {
{ 0x5601, 1, 1, 1 },
{ 0x3401, 2, 6, 0 },
{ 0x1801, 3, 9, 0 },
{ 0x0AC1, 4, 12, 0 },
{ 0x0521, 5, 29, 0 },
{ 0x0221, 38, 33, 0 },
{ 0x5601, 7, 6, 1 },
{ 0x5401, 8, 14, 0 },
{ 0x4801, 9, 14, 0 },
{ 0x3801, 10, 14, 0 },
{ 0x3001, 11, 17, 0 },
{ 0x2401, 12, 18, 0 },
{ 0x1C01, 13, 20, 0 },
{ 0x1601, 29, 21, 0 },
{ 0x5601, 15, 14, 1 },
{ 0x5401, 16, 14, 0 },
{ 0x5101, 17, 15, 0 },
{ 0x4801, 18, 16, 0 },
{ 0x3801, 19, 17, 0 },
{ 0x3401, 20, 18, 0 },
{ 0x3001, 21, 19, 0 },
{ 0x2801, 22, 19, 0 },
{ 0x2401, 23, 20, 0 },
{ 0x2201, 24, 21, 0 },
{ 0x1C01, 25, 22, 0 },
{ 0x1801, 26, 23, 0 },
{ 0x1601, 27, 24, 0 },
{ 0x1401, 28, 25, 0 },
{ 0x1201, 29, 26, 0 },
{ 0x1101, 30, 27, 0 },
{ 0x0AC1, 31, 28, 0 },
{ 0x09C1, 32, 29, 0 },
{ 0x08A1, 33, 30, 0 },
{ 0x0521, 34, 31, 0 },
{ 0x0441, 35, 32, 0 },
{ 0x02A1, 36, 33, 0 },
{ 0x0221, 37, 34, 0 },
{ 0x0141, 38, 35, 0 },
{ 0x0111, 39, 36, 0 },
{ 0x0085, 40, 37, 0 },
{ 0x0049, 41, 38, 0 },
{ 0x0025, 42, 39, 0 },
{ 0x0015, 43, 40, 0 },
{ 0x0009, 44, 41, 0 },
{ 0x0005, 45, 42, 0 },
{ 0x0001, 45, 43, 0 },
{ 0x5601, 46, 46, 0 }
};
uint16_t ff_mqc_qe [2 * 47];
uint8_t ff_mqc_nlps[2 * 47];
uint8_t ff_mqc_nmps[2 * 47];
void ff_mqc_init_contexts(MqcState *mqc)
{
int i;
memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
mqc->cx_states[MQC_CX_UNI] = 2 * 46;
mqc->cx_states[MQC_CX_RL] = 2 * 3;
mqc->cx_states[0] = 2 * 4;
for (i = 0; i < 47; i++) {
ff_mqc_qe[2 * i] =
ff_mqc_qe[2 * i + 1] = cx_states[i].qe;
ff_mqc_nlps[2 * i] = 2 * cx_states[i].nlps + cx_states[i].sw;
ff_mqc_nlps[2 * i + 1] = 2 * cx_states[i].nlps + 1 - cx_states[i].sw;
ff_mqc_nmps[2 * i] = 2 * cx_states[i].nmps;
ff_mqc_nmps[2 * i + 1] = 2 * cx_states[i].nmps + 1;
}
}
/*
* MQ-coder: structures, common and decoder functions
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* 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.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_MQC_H
#define AVCODEC_MQC_H
/**
* MQ-coder
* @file
* @author Kamil Nowosad
*/
#include <stdint.h>
#define MQC_CX_UNI 17
#define MQC_CX_RL 18
extern uint16_t ff_mqc_qe[2 * 47];
extern uint8_t ff_mqc_nlps[2 * 47];
extern uint8_t ff_mqc_nmps[2 * 47];
typedef struct MqcState {
uint8_t *bp, *bpstart;
unsigned int a;
unsigned int c;
unsigned int ct;
uint8_t cx_states[19];
} MqcState;
/* decoder */
/**
* Initialize MQ-decoder.
* @param mqc MQ decoder state
* @param bp byte poiter
*/
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp);
/**
* MQ decoder.
* @param mqc MQ decoder state
* @param cxstate Context
* @return Decision (0 ot 1)
*/
int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate);
/* common */
/**
* MQ-coder context initialisations.
* @param mqc MQ-coder context
*/
void ff_mqc_init_contexts(MqcState *mqc);
#endif /* AVCODEC_MQC_H */
/*
* MQ-coder decoder
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* 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.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* MQ-coder decoder
* @file
* @author Kamil Nowosad
*/
#include "mqc.h"
static void bytein(MqcState *mqc)
{
if (*mqc->bp == 0xff) {
if (*(mqc->bp + 1) > 0x8f)
mqc->c++;
else {
mqc->bp++;
mqc->c += 2 + 0xfe00 - (*mqc->bp << 9);
}
} else {
mqc->bp++;
mqc->c += 1 + 0xff00 - (*mqc->bp << 8);
}
}
static int exchange(MqcState *mqc, uint8_t *cxstate, int lps)
{
int d;
if ((mqc->a < ff_mqc_qe[*cxstate]) ^ (!lps)) {
if (lps)
mqc->a = ff_mqc_qe[*cxstate];
d = *cxstate & 1;
*cxstate = ff_mqc_nmps[*cxstate];
} else {
if (lps)
mqc->a = ff_mqc_qe[*cxstate];
d = 1 - (*cxstate & 1);
*cxstate = ff_mqc_nlps[*cxstate];
}
// do RENORMD: see ISO/IEC 15444-1:2002 §C.3.3
do {
if (!(mqc->c & 0xff)) {
mqc->c -= 0x100;
bytein(mqc);
}
mqc->a += mqc->a;
mqc->c += mqc->c;
} while (!(mqc->a & 0x8000));
return d;
}
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp)
{
ff_mqc_init_contexts(mqc);
mqc->bp = bp;
mqc->c = (*mqc->bp ^ 0xff) << 16;
bytein(mqc);
mqc->c = mqc->c << 7;
mqc->a = 0x8000;
}
int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
{
mqc->a -= ff_mqc_qe[*cxstate];
if ((mqc->c >> 16) < mqc->a) {
if (mqc->a & 0x8000)
return *cxstate & 1;
else
return exchange(mqc, cxstate, 0);
} else {
mqc->c -= mqc->a << 16;
return exchange(mqc, cxstate, 1);
}
}
......@@ -151,6 +151,9 @@ fate-interplay-mve-8bit: CMD = framecrc -i $(SAMPLES)/interplay-mve/interplay-lo
FATE_SAMPLES_AVCONV-$(call DEMDEC, IPMOVIE, INTERPLAY_VIDEO) += fate-interplay-mve-16bit
fate-interplay-mve-16bit: CMD = framecrc -i $(SAMPLES)/interplay-mve/descent3-level5-16bit-partial.mve -pix_fmt rgb24 -an
FATE_SAMPLES_AVCONV-$(call DEMDEC, MXF, JPEG2000) += fate-jpeg2000-dcinema
fate-jpeg2000-dcinema: CMD = framecrc -flags +bitexact -i $(SAMPLES)/jpeg2000/chiens_dcinema2K.mxf
FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, KGV1) += fate-kgv1
fate-kgv1: CMD = framecrc -i $(SAMPLES)/kega/kgv1.avi -pix_fmt rgb555le -an
......
#tb 0: 1/24
0, 0, 0, 1, 12441600, 0xf0de508b
0, 1, 1, 1, 12441600, 0x8e50c249
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment