]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/intrax8.c
Make 8SVX codec names just a single word for consistency with other codec names.
[ffmpeg] / libavcodec / intrax8.c
index 1f006f9ce9eb8c773a0079e8c639f121d5d1917c..0436deb4ce865ac008b37b9705a1eab7eddb5e69 100644 (file)
@@ -18,7 +18,7 @@
 
 /**
  * @file intrax8.c
- * @brief IntraX8 (J-Frame) sub-decoder, used by wmv2 and vc1
+ * @brief IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1
  */
 
 #include "avcodec.h"
@@ -53,10 +53,10 @@ static void x8_vlc_init(){
               1)
 //set ac tables
     for(i=0;i<8;i++){
-        init_ac_vlc( j_ac_vlc[0][0][i], ff_x8_ac0_highquant_table[i][0] );
-        init_ac_vlc( j_ac_vlc[0][1][i], ff_x8_ac1_highquant_table[i][0] );
-        init_ac_vlc( j_ac_vlc[1][0][i], ff_x8_ac0_lowquant_table [i][0] );
-        init_ac_vlc( j_ac_vlc[1][1][i], ff_x8_ac1_lowquant_table [i][0] );
+        init_ac_vlc( j_ac_vlc[0][0][i], x8_ac0_highquant_table[i][0] );
+        init_ac_vlc( j_ac_vlc[0][1][i], x8_ac1_highquant_table[i][0] );
+        init_ac_vlc( j_ac_vlc[1][0][i], x8_ac0_lowquant_table [i][0] );
+        init_ac_vlc( j_ac_vlc[1][1][i], x8_ac1_lowquant_table [i][0] );
     }
 #undef init_ac_vlc
 
@@ -68,8 +68,8 @@ static void x8_vlc_init(){
         &src[0],4,2, \
         1);
     for(i=0;i<8;i++){
-        init_dc_vlc( j_dc_vlc[0][i], ff_x8_dc_highquant_table[i][0]);
-        init_dc_vlc( j_dc_vlc[1][i], ff_x8_dc_lowquant_table [i][0]);
+        init_dc_vlc( j_dc_vlc[0][i], x8_dc_highquant_table[i][0]);
+        init_dc_vlc( j_dc_vlc[1][i], x8_dc_lowquant_table [i][0]);
     }
 #undef init_dc_vlc
 
@@ -81,15 +81,15 @@ static void x8_vlc_init(){
     &src[0],4,2, \
     1);
     for(i=0;i<2;i++){
-        init_or_vlc( j_orient_vlc[0][i], ff_x8_orient_highquant_table[i][0]);
+        init_or_vlc( j_orient_vlc[0][i], x8_orient_highquant_table[i][0]);
     }
     for(i=0;i<4;i++){
-        init_or_vlc( j_orient_vlc[1][i], ff_x8_orient_lowquant_table [i][0])
+        init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0])
     }
 }
 #undef init_or_vlc
 
-static inline void x8_reset_vlc_tables(IntraX8Context * w){
+static void x8_reset_vlc_tables(IntraX8Context * w){
     memset(w->j_dc_vlc,0,sizeof(w->j_dc_vlc));
     memset(w->j_ac_vlc,0,sizeof(w->j_ac_vlc));
     w->j_orient_vlc=NULL;
@@ -194,7 +194,7 @@ static void x8_get_ac_rlf(IntraX8Context * const w, const int mode,
   i==20-21 r=0-1  l=2 ;r=i& %00001
   i==22    r=0    l=3 ;r=i& %00000
 l=lut_l[i/2]={0,0,0,0,0,0,0,0,1,1,2,3}[i>>1];// 11 10'01 01'00 00'00 00'00 00'00 00 => 0xE50000
-t=lut_mask[l]={0x0f,0x03,0x01,0x00}[l]; as i<256 the higher bits doesn't matter */
+t=lut_mask[l]={0x0f,0x03,0x01,0x00}[l]; as i<256 the higher bits do not matter */
         l=(0xE50000>>(i&(0x1E)))&3;/*0x1E or (~1) or ((i>>1)<<1)*/
         t=(0x01030F>>(l<<3));
 
@@ -278,7 +278,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma
     int sum;
     int quant;
 
-    s->dsp.x8_setup_spacial_compensation(s->dest[chroma], s->edge_emu_buffer,
+    s->dsp.x8_setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer,
                                           s->current_picture.linesize[chroma>0],
                                           &range, &sum, w->edges);
     if(chroma){
@@ -291,7 +291,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma
     w->flat_dc=0;
     if(range < quant || range < 3){
         w->orient=0;
-        if(range < 3){//yep you read right, idct error of +-1 may break decoding!
+        if(range < 3){//yep you read right, a +-1 idct error may break decoding!
             w->flat_dc=1;
             sum+=9;
             w->predicted_dc = (sum*6899)>>17;//((1<<17)+9)/(8+8+1+2)=6899
@@ -374,15 +374,15 @@ static void x8_get_prediction(IntraX8Context * const w){
             w->orient  = 0;
             return;
     }
-    //no edge cases.
+    //no edge cases
     b= w->prediction_table[2*s->mb_x   + !(s->mb_y&1) ];//block[x  ][y-1]
     a= w->prediction_table[2*s->mb_x-2 +  (s->mb_y&1) ];//block[x-1][y  ]
     c= w->prediction_table[2*s->mb_x-2 + !(s->mb_y&1) ];//block[x-1][y-1]
 
     w->est_run = FFMIN(b,a);
-    /*this condition have nothing to do with w->edges, even if it looks similar
-      it would triger if e.g. x=3;y=2;
-      I guess somebody wrote something wrong and it became standard */
+    /* This condition has nothing to do with w->edges, even if it looks
+       similar it would trigger if e.g. x=3;y=2;
+       I guess somebody wrote something wrong and it became standard. */
     if( (s->mb_x & s->mb_y) != 0 ) w->est_run=FFMIN(c,w->est_run);
     w->est_run>>=2;
 
@@ -500,7 +500,7 @@ static const int16_t quant_table[64] = {
 };
 
 static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
-MpegEncContext * const s= w->s;
+    MpegEncContext * const s= w->s;
 
     uint8_t * scantable;
     int final,run,level;
@@ -614,7 +614,7 @@ MpegEncContext * const s= w->s;
     if(w->flat_dc){
         dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.linesize[!!chroma]);
     }else{
-        s->dsp.x8_spacial_compensation[w->orient]( s->edge_emu_buffer,
+        s->dsp.x8_spatial_compensation[w->orient]( s->edge_emu_buffer,
                                             s->dest[chroma],
                                             s->current_picture.linesize[!!chroma] );
     }
@@ -643,9 +643,9 @@ block_placed:
     return 0;
 }
 
-static inline void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
+static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
 //not s->linesize as this would be wrong for field pics
-//not that IntraX8 have interlace support ;)
+//not that IntraX8 has interlacing support ;)
     const int linesize  = s->current_picture.linesize[0];
     const int uvlinesize= s->current_picture.linesize[1];
 
@@ -676,16 +676,25 @@ void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s){
     ff_init_scantable(s->dsp.idct_permutation, &w->scantable[2], wmv1_scantable[3]);
 }
 
+/**
+ * Destroy IntraX8 frame structure.
+ * @param w pointer to IntraX8Context
+ */
+void ff_intrax8_common_end(IntraX8Context * w)
+{
+    av_freep(&w->prediction_table);
+}
+
 /**
  * Decode single IntraX8 frame.
  * The parent codec must fill s->loopfilter and s->gb (bitstream).
- * The parent codec must call MPV_frame_start(), ff_er_frame_start() before calling this function
+ * The parent codec must call MPV_frame_start(), ff_er_frame_start() before calling this function.
  * The parent codec must call ff_er_frame_end(), MPV_frame_end() after calling this function.
  * This function does not use MPV_decode_mb().
  * lowres decoding is theoretically impossible.
  * @param w pointer to IntraX8Context
- * @param dquant doubled quantizer, it would be odd in case of vc1 halfpq==1
- * @param quant_offset offset away from zero.
+ * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
+ * @param quant_offset offset away from zero
  */
 //FIXME extern uint8_t wmv3_dc_scale_table[32];
 int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_offset){
@@ -724,7 +733,7 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of
                 x8_get_prediction_chroma(w);
 
                 /*when setting up chroma, no vlc is read,
-                so no error condition could be reached*/
+                so no error condition can be reached*/
                 x8_setup_spatial_predictor(w,1);
                 if(x8_decode_intra_mb(w,1)) goto error;