mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-24 17:12:34 +02:00
diractab: expose the maximum quantization index as a macro
Prevents having to have random magic values in the decoder and a separate macro in the encoder. Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
This commit is contained in:
parent
b9c6c5f453
commit
09d89d9406
@ -486,7 +486,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
|
|||||||
b->quant = quant;
|
b->quant = quant;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->quant > 115) {
|
if (b->quant > DIRAC_MAX_QUANT_INDEX) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
|
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
|
||||||
b->quant = 0;
|
b->quant = 0;
|
||||||
return;
|
return;
|
||||||
@ -676,12 +676,12 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
|
|||||||
uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
|
uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (quant > 115) {
|
if (quant > DIRAC_MAX_QUANT_INDEX) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", quant);
|
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", quant);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qfactor = ff_dirac_qscale_tab[quant & 0x7f];
|
qfactor = ff_dirac_qscale_tab[quant];
|
||||||
qoffset = ff_dirac_qoffset_intra_tab[quant & 0x7f] + 2;
|
qoffset = ff_dirac_qoffset_intra_tab[quant] + 2;
|
||||||
/* we have to constantly check for overread since the spec explicitly
|
/* we have to constantly check for overread since the spec explicitly
|
||||||
requires this, with the meaning that all remaining coeffs are set to 0 */
|
requires this, with the meaning that all remaining coeffs are set to 0 */
|
||||||
if (get_bits_count(gb) >= bits_end)
|
if (get_bits_count(gb) >= bits_end)
|
||||||
|
@ -38,4 +38,6 @@ extern const int32_t ff_dirac_qoffset_intra_tab[120];
|
|||||||
/* Scaling offsets needed for quantization/dequantization, for inter frames */
|
/* Scaling offsets needed for quantization/dequantization, for inter frames */
|
||||||
extern const int ff_dirac_qoffset_inter_tab[122];
|
extern const int ff_dirac_qoffset_inter_tab[122];
|
||||||
|
|
||||||
|
#define DIRAC_MAX_QUANT_INDEX (FF_ARRAY_ELEMS(ff_dirac_qscale_tab))
|
||||||
|
|
||||||
#endif /* AVCODEC_DIRACTAB_H */
|
#endif /* AVCODEC_DIRACTAB_H */
|
||||||
|
@ -29,11 +29,8 @@
|
|||||||
#include "vc2enc_dwt.h"
|
#include "vc2enc_dwt.h"
|
||||||
#include "diractab.h"
|
#include "diractab.h"
|
||||||
|
|
||||||
/* Quantizations above this usually zero coefficients and lower the quality */
|
|
||||||
#define MAX_QUANT_INDEX FF_ARRAY_ELEMS(ff_dirac_qscale_tab)
|
|
||||||
|
|
||||||
/* Total range is -COEF_LUT_TAB to +COEFF_LUT_TAB, but total tab size is half
|
/* Total range is -COEF_LUT_TAB to +COEFF_LUT_TAB, but total tab size is half
|
||||||
* (COEF_LUT_TAB*MAX_QUANT_INDEX) since the sign is appended during encoding */
|
* (COEF_LUT_TAB*DIRAC_MAX_QUANT_INDEX), as the sign is appended during encoding */
|
||||||
#define COEF_LUT_TAB 2048
|
#define COEF_LUT_TAB 2048
|
||||||
|
|
||||||
/* The limited size resolution of each slice forces us to do this */
|
/* The limited size resolution of each slice forces us to do this */
|
||||||
@ -109,7 +106,7 @@ typedef struct Plane {
|
|||||||
|
|
||||||
typedef struct SliceArgs {
|
typedef struct SliceArgs {
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
int cache[MAX_QUANT_INDEX];
|
int cache[DIRAC_MAX_QUANT_INDEX];
|
||||||
void *ctx;
|
void *ctx;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
@ -1074,7 +1071,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
|
|||||||
s->picture_number = 0;
|
s->picture_number = 0;
|
||||||
|
|
||||||
/* Total allowed quantization range */
|
/* Total allowed quantization range */
|
||||||
s->q_ceil = MAX_QUANT_INDEX;
|
s->q_ceil = DIRAC_MAX_QUANT_INDEX;
|
||||||
|
|
||||||
s->ver.major = 2;
|
s->ver.major = 2;
|
||||||
s->ver.minor = 0;
|
s->ver.minor = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user