[FFmpeg-cvslog] Merge commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5'

Derek Buitenhuis git at videolan.org
Sun Apr 24 13:47:43 CEST 2016


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Sun Apr 24 12:34:16 2016 +0100| [50fa5715bcc3e63143e8ae8d1ef57d9e0e6a6325] | committer: Derek Buitenhuis

Merge commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5'

* commit '8072345e9f86d88fbc4a15c17cb03f1e4701c9a5':
  intrax8: Keep a reference to the GetBitContext reader

Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50fa5715bcc3e63143e8ae8d1ef57d9e0e6a6325
---

 libavcodec/intrax8.c   |   35 ++++++++++++++++-------------------
 libavcodec/intrax8.h   |    4 +++-
 libavcodec/vc1_block.c |    2 +-
 libavcodec/wmv2dec.c   |    2 +-
 4 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 2b37658..9d3390c 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) {
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 64a33ce..988f0c1 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -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 */
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 50c50c2..676da53 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -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);
 
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 4aef773..629dc80 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -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);
 


======================================================================

diff --cc libavcodec/intrax8.c
index 2b37658,f23ab81..9d3390c
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@@ -133,30 -132,30 +133,27 @@@ static void x8_reset_vlc_tables(IntraX8
  
  static inline void x8_select_ac_table(IntraX8Context *const w, int mode)
  {
-     MpegEncContext *const s = w->s;
      int table_index;
  
 -    assert(mode < 4);
 +    av_assert2(mode < 4);
  
      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];
 -
 -    assert(w->j_ac_vlc[mode]);
 +    av_assert2(w->j_ac_vlc[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];
      }
 -    assert(w->j_orient_vlc);
 -    assert(w->j_orient_vlc->table);
  
-     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
@@@ -290,17 -288,18 +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;
  
 -    assert(mode < 3);
 +    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];
      }
 -    assert(w->j_dc_vlc);
 -    assert(w->j_dc_vlc[mode]->table);
  
-     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;
@@@ -780,8 -775,9 +776,8 @@@ int ff_intrax8_decode_picture(IntraX8Co
  {
      MpegEncContext *const s = w->s;
      int mb_xy;
-     w->use_quant_matrix = get_bits1(&s->gb);
 -    assert(s);
  
+     w->gb     = gb;
      w->dquant = dquant;
      w->quant  = dquant >> 1;
      w->qsum   = quant_offset;
diff --cc libavcodec/intrax8.h
index 64a33ce,f07349f..988f0c1
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@@ -88,10 -86,9 +89,10 @@@ void ff_intrax8_common_end(IntraX8Conte
   * 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



More information about the ffmpeg-cvslog mailing list