aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/intrax8.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-24 12:34:16 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-24 12:34:16 +0100
commit50fa5715bcc3e63143e8ae8d1ef57d9e0e6a6325 (patch)
tree42a0d40d95549de461eb1f15165d2317bc1e81a3 /libavcodec/intrax8.c
parent93c61c980d63101d7ea1664fd83c810e95ffdc06 (diff)
parent8072345e9f86d88fbc4a15c17cb03f1e4701c9a5 (diff)
downloadffmpeg-50fa5715bcc3e63143e8ae8d1ef57d9e0e6a6325.tar.gz
Merge commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5'
* commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5': intrax8: Keep a reference to the GetBitContext reader Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec/intrax8.c')
-rw-r--r--libavcodec/intrax8.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 2b37658cb7..9d3390cec4 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -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) {