Skip to content

Commit

Permalink
Обновлен ffmpeg n7.2-dev-568-g13129f1af4.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Nov 9, 2024
1 parent 1dc0f0f commit 884e597
Show file tree
Hide file tree
Showing 25 changed files with 601 additions and 110 deletions.
2 changes: 2 additions & 0 deletions docs/Changelog.Rus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

1.8.1.x dev
=============================
Обновлены библиотеки:
ffmpeg n7.2-dev-568-g13129f1af4.


1.8.1 - 2024-11-07
Expand Down
2 changes: 2 additions & 0 deletions docs/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

1.8.1.x dev
=============================
Updated libraries:
ffmpeg n7.2-dev-568-g13129f1af4.


1.8.1 - 2024-11-07
Expand Down
1 change: 1 addition & 0 deletions src/ExtLib/ffmpeg/libavcodec/allcodecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ extern const FFCodec ff_rv20_encoder;
extern const FFCodec ff_rv20_decoder;
extern const FFCodec ff_rv30_decoder;
extern const FFCodec ff_rv40_decoder;
extern const FFCodec ff_rv60_decoder;
extern const FFCodec ff_s302m_encoder;
extern const FFCodec ff_s302m_decoder;
extern const FFCodec ff_sanm_decoder;
Expand Down
7 changes: 7 additions & 0 deletions src/ExtLib/ffmpeg/libavcodec/codec_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("DNxUncompressed / SMPTE RDD 50"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_RV60,
.type = AVMEDIA_TYPE_VIDEO,
.name = "rv60",
.long_name = NULL_IF_CONFIG_SMALL("RealVideo 6.0"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
},

/* various PCM "codecs" */
{
Expand Down
1 change: 1 addition & 0 deletions src/ExtLib/ffmpeg/libavcodec/codec_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ enum AVCodecID {
AV_CODEC_ID_VMIX,
AV_CODEC_ID_LEAD,
AV_CODEC_ID_DNXUC,
AV_CODEC_ID_RV60,

/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
Expand Down
11 changes: 2 additions & 9 deletions src/ExtLib/ffmpeg/libavcodec/jpeg2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,15 @@ static void init_band_stepsize(AVCodecContext *avctx,
band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
break;
}
if (codsty->transform == FF_DWT97) {
band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2);
}
band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2);
}

if (band->f_stepsize > (INT_MAX >> 15)) {
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "stepsize out of range\n");
}

band->i_stepsize = band->f_stepsize * (1 << 15);

/* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = (int)floorf(band->f_stepsize * (1 << 15));
}

static int init_prec(AVCodecContext *avctx,
Expand Down
150 changes: 88 additions & 62 deletions src/ExtLib/ffmpeg/libavcodec/jpeg2000dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,14 +1885,15 @@ static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
&& !(t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {
if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1] & flags_mask, bandno))) {
int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y+1) * t1->stride + x+1] & flags_mask, &xorbit);
if (t1->mqc.raw)
t1->data[(y) * t1->stride + x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask;
else
t1->data[(y) * t1->stride + x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ?
-mask : mask;

if (t1->mqc.raw) {
t1->data[(y) * t1->stride + x] |= ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) << 31;
t1->data[(y) * t1->stride + x] |= mask;
} else {
t1->data[(y) * t1->stride + x] |= (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) << 31;
t1->data[(y) * t1->stride + x] |= mask;
}
ff_jpeg2000_set_significance(t1, x, y,
t1->data[(y) * t1->stride + x] < 0);
t1->data[(y) * t1->stride + x] & INT32_MIN);
}
t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_VIS;
}
Expand All @@ -1902,11 +1903,10 @@ static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
static void decode_refpass(Jpeg2000T1Context *t1, int width, int height,
int bpno, int vert_causal_ctx_csty_symbol)
{
int phalf, nhalf;
int phalf;
int y0, x, y;

phalf = 1 << (bpno - 1);
nhalf = -phalf;

for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
Expand All @@ -1915,10 +1915,13 @@ static void decode_refpass(Jpeg2000T1Context *t1, int width, int height,
int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ?
~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S) : -1;
int ctxno = ff_jpeg2000_getrefctxno(t1->flags[(y + 1) * t1->stride + x + 1] & flags_mask);
int r = ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states + ctxno)
? phalf : nhalf;
t1->data[(y) * t1->stride + x] += t1->data[(y) * t1->stride + x] < 0 ? -r : r;
t1->data[(y) * t1->stride + x] |= phalf;
if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno))
t1->data[(y) * t1->stride + x] |= phalf << 1;
else {
t1->data[(y) * t1->stride + x] &= ~(phalf << 1);

}
t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_REF;
}
}
Expand Down Expand Up @@ -1966,11 +1969,9 @@ static void decode_clnpass(const Jpeg2000DecoderContext *s, Jpeg2000T1Context *t
int xorbit;
int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y + 1) * t1->stride + x + 1] & flags_mask,
&xorbit);
t1->data[(y) * t1->stride + x] = (ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states + ctxno) ^
xorbit)
? -mask : mask;
ff_jpeg2000_set_significance(t1, x, y, t1->data[(y) * t1->stride + x] < 0);
t1->data[(y) * t1->stride + x] |= (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) << 31;
t1->data[(y) * t1->stride + x] |= mask;
ff_jpeg2000_set_significance(t1, x, y, t1->data[(y) * t1->stride + x] & INT32_MIN);
}
dec = 0;
t1->flags[(y + 1) * t1->stride + x + 1] &= ~JPEG2000_T1_VIS;
Expand All @@ -1991,9 +1992,9 @@ static void decode_clnpass(const Jpeg2000DecoderContext *s, Jpeg2000T1Context *t

static int decode_cblk(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk,
int width, int height, int bandpos, uint8_t roi_shift)
int width, int height, int bandpos, uint8_t roi_shift, const int M_b)
{
int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1;
int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1 + 31 - M_b - 1 - roi_shift;
int pass_cnt = 0;
int vert_causal_ctx_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_VSC;
int term_cnt = 0;
Expand Down Expand Up @@ -2068,22 +2069,25 @@ static int decode_cblk(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *cod
av_log(s->avctx, AV_LOG_WARNING, "Synthetic End of Stream Marker Read.\n");
}

/* Reconstruct the sample values */
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int32_t sign, n, val;
const uint32_t mask = UINT32_MAX >> (M_b + 1); // bit mask for ROI detection

n = x + (y * t1->stride);
val = t1->data[n];
sign = val & INT32_MIN;
val &= INT32_MAX;
/* ROI shift, if necessary */
if (roi_shift && (((uint32_t)val & ~mask) == 0))
val <<= roi_shift;
t1->data[n] = val | sign; /* NOTE: Binary point for reconstruction value is located in 31 - M_b */
}
}
return 1;
}

static inline int roi_shift_param(Jpeg2000Component *comp,
int quan_parameter)
{
uint8_t roi_shift;
int val;
roi_shift = comp->roi_shift;
val = (quan_parameter < 0)?-quan_parameter:quan_parameter;

if (val > (1 << roi_shift))
return (quan_parameter < 0)?-(val >> roi_shift):(val >> roi_shift);
return quan_parameter;
}

/* TODO: Verify dequantization for lossless case
* comp->data can be float or int
* band->stepsize can be float or int
Expand All @@ -2093,50 +2097,86 @@ static inline int roi_shift_param(Jpeg2000Component *comp,
/* Float dequantization of a codeblock.*/
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk,
Jpeg2000Component *comp,
Jpeg2000T1Context *t1, Jpeg2000Band *band)
Jpeg2000T1Context *t1, Jpeg2000Band *band, const int M_b)
{
int i, j;
int w = cblk->coord[0][1] - cblk->coord[0][0];
const int downshift = 31 - M_b;
float fscale = band->f_stepsize;
fscale /= (float)(1 << downshift);
for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x];
int *src = t1->data + j*t1->stride;
for (i = 0; i < w; ++i)
datap[i] = src[i] * band->f_stepsize;
for (i = 0; i < w; ++i) {
int val = src[i];
if (val < 0) // Convert sign-magnitude to two's complement
val = -(val & INT32_MAX);
datap[i] = (float)val * fscale;
}
}
}

/* Integer dequantization of a codeblock.*/
static void dequantization_int(int x, int y, Jpeg2000Cblk *cblk,
Jpeg2000Component *comp,
Jpeg2000T1Context *t1, Jpeg2000Band *band)
Jpeg2000T1Context *t1, Jpeg2000Band *band, const int M_b)
{
int i, j;
const int downshift = 31 - M_b;
int w = cblk->coord[0][1] - cblk->coord[0][0];
for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x];
int *src = t1->data + j*t1->stride;
if (band->i_stepsize == 32768) {
for (i = 0; i < w; ++i)
datap[i] = src[i] / 2;
for (i = 0; i < w; ++i) {
int val = src[i];
if (val < 0) // Convert sign-magnitude to two's complement
val = -((val & INT32_MAX) >> downshift);
else
val >>= downshift;
datap[i] = val;
}
} else {
// This should be VERY uncommon
for (i = 0; i < w; ++i)
datap[i] = (src[i] * (int64_t)band->i_stepsize) / 65536;
for (i = 0; i < w; ++i) {
int val = src[i];
if (val < 0) // Convert sign-magnitude to two's complement
val = -((val & INT32_MAX) >> downshift);
else
val >>= downshift;
datap[i] = (val * (int64_t)band->i_stepsize) / 65536;
}
}
}
}

static void dequantization_int_97(int x, int y, Jpeg2000Cblk *cblk,
Jpeg2000Component *comp,
Jpeg2000T1Context *t1, Jpeg2000Band *band)
Jpeg2000T1Context *t1, Jpeg2000Band *band, const int M_b)
{
int i, j;
int w = cblk->coord[0][1] - cblk->coord[0][0];
float fscale = band->f_stepsize;
const int downshift = 31 - M_b;
const int PRESCALE = 6; // At least 6 is required to pass the conformance tests in ISO/IEC 15444-4
int scale;

fscale /= (float)(1 << downshift);
fscale *= (float)(1 << PRESCALE);
fscale *= (float)(1 << (16 + I_PRESHIFT));
scale = (int)(fscale + 0.5);
band->i_stepsize = scale;
for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x];
int *src = t1->data + j*t1->stride;
for (i = 0; i < w; ++i)
datap[i] = (src[i] * (int64_t)band->i_stepsize + (1<<15)) >> 16;
for (i = 0; i < w; ++i) {
int val = src[i];
if (val < 0) // Convert sign-magnitude to two's complement
val = -(val & INT32_MAX);
// Shifting down to prevent overflow in dequantization
val = (val + (1 << (PRESCALE - 1))) >> PRESCALE;
datap[i] = RSHIFT(val * (int64_t)band->i_stepsize, 16);
}
}
}

Expand Down Expand Up @@ -2168,18 +2208,6 @@ static inline void mct_decode(const Jpeg2000DecoderContext *s, Jpeg2000Tile *til
s->dsp.mct_decode[tile->codsty[0].transform](src[0], src[1], src[2], csize);
}

static inline void roi_scale_cblk(Jpeg2000Cblk *cblk,
Jpeg2000Component *comp,
Jpeg2000T1Context *t1)
{
int i, j;
int w = cblk->coord[0][1] - cblk->coord[0][0];
for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
int *src = t1->data + j*t1->stride;
for (i = 0; i < w; ++i)
src[i] = roi_shift_param(comp, src[i]);
}
}

static inline int tile_codeblocks(const Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
{
Expand Down Expand Up @@ -2242,7 +2270,7 @@ static inline int tile_codeblocks(const Jpeg2000DecoderContext *s, Jpeg2000Tile
ret = decode_cblk(s, codsty, &t1, cblk,
cblk->coord[0][1] - cblk->coord[0][0],
cblk->coord[1][1] - cblk->coord[1][0],
bandpos, comp->roi_shift);
bandpos, comp->roi_shift, M_b);

if (ret)
coded = 1;
Expand All @@ -2251,14 +2279,12 @@ static inline int tile_codeblocks(const Jpeg2000DecoderContext *s, Jpeg2000Tile
x = cblk->coord[0][0] - band->coord[0][0];
y = cblk->coord[1][0] - band->coord[1][0];

if (comp->roi_shift)
roi_scale_cblk(cblk, comp, &t1);
if (codsty->transform == FF_DWT97)
dequantization_float(x, y, cblk, comp, &t1, band);
dequantization_float(x, y, cblk, comp, &t1, band, M_b);
else if (codsty->transform == FF_DWT97_INT)
dequantization_int_97(x, y, cblk, comp, &t1, band);
dequantization_int_97(x, y, cblk, comp, &t1, band, M_b);
else
dequantization_int(x, y, cblk, comp, &t1, band);
dequantization_int(x, y, cblk, comp, &t1, band, M_b);
} /* end cblk */
} /*end prec */
} /* end band */
Expand Down
Loading

0 comments on commit 884e597

Please sign in to comment.