mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
Merge commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5'
* commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5': intrax8: Keep a reference to the GetBitContext reader Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
commit
50fa5715bc
@ -133,7 +133,6 @@ static void x8_reset_vlc_tables(IntraX8Context *w)
|
||||
|
||||
static inline void x8_select_ac_table(IntraX8Context *const w, int mode)
|
||||
{
|
||||
MpegEncContext *const s = w->s;
|
||||
int table_index;
|
||||
|
||||
av_assert2(mode < 4);
|
||||
@ -141,7 +140,7 @@ static inline void x8_select_ac_table(IntraX8Context *const w, int mode)
|
||||
if (w->j_ac_vlc[mode])
|
||||
return;
|
||||
|
||||
table_index = get_bits(&s->gb, 3);
|
||||
table_index = get_bits(w->gb, 3);
|
||||
// 2 modes use same tables
|
||||
w->j_ac_vlc[mode] = &j_ac_vlc[w->quant < 13][mode >> 1][table_index];
|
||||
av_assert2(w->j_ac_vlc[mode]);
|
||||
@ -149,14 +148,12 @@ static inline void x8_select_ac_table(IntraX8Context *const w, int mode)
|
||||
|
||||
static inline int x8_get_orient_vlc(IntraX8Context *w)
|
||||
{
|
||||
MpegEncContext *const s = w->s;
|
||||
|
||||
if (!w->j_orient_vlc) {
|
||||
int table_index = get_bits(&s->gb, 1 + (w->quant < 13));
|
||||
int table_index = get_bits(w->gb, 1 + (w->quant < 13));
|
||||
w->j_orient_vlc = &j_orient_vlc[w->quant < 13][table_index];
|
||||
}
|
||||
|
||||
return get_vlc2(&s->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
|
||||
return get_vlc2(w->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
|
||||
}
|
||||
|
||||
#define extra_bits(eb) (eb) // 3 bits
|
||||
@ -209,11 +206,10 @@ static const uint32_t ac_decode_table[] = {
|
||||
static void x8_get_ac_rlf(IntraX8Context *const w, const int mode,
|
||||
int *const run, int *const level, int *const final)
|
||||
{
|
||||
MpegEncContext *const s = w->s;
|
||||
int i, e;
|
||||
|
||||
// x8_select_ac_table(w, mode);
|
||||
i = get_vlc2(&s->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD);
|
||||
i = get_vlc2(w->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD);
|
||||
|
||||
if (i < 46) { // [0-45]
|
||||
int t, l;
|
||||
@ -252,7 +248,7 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const int mode,
|
||||
i -= 46;
|
||||
sm = ac_decode_table[i];
|
||||
|
||||
e = get_bits(&s->gb, sm & 0xF);
|
||||
e = get_bits(w->gb, sm & 0xF);
|
||||
sm >>= 8; // 3bits
|
||||
mask = sm & 0xff;
|
||||
sm >>= 8; // 1bit
|
||||
@ -269,13 +265,13 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const int mode,
|
||||
};
|
||||
|
||||
(*final) = !(i & 1);
|
||||
e = get_bits(&s->gb, 5); // get the extra bits
|
||||
e = get_bits(w->gb, 5); // get the extra bits
|
||||
(*run) = crazy_mix_runlevel[e] >> 4;
|
||||
(*level) = crazy_mix_runlevel[e] & 0x0F;
|
||||
} else {
|
||||
(*level) = get_bits(&s->gb, 7 - 3 * (i & 1));
|
||||
(*run) = get_bits(&s->gb, 6);
|
||||
(*final) = get_bits1(&s->gb);
|
||||
(*level) = get_bits(w->gb, 7 - 3 * (i & 1));
|
||||
(*run) = get_bits(w->gb, 6);
|
||||
(*final) = get_bits1(w->gb);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -290,17 +286,16 @@ static const uint8_t dc_index_offset[] = {
|
||||
static int x8_get_dc_rlf(IntraX8Context *const w, const int mode,
|
||||
int *const level, int *const final)
|
||||
{
|
||||
MpegEncContext *const s = w->s;
|
||||
int i, e, c;
|
||||
|
||||
av_assert2(mode < 3);
|
||||
if (!w->j_dc_vlc[mode]) {
|
||||
int table_index = get_bits(&s->gb, 3);
|
||||
int table_index = get_bits(w->gb, 3);
|
||||
// 4 modes, same table
|
||||
w->j_dc_vlc[mode] = &j_dc_vlc[w->quant < 13][table_index];
|
||||
}
|
||||
|
||||
i = get_vlc2(&s->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD);
|
||||
i = get_vlc2(w->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD);
|
||||
|
||||
/* (i >= 17) { i -= 17; final =1; } */
|
||||
c = i > 16;
|
||||
@ -314,7 +309,7 @@ static int x8_get_dc_rlf(IntraX8Context *const w, const int mode,
|
||||
c = (i + 1) >> 1; // hackish way to calculate dc_extra_sbits[]
|
||||
c -= c > 1;
|
||||
|
||||
e = get_bits(&s->gb, c); // get the extra bits
|
||||
e = get_bits(w->gb, c); // get the extra bits
|
||||
i = dc_index_offset[i] + (e >> 1);
|
||||
|
||||
e = -(e & 1); // 0, 0xffffff
|
||||
@ -643,7 +638,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
|
||||
level = (level + 1) * w->dquant;
|
||||
level += w->qsum;
|
||||
|
||||
sign = -get_bits1(&s->gb);
|
||||
sign = -get_bits1(w->gb);
|
||||
level = (level ^ sign) - sign;
|
||||
|
||||
if (use_quant_matrix)
|
||||
@ -776,17 +771,19 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
|
||||
}
|
||||
|
||||
int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
||||
GetBitContext *gb,
|
||||
int dquant, int quant_offset, int loopfilter)
|
||||
{
|
||||
MpegEncContext *const s = w->s;
|
||||
int mb_xy;
|
||||
w->use_quant_matrix = get_bits1(&s->gb);
|
||||
|
||||
w->gb = gb;
|
||||
w->dquant = dquant;
|
||||
w->quant = dquant >> 1;
|
||||
w->qsum = quant_offset;
|
||||
w->frame = pict->f;
|
||||
w->loopfilter = loopfilter;
|
||||
w->use_quant_matrix = get_bits1(w->gb);
|
||||
|
||||
w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant;
|
||||
if (w->quant < 5) {
|
||||
|
@ -48,6 +48,7 @@ typedef struct IntraX8Context {
|
||||
int qsum;
|
||||
int loopfilter;
|
||||
AVFrame *frame;
|
||||
GetBitContext *gb;
|
||||
|
||||
// calculated per frame
|
||||
int quant_dc_chroma;
|
||||
@ -85,18 +86,19 @@ void ff_intrax8_common_end(IntraX8Context *w);
|
||||
|
||||
/**
|
||||
* Decode single IntraX8 frame.
|
||||
* The parent codec must fill s->gb (bitstream).
|
||||
* The parent codec must call ff_mpv_frame_start() before calling this function.
|
||||
* The parent codec must call ff_mpv_frame_end() after calling this function.
|
||||
* This function does not use ff_mpv_decode_mb().
|
||||
* lowres decoding is theoretically impossible.
|
||||
* @param w pointer to IntraX8Context
|
||||
* @param pict the output Picture containing an AVFrame
|
||||
* @param gb open bitstream reader
|
||||
* @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
|
||||
* @param quant_offset offset away from zero
|
||||
* @param loopfilter enable filter after decoding a block
|
||||
*/
|
||||
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
|
||||
GetBitContext *gb,
|
||||
int quant, int halfpq, int loopfilter);
|
||||
|
||||
#endif /* AVCODEC_INTRAX8_H */
|
||||
|
@ -2931,7 +2931,7 @@ void ff_vc1_decode_blocks(VC1Context *v)
|
||||
|
||||
v->s.esc3_level_length = 0;
|
||||
if (v->x8_type) {
|
||||
ff_intrax8_decode_picture(&v->x8, &v->s.current_picture,
|
||||
ff_intrax8_decode_picture(&v->x8, &v->s.current_picture, &v->s.gb,
|
||||
2 * v->pq + v->halfpq, v->pq * !v->pquantizer,
|
||||
v->s.loop_filter);
|
||||
|
||||
|
@ -219,7 +219,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
|
||||
s->picture_number++; // FIXME ?
|
||||
|
||||
if (w->j_type) {
|
||||
ff_intrax8_decode_picture(&w->x8, &s->current_picture,
|
||||
ff_intrax8_decode_picture(&w->x8, &s->current_picture, &s->gb,
|
||||
2 * s->qscale, (s->qscale - 1) | 1,
|
||||
s->loop_filter);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user