Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
ulti: Fix invalid reads
lavf: dealloc private options in av_write_trailer
yadif: support 10bit YUV
vc1: mark with ER_MB_ERROR bits overconsumption
lavc: introduce ER_MB_END and ER_MB_ERROR
error_resilience: use the ER_ namespace
build: move inclusion of subdir.mak to main subdir loop
rv34: NEON optimised 4x4 dequant
rv34: move 4x4 dequant to RV34DSPContext
aacdec: Use intfloat.h rather than local punning union.

Conflicts:
libavcodec/h264.c
libavcodec/vc1dec.c
libavfilter/vf_yadif.c
libavformat/Makefile

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/12/14 07:21:37
Showing 30 changed files
... ...
@@ -77,6 +77,7 @@ define DOSUBDIR
77 77
 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
78 78
 SUBDIR := $(1)/
79 79
 include $(SRC_PATH)/$(1)/Makefile
80
+include $(SRC_PATH)/subdir.mak
80 81
 endef
81 82
 
82 83
 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
... ...
@@ -732,8 +732,6 @@ DIRS = alpha arm bfin mlib ppc ps2 sh4 sparc x86
732 732
 
733 733
 CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF)
734 734
 
735
-include $(SRC_PATH)/subdir.mak
736
-
737 735
 $(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o
738 736
 
739 737
 TRIG_TABLES  = cos cos_fixed sin
... ...
@@ -98,6 +98,7 @@
98 98
 #include "aacsbr.h"
99 99
 #include "mpeg4audio.h"
100 100
 #include "aacadtsdec.h"
101
+#include "libavutil/intfloat.h"
101 102
 
102 103
 #include <assert.h>
103 104
 #include <errno.h>
... ...
@@ -108,11 +109,6 @@
108 108
 #   include "arm/aac.h"
109 109
 #endif
110 110
 
111
-union float754 {
112
-    float f;
113
-    uint32_t i;
114
-};
115
-
116 111
 static VLC vlc_scalefactors;
117 112
 static VLC vlc_spectral[11];
118 113
 
... ...
@@ -1023,7 +1019,7 @@ static inline float *VMUL4(float *dst, const float *v, unsigned idx,
1023 1023
 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
1024 1024
                             unsigned sign, const float *scale)
1025 1025
 {
1026
-    union float754 s0, s1;
1026
+    union av_intfloat32 s0, s1;
1027 1027
 
1028 1028
     s0.f = s1.f = *scale;
1029 1029
     s0.i ^= sign >> 1 << 31;
... ...
@@ -1041,8 +1037,8 @@ static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
1041 1041
                             unsigned sign, const float *scale)
1042 1042
 {
1043 1043
     unsigned nz = idx >> 12;
1044
-    union float754 s = { .f = *scale };
1045
-    union float754 t;
1044
+    union av_intfloat32 s = { .f = *scale };
1045
+    union av_intfloat32 t;
1046 1046
 
1047 1047
     t.i = s.i ^ (sign & 1U<<31);
1048 1048
     *dst++ = v[idx    & 3] * t.f;
... ...
@@ -1291,7 +1287,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
1291 1291
 
1292 1292
 static av_always_inline float flt16_round(float pf)
1293 1293
 {
1294
-    union float754 tmp;
1294
+    union av_intfloat32 tmp;
1295 1295
     tmp.f = pf;
1296 1296
     tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
1297 1297
     return tmp.f;
... ...
@@ -1299,7 +1295,7 @@ static av_always_inline float flt16_round(float pf)
1299 1299
 
1300 1300
 static av_always_inline float flt16_even(float pf)
1301 1301
 {
1302
-    union float754 tmp;
1302
+    union av_intfloat32 tmp;
1303 1303
     tmp.f = pf;
1304 1304
     tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
1305 1305
     return tmp.f;
... ...
@@ -1307,7 +1303,7 @@ static av_always_inline float flt16_even(float pf)
1307 1307
 
1308 1308
 static av_always_inline float flt16_trunc(float pf)
1309 1309
 {
1310
-    union float754 pun;
1310
+    union av_intfloat32 pun;
1311 1311
     pun.f = pf;
1312 1312
     pun.i &= 0xFFFF0000U;
1313 1313
     return pun.f;
... ...
@@ -25,9 +25,12 @@
25 25
 
26 26
 void ff_rv34_inv_transform_neon(DCTELEM *block);
27 27
 void ff_rv34_inv_transform_noround_neon(DCTELEM *block);
28
+void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q);
28 29
 
29 30
 void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp)
30 31
 {
31 32
     c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon;
32 33
     c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon;
34
+
35
+    c->rv34_dequant4x4 = ff_rv34_dequant4x4_neon;
33 36
 }
... ...
@@ -107,3 +107,27 @@ function ff_rv34_inv_transform_noround_neon, export=1
107 107
         vst4.16         {d0[3], d1[3], d2[3], d3[3]}, [r2,:64], r1
108 108
         bx              lr
109 109
 endfunc
110
+
111
+function ff_rv34_dequant4x4_neon, export=1
112
+        mov             r3,  r0
113
+        mov             r12, #16
114
+        vdup.16         q0,  r2
115
+        vmov.16         d0[0], r1
116
+        vld1.16         {d2},     [r0,:64], r12
117
+        vld1.16         {d4},     [r0,:64], r12
118
+        vld1.16         {d6},     [r0,:64], r12
119
+        vld1.16         {d16},    [r0,:64], r12
120
+        vmull.s16       q1,  d2,  d0
121
+        vmull.s16       q2,  d4,  d1
122
+        vmull.s16       q3,  d6,  d1
123
+        vmull.s16       q8,  d16, d1
124
+        vqrshrn.s32     d2,  q1,  #4
125
+        vqrshrn.s32     d4,  q2,  #4
126
+        vqrshrn.s32     d6,  q3,  #4
127
+        vqrshrn.s32     d16, q8,  #4
128
+        vst1.16         {d2},     [r3,:64], r12
129
+        vst1.16         {d4},     [r3,:64], r12
130
+        vst1.16         {d6},     [r3,:64], r12
131
+        vst1.16         {d16},    [r3,:64], r12
132
+        bx              lr
133
+endfunc
... ...
@@ -167,14 +167,14 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
167 167
             error= s->error_status_table[mb_index];
168 168
 
169 169
             if(IS_INTER(s->current_picture.f.mb_type[mb_index])) continue; //inter
170
-            if(!(error&DC_ERROR)) continue;           //dc-ok
170
+            if(!(error&ER_DC_ERROR)) continue;           //dc-ok
171 171
 
172 172
             /* right block */
173 173
             for(j=b_x+1; j<w; j++){
174 174
                 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
175 175
                 int error_j= s->error_status_table[mb_index_j];
176 176
                 int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
177
-                if(intra_j==0 || !(error_j&DC_ERROR)){
177
+                if(intra_j==0 || !(error_j&ER_DC_ERROR)){
178 178
                     color[0]= dc[j + b_y*stride];
179 179
                     distance[0]= j-b_x;
180 180
                     break;
... ...
@@ -186,7 +186,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
186 186
                 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
187 187
                 int error_j= s->error_status_table[mb_index_j];
188 188
                 int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
189
-                if(intra_j==0 || !(error_j&DC_ERROR)){
189
+                if(intra_j==0 || !(error_j&ER_DC_ERROR)){
190 190
                     color[1]= dc[j + b_y*stride];
191 191
                     distance[1]= b_x-j;
192 192
                     break;
... ...
@@ -198,7 +198,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
198 198
                 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
199 199
                 int error_j= s->error_status_table[mb_index_j];
200 200
                 int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
201
-                if(intra_j==0 || !(error_j&DC_ERROR)){
201
+                if(intra_j==0 || !(error_j&ER_DC_ERROR)){
202 202
                     color[2]= dc[b_x + j*stride];
203 203
                     distance[2]= j-b_y;
204 204
                     break;
... ...
@@ -210,7 +210,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, i
210 210
                 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
211 211
                 int error_j= s->error_status_table[mb_index_j];
212 212
                 int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
213
-                if(intra_j==0 || !(error_j&DC_ERROR)){
213
+                if(intra_j==0 || !(error_j&ER_DC_ERROR)){
214 214
                     color[3]= dc[b_x + j*stride];
215 215
                     distance[3]= b_y-j;
216 216
                     break;
... ...
@@ -250,8 +250,8 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
250 250
             int right_status= s->error_status_table[((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride];
251 251
             int left_intra  = IS_INTRA(s->current_picture.f.mb_type[( b_x      >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
252 252
             int right_intra = IS_INTRA(s->current_picture.f.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
253
-            int left_damage =  left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
254
-            int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
253
+            int left_damage =  left_status&ER_MB_ERROR;
254
+            int right_damage= right_status&ER_MB_ERROR;
255 255
             int offset= b_x*8 + b_y*stride*8;
256 256
             int16_t *left_mv=  s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride* b_x   ];
257 257
             int16_t *right_mv= s->current_picture.f.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)];
... ...
@@ -313,8 +313,8 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
313 313
             int bottom_status= s->error_status_table[(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride];
314 314
             int top_intra    = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ( b_y      >> is_luma) * s->mb_stride]);
315 315
             int bottom_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
316
-            int top_damage =      top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
317
-            int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
316
+            int top_damage =      top_status&ER_MB_ERROR;
317
+            int bottom_damage= bottom_status&ER_MB_ERROR;
318 318
             int offset= b_x*8 + b_y*stride*8;
319 319
             int16_t *top_mv    = s->current_picture.f.motion_val[0][mvy_stride *  b_y      + mvx_stride * b_x];
320 320
             int16_t *bottom_mv = s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
... ...
@@ -377,7 +377,7 @@ static void guess_mv(MpegEncContext *s){
377 377
         int error= s->error_status_table[mb_xy];
378 378
 
379 379
         if(IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check
380
-        if(!(error&MV_ERROR)) f=MV_FROZEN;           //inter with undamaged MV
380
+        if(!(error&ER_MV_ERROR)) f=MV_FROZEN;           //inter with undamaged MV
381 381
 
382 382
         fixed[mb_xy]= f;
383 383
         if(f==MV_FROZEN)
... ...
@@ -398,7 +398,7 @@ static void guess_mv(MpegEncContext *s){
398 398
                 const int mb_xy= mb_x + mb_y*s->mb_stride;
399 399
 
400 400
                 if(IS_INTRA(s->current_picture.f.mb_type[mb_xy]))  continue;
401
-                if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue;
401
+                if(!(s->error_status_table[mb_xy]&ER_MV_ERROR)) continue;
402 402
 
403 403
                 s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
404 404
                 s->mb_intra=0;
... ...
@@ -656,7 +656,7 @@ static int is_intra_more_likely(MpegEncContext *s){
656 656
     for(i=0; i<s->mb_num; i++){
657 657
         const int mb_xy= s->mb_index2xy[i];
658 658
         const int error= s->error_status_table[mb_xy];
659
-        if(!((error&DC_ERROR) && (error&MV_ERROR)))
659
+        if(!((error&ER_DC_ERROR) && (error&ER_MV_ERROR)))
660 660
             undamaged_count++;
661 661
     }
662 662
 
... ...
@@ -682,7 +682,7 @@ static int is_intra_more_likely(MpegEncContext *s){
682 682
             const int mb_xy= mb_x + mb_y*s->mb_stride;
683 683
 
684 684
             error= s->error_status_table[mb_xy];
685
-            if((error&DC_ERROR) && (error&MV_ERROR))
685
+            if((error&ER_DC_ERROR) && (error&ER_MV_ERROR))
686 686
                 continue; //skip damaged
687 687
 
688 688
             j++;
... ...
@@ -716,7 +716,7 @@ static int is_intra_more_likely(MpegEncContext *s){
716 716
 void ff_er_frame_start(MpegEncContext *s){
717 717
     if(!s->err_recognition) return;
718 718
 
719
-    memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_stride*s->mb_height*sizeof(uint8_t));
719
+    memset(s->error_status_table, ER_MB_ERROR|VP_START|ER_MB_END, s->mb_stride*s->mb_height*sizeof(uint8_t));
720 720
     s->error_count= 3*s->mb_num;
721 721
     s->error_occurred = 0;
722 722
 }
... ...
@@ -724,7 +724,7 @@ void ff_er_frame_start(MpegEncContext *s){
724 724
 /**
725 725
  * Add a slice.
726 726
  * @param endx x component of the last macroblock, can be -1 for the last of the previous line
727
- * @param status the status at the end (MV_END, AC_ERROR, ...), it is assumed that no earlier end or
727
+ * @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...), it is assumed that no earlier end or
728 728
  *               error of the same type occurred
729 729
  */
730 730
 void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status){
... ...
@@ -745,20 +745,20 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en
745 745
     if(!s->err_recognition) return;
746 746
 
747 747
     mask &= ~VP_START;
748
-    if(status & (AC_ERROR|AC_END)){
749
-        mask &= ~(AC_ERROR|AC_END);
748
+    if(status & (ER_AC_ERROR|ER_AC_END)){
749
+        mask &= ~(ER_AC_ERROR|ER_AC_END);
750 750
         s->error_count -= end_i - start_i + 1;
751 751
     }
752
-    if(status & (DC_ERROR|DC_END)){
753
-        mask &= ~(DC_ERROR|DC_END);
752
+    if(status & (ER_DC_ERROR|ER_DC_END)){
753
+        mask &= ~(ER_DC_ERROR|ER_DC_END);
754 754
         s->error_count -= end_i - start_i + 1;
755 755
     }
756
-    if(status & (MV_ERROR|MV_END)){
757
-        mask &= ~(MV_ERROR|MV_END);
756
+    if(status & (ER_MV_ERROR|ER_MV_END)){
757
+        mask &= ~(ER_MV_ERROR|ER_MV_END);
758 758
         s->error_count -= end_i - start_i + 1;
759 759
     }
760 760
 
761
-    if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) {
761
+    if(status & ER_MB_ERROR) {
762 762
         s->error_occurred = 1;
763 763
         s->error_count= INT_MAX;
764 764
     }
... ...
@@ -785,7 +785,7 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en
785 785
         int prev_status= s->error_status_table[ s->mb_index2xy[start_i - 1] ];
786 786
 
787 787
         prev_status &= ~ VP_START;
788
-        if(prev_status != (MV_END|DC_END|AC_END)) s->error_count= INT_MAX;
788
+        if(prev_status != (ER_MV_END|ER_DC_END|ER_AC_END)) s->error_count= INT_MAX;
789 789
     }
790 790
 }
791 791
 
... ...
@@ -858,13 +858,13 @@ void ff_er_frame_end(MpegEncContext *s){
858 858
             const int mb_xy= s->mb_index2xy[i];
859 859
             int error= s->error_status_table[mb_xy];
860 860
 
861
-            if(error&AC_END)
861
+            if(error&ER_AC_END)
862 862
                 end_ok=0;
863
-            if((error&MV_END) || (error&DC_END) || (error&AC_ERROR))
863
+            if((error&ER_MV_END) || (error&ER_DC_END) || (error&ER_AC_ERROR))
864 864
                 end_ok=1;
865 865
 
866 866
             if(!end_ok)
867
-                s->error_status_table[mb_xy]|= AC_ERROR;
867
+                s->error_status_table[mb_xy]|= ER_AC_ERROR;
868 868
 
869 869
             if(error&VP_START)
870 870
                 end_ok=0;
... ...
@@ -883,14 +883,14 @@ void ff_er_frame_end(MpegEncContext *s){
883 883
             if(error1&VP_START)
884 884
                 end_ok=1;
885 885
 
886
-            if(   error2==(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END)
887
-               && error1!=(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END)
888
-               && ((error1&AC_END) || (error1&DC_END) || (error1&MV_END))){ //end & uninit
886
+            if(   error2==(VP_START|ER_MB_ERROR|ER_MB_END)
887
+               && error1!=(VP_START|ER_MB_ERROR|ER_MB_END)
888
+               && ((error1&ER_AC_END) || (error1&ER_DC_END) || (error1&ER_MV_END))){ //end & uninit
889 889
                 end_ok=0;
890 890
             }
891 891
 
892 892
             if(!end_ok)
893
-                s->error_status_table[mb_xy]|= DC_ERROR|AC_ERROR|MV_ERROR;
893
+                s->error_status_table[mb_xy]|= ER_MB_ERROR;
894 894
         }
895 895
     }
896 896
 
... ...
@@ -928,9 +928,9 @@ void ff_er_frame_end(MpegEncContext *s){
928 928
         int old_error= s->error_status_table[mb_xy];
929 929
 
930 930
         if(old_error&VP_START)
931
-            error= old_error& (DC_ERROR|AC_ERROR|MV_ERROR);
931
+            error= old_error& ER_MB_ERROR;
932 932
         else{
933
-            error|= old_error& (DC_ERROR|AC_ERROR|MV_ERROR);
933
+            error|= old_error& ER_MB_ERROR;
934 934
             s->error_status_table[mb_xy]|= error;
935 935
         }
936 936
     }
... ...
@@ -940,8 +940,8 @@ void ff_er_frame_end(MpegEncContext *s){
940 940
         for(i=0; i<s->mb_num; i++){
941 941
             const int mb_xy= s->mb_index2xy[i];
942 942
             error= s->error_status_table[mb_xy];
943
-            if(error&(AC_ERROR|DC_ERROR|MV_ERROR))
944
-                error|= AC_ERROR|DC_ERROR|MV_ERROR;
943
+            if(error&ER_MB_ERROR)
944
+                error|= ER_MB_ERROR;
945 945
             s->error_status_table[mb_xy]= error;
946 946
         }
947 947
     }
... ...
@@ -951,9 +951,9 @@ void ff_er_frame_end(MpegEncContext *s){
951 951
     for(i=0; i<s->mb_num; i++){
952 952
         const int mb_xy= s->mb_index2xy[i];
953 953
         error= s->error_status_table[mb_xy];
954
-        if(error&DC_ERROR) dc_error ++;
955
-        if(error&AC_ERROR) ac_error ++;
956
-        if(error&MV_ERROR) mv_error ++;
954
+        if(error&ER_DC_ERROR) dc_error ++;
955
+        if(error&ER_AC_ERROR) ac_error ++;
956
+        if(error&ER_MV_ERROR) mv_error ++;
957 957
     }
958 958
     av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors\n", dc_error, ac_error, mv_error);
959 959
 
... ...
@@ -963,7 +963,7 @@ void ff_er_frame_end(MpegEncContext *s){
963 963
     for(i=0; i<s->mb_num; i++){
964 964
         const int mb_xy= s->mb_index2xy[i];
965 965
         error= s->error_status_table[mb_xy];
966
-        if(!((error&DC_ERROR) && (error&MV_ERROR)))
966
+        if(!((error&ER_DC_ERROR) && (error&ER_MV_ERROR)))
967 967
             continue;
968 968
 
969 969
         if(is_intra_likely)
... ...
@@ -989,8 +989,8 @@ void ff_er_frame_end(MpegEncContext *s){
989 989
             error= s->error_status_table[mb_xy];
990 990
 
991 991
             if(IS_INTRA(mb_type)) continue; //intra
992
-            if(error&MV_ERROR) continue;              //inter with damaged MV
993
-            if(!(error&AC_ERROR)) continue;           //undamaged inter
992
+            if(error&ER_MV_ERROR) continue;              //inter with damaged MV
993
+            if(!(error&ER_AC_ERROR)) continue;           //undamaged inter
994 994
 
995 995
             s->mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
996 996
             s->mb_intra=0;
... ...
@@ -1027,8 +1027,8 @@ void ff_er_frame_end(MpegEncContext *s){
1027 1027
                 error= s->error_status_table[mb_xy];
1028 1028
 
1029 1029
                 if(IS_INTRA(mb_type)) continue;
1030
-                if(!(error&MV_ERROR)) continue;           //inter with undamaged MV
1031
-                if(!(error&AC_ERROR)) continue;           //undamaged inter
1030
+                if(!(error&ER_MV_ERROR)) continue;           //inter with undamaged MV
1031
+                if(!(error&ER_AC_ERROR)) continue;           //undamaged inter
1032 1032
 
1033 1033
                 s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD;
1034 1034
                 if(!s->last_picture.f.data[0]) s->mv_dir &= ~MV_DIR_FORWARD;
... ...
@@ -1082,7 +1082,7 @@ void ff_er_frame_end(MpegEncContext *s){
1082 1082
             error= s->error_status_table[mb_xy];
1083 1083
 
1084 1084
             if(IS_INTRA(mb_type) && s->partitioned_frame) continue;
1085
-//            if(error&MV_ERROR) continue; //inter data damaged FIXME is this good?
1085
+//            if(error&ER_MV_ERROR) continue; //inter data damaged FIXME is this good?
1086 1086
 
1087 1087
             dest_y  = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
1088 1088
             dest_cb = s->current_picture.f.data[1] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
... ...
@@ -1132,7 +1132,7 @@ void ff_er_frame_end(MpegEncContext *s){
1132 1132
             error= s->error_status_table[mb_xy];
1133 1133
 
1134 1134
             if(IS_INTER(mb_type)) continue;
1135
-            if(!(error&AC_ERROR)) continue;              //undamaged
1135
+            if(!(error&ER_AC_ERROR)) continue;              //undamaged
1136 1136
 
1137 1137
             dest_y  = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
1138 1138
             dest_cb = s->current_picture.f.data[1] + mb_x *  8 + mb_y *  8 * s->uvlinesize;
... ...
@@ -1161,7 +1161,7 @@ ec_clean:
1161 1161
         const int mb_xy= s->mb_index2xy[i];
1162 1162
         int error= s->error_status_table[mb_xy];
1163 1163
 
1164
-        if(s->pict_type!=AV_PICTURE_TYPE_B && (error&(DC_ERROR|MV_ERROR|AC_ERROR))){
1164
+        if(s->pict_type!=AV_PICTURE_TYPE_B && (error&(ER_DC_ERROR|ER_MV_ERROR|ER_AC_ERROR))){
1165 1165
             s->mbskip_table[mb_xy]=0;
1166 1166
         }
1167 1167
         s->mbintra_table[mb_xy]=1;
... ...
@@ -148,7 +148,7 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size){
148 148
 }
149 149
 
150 150
 static int decode_slice(MpegEncContext *s){
151
-    const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
151
+    const int part_mask= s->partitioned_frame ? (ER_AC_END|ER_AC_ERROR) : 0x7F;
152 152
     const int mb_size= 16>>s->avctx->lowres;
153 153
     s->last_resync_gb= s->gb;
154 154
     s->first_slice_line= 1;
... ...
@@ -184,7 +184,7 @@ static int decode_slice(MpegEncContext *s){
184 184
         /* per-row end of slice checks */
185 185
         if(s->msmpeg4_version){
186 186
             if(s->resync_mb_y + s->slice_height == s->mb_y){
187
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
187
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
188 188
 
189 189
                 return 0;
190 190
             }
... ...
@@ -225,7 +225,7 @@ static int decode_slice(MpegEncContext *s){
225 225
                         ff_h263_loop_filter(s);
226 226
 
227 227
 //printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
228
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
228
+                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
229 229
 
230 230
                     s->padding_bug_score--;
231 231
 
... ...
@@ -238,11 +238,11 @@ static int decode_slice(MpegEncContext *s){
238 238
                     return 0;
239 239
                 }else if(ret==SLICE_NOEND){
240 240
                     av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
241
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
241
+                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, ER_MB_END&part_mask);
242 242
                     return -1;
243 243
                 }
244 244
                 av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
245
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
245
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
246 246
 
247 247
                 return -1;
248 248
             }
... ...
@@ -321,7 +321,7 @@ static int decode_slice(MpegEncContext *s){
321 321
         else if(left<0){
322 322
             av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
323 323
         }else
324
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
324
+            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
325 325
 
326 326
         return 0;
327 327
     }
... ...
@@ -330,7 +330,7 @@ static int decode_slice(MpegEncContext *s){
330 330
             get_bits_left(&s->gb),
331 331
             show_bits(&s->gb, 24), s->padding_bug_score);
332 332
 
333
-    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
333
+    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
334 334
 
335 335
     return -1;
336 336
 }
... ...
@@ -673,7 +673,7 @@ retry:
673 673
 
674 674
     if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
675 675
         if(!CONFIG_MSMPEG4_DECODER || msmpeg4_decode_ext_header(s, buf_size) < 0){
676
-            s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR;
676
+            s->error_status_table[s->mb_num-1]= ER_MB_ERROR;
677 677
         }
678 678
 
679 679
     assert(s->bitstream_buffer_size==0);
... ...
@@ -3593,7 +3593,7 @@ static void decode_finish_row(H264Context *h){
3593 3593
 static int decode_slice(struct AVCodecContext *avctx, void *arg){
3594 3594
     H264Context *h = *(void**)arg;
3595 3595
     MpegEncContext * const s = &h->s;
3596
-    const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
3596
+    const int part_mask= s->partitioned_frame ? (ER_AC_END|ER_AC_ERROR) : 0x7F;
3597 3597
     int lf_x_start = s->mb_x;
3598 3598
 
3599 3599
     s->mb_skip_run= -1;
... ...
@@ -3632,13 +3632,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
3632 3632
             eos = get_cabac_terminate( &h->cabac );
3633 3633
 
3634 3634
             if((s->workaround_bugs & FF_BUG_TRUNCATED) && h->cabac.bytestream > h->cabac.bytestream_end + 2){
3635
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
3635
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END&part_mask);
3636 3636
                 if (s->mb_x >= lf_x_start) loop_filter(h, lf_x_start, s->mb_x + 1);
3637 3637
                 return 0;
3638 3638
             }
3639 3639
             if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
3640 3640
                 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream);
3641
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
3641
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
3642 3642
                 return -1;
3643 3643
             }
3644 3644
 
... ...
@@ -3656,7 +3656,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
3656 3656
 
3657 3657
             if( eos || s->mb_y >= s->mb_height ) {
3658 3658
                 tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
3659
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
3659
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END&part_mask);
3660 3660
                 if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
3661 3661
                 return 0;
3662 3662
             }
... ...
@@ -3678,7 +3678,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
3678 3678
 
3679 3679
             if(ret<0){
3680 3680
                 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
3681
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
3681
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
3682 3682
                 return -1;
3683 3683
             }
3684 3684
 
... ...
@@ -3697,11 +3697,11 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
3697 3697
 
3698 3698
                     if(   get_bits_count(&s->gb) == s->gb.size_in_bits
3699 3699
                        || get_bits_count(&s->gb) <  s->gb.size_in_bits && s->avctx->error_recognition < FF_ER_AGGRESSIVE) {
3700
-                        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
3700
+                        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END&part_mask);
3701 3701
 
3702 3702
                         return 0;
3703 3703
                     }else{
3704
-                        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
3704
+                        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
3705 3705
 
3706 3706
                         return -1;
3707 3707
                     }
... ...
@@ -3711,12 +3711,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
3711 3711
             if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->mb_skip_run<=0){
3712 3712
                 tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
3713 3713
                 if(get_bits_count(&s->gb) == s->gb.size_in_bits ){
3714
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
3714
+                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END&part_mask);
3715 3715
                     if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
3716 3716
 
3717 3717
                     return 0;
3718 3718
                 }else{
3719
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
3719
+                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
3720 3720
 
3721 3721
                     return -1;
3722 3722
                 }
... ...
@@ -690,13 +690,13 @@ av_cold void ff_h264_decode_init_vlc(void);
690 690
 
691 691
 /**
692 692
  * Decode a macroblock
693
- * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
693
+ * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
694 694
  */
695 695
 int ff_h264_decode_mb_cavlc(H264Context *h);
696 696
 
697 697
 /**
698 698
  * Decode a CABAC coded macroblock
699
- * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
699
+ * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
700 700
  */
701 701
 int ff_h264_decode_mb_cabac(H264Context *h);
702 702
 
... ...
@@ -1864,7 +1864,7 @@ static av_always_inline void decode_cabac_luma_residual( H264Context *h, const u
1864 1864
 
1865 1865
 /**
1866 1866
  * Decode a macroblock.
1867
- * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
1867
+ * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
1868 1868
  */
1869 1869
 int ff_h264_decode_mb_cabac(H264Context *h) {
1870 1870
     MpegEncContext * const s = &h->s;
... ...
@@ -784,6 +784,6 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of
784 784
 error:
785 785
     ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
786 786
                         (s->mb_x>>1)-1, (s->mb_y>>1)-1,
787
-                        (AC_END|DC_END|MV_END) );
787
+                        ER_MB_END );
788 788
     return 0;
789 789
 }
... ...
@@ -1900,9 +1900,9 @@ static int slice_decode_thread(AVCodecContext *c, void *arg)
1900 1900
             if (c->err_recognition & AV_EF_EXPLODE)
1901 1901
                 return ret;
1902 1902
             if (s->resync_mb_x >= 0 && s->resync_mb_y >= 0)
1903
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR | DC_ERROR | MV_ERROR);
1903
+                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
1904 1904
         } else {
1905
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END | DC_END | MV_END);
1905
+            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
1906 1906
         }
1907 1907
 
1908 1908
         if (s->mb_y == s->end_mb_y)
... ...
@@ -2504,9 +2504,9 @@ static int decode_chunks(AVCodecContext *avctx,
2504 2504
                         if (avctx->err_recognition & AV_EF_EXPLODE)
2505 2505
                             return ret;
2506 2506
                         if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0)
2507
-                            ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR | DC_ERROR | MV_ERROR);
2507
+                            ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
2508 2508
                     } else {
2509
-                        ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, AC_END | DC_END | MV_END);
2509
+                        ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
2510 2510
                     }
2511 2511
                 }
2512 2512
             }
... ...
@@ -786,8 +786,8 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
786 786
 int ff_mpeg4_decode_partitions(MpegEncContext *s)
787 787
 {
788 788
     int mb_num;
789
-    const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (DC_ERROR|MV_ERROR) : MV_ERROR;
790
-    const int part_a_end  = s->pict_type==AV_PICTURE_TYPE_I ? (DC_END  |MV_END)   : MV_END;
789
+    const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_ERROR|ER_MV_ERROR) : ER_MV_ERROR;
790
+    const int part_a_end  = s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_END  |ER_MV_END)   : ER_MV_END;
791 791
 
792 792
     mb_num= mpeg4_decode_partition_a(s);
793 793
     if(mb_num<0){
... ...
@@ -822,11 +822,11 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s)
822 822
 
823 823
     if( mpeg4_decode_partition_b(s, mb_num) < 0){
824 824
         if(s->pict_type==AV_PICTURE_TYPE_P)
825
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, DC_ERROR);
825
+            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR);
826 826
         return -1;
827 827
     }else{
828 828
         if(s->pict_type==AV_PICTURE_TYPE_P)
829
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, DC_END);
829
+            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END);
830 830
     }
831 831
 
832 832
     return 0;
... ...
@@ -479,13 +479,15 @@ typedef struct MpegEncContext {
479 479
     int error_count, error_occurred;
480 480
     uint8_t *error_status_table;       ///< table of the error status of each MB
481 481
 #define VP_START            1          ///< current MB is the first after a resync marker
482
-#define AC_ERROR            2
483
-#define DC_ERROR            4
484
-#define MV_ERROR            8
485
-#define AC_END              16
486
-#define DC_END              32
487
-#define MV_END              64
488
-//FIXME some prefix?
482
+#define ER_AC_ERROR            2
483
+#define ER_DC_ERROR            4
484
+#define ER_MV_ERROR            8
485
+#define ER_AC_END              16
486
+#define ER_DC_END              32
487
+#define ER_MV_END              64
488
+
489
+#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
490
+#define ER_MB_END   (ER_AC_END|ER_DC_END|ER_MV_END)
489 491
 
490 492
     int resync_mb_x;                 ///< x position of last resync marker
491 493
     int resync_mb_y;                 ///< y position of last resync marker
... ...
@@ -626,7 +626,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
626 626
         if(ret == SLICE_END) break;
627 627
     }
628 628
 
629
-    ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
629
+    ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
630 630
 
631 631
     return s->gb.size_in_bits;
632 632
 }
... ...
@@ -289,20 +289,6 @@ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *r
289 289
 }
290 290
 
291 291
 /**
292
- * Dequantize ordinary 4x4 block.
293
- * @todo optimize
294
- */
295
-static inline void rv34_dequant4x4(DCTELEM *block, int Qdc, int Q)
296
-{
297
-    int i, j;
298
-
299
-    block[0] = (block[0] * Qdc + 8) >> 4;
300
-    for(i = 0; i < 4; i++)
301
-        for(j = !i; j < 4; j++)
302
-            block[j + i*8] = (block[j + i*8] * Q + 8) >> 4;
303
-}
304
-
305
-/**
306 292
  * Dequantize 4x4 block of DC values for 16x16 macroblock.
307 293
  * @todo optimize
308 294
  */
... ...
@@ -1159,7 +1145,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
1159 1159
         blkoff = ((i & 1) << 2) + ((i & 4) << 3);
1160 1160
         if(cbp & 1)
1161 1161
             rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0);
1162
-        rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]);
1162
+        r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]);
1163 1163
         if(r->is16) //FIXME: optimize
1164 1164
             s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)];
1165 1165
         r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
... ...
@@ -1171,7 +1157,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
1171 1171
         blknum = ((i & 4) >> 2) + 4;
1172 1172
         blkoff = ((i & 1) << 2) + ((i & 2) << 4);
1173 1173
         rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1);
1174
-        rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]);
1174
+        r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]);
1175 1175
         r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff);
1176 1176
     }
1177 1177
     if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos]))
... ...
@@ -1296,7 +1282,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
1296 1296
         s->dsp.clear_blocks(s->block[0]);
1297 1297
 
1298 1298
         if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
1299
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
1299
+            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR);
1300 1300
             return -1;
1301 1301
         }
1302 1302
         if (++s->mb_x == s->mb_width) {
... ...
@@ -1314,7 +1300,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
1314 1314
             s->first_slice_line=0;
1315 1315
         s->mb_num_left--;
1316 1316
     }
1317
-    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
1317
+    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
1318 1318
 
1319 1319
     return s->mb_y == s->mb_height;
1320 1320
 }
... ...
@@ -100,10 +100,26 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){
100 100
 /** @} */ // transform
101 101
 
102 102
 
103
+/**
104
+ * Dequantize ordinary 4x4 block.
105
+ */
106
+void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q);
107
+static void rv34_dequant4x4_c(DCTELEM *block, int Qdc, int Q)
108
+{
109
+    int i, j;
110
+
111
+    block[0] = (block[0] * Qdc + 8) >> 4;
112
+    for (i = 0; i < 4; i++)
113
+        for (j = !i; j < 4; j++)
114
+            block[j + i*8] = (block[j + i*8] * Q + 8) >> 4;
115
+}
116
+
103 117
 av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
104 118
     c->rv34_inv_transform_tab[0] = rv34_inv_transform_c;
105 119
     c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c;
106 120
 
121
+    c->rv34_dequant4x4 = rv34_dequant4x4_c;
122
+
107 123
     if (HAVE_NEON)
108 124
         ff_rv34dsp_init_neon(c, dsp);
109 125
 }
... ...
@@ -48,6 +48,7 @@ typedef struct RV34DSPContext {
48 48
     h264_chroma_mc_func avg_chroma_pixels_tab[3];
49 49
     rv40_weight_func rv40_weight_pixels_tab[2];
50 50
     rv34_inv_transform_func rv34_inv_transform_tab[2];
51
+    void (*rv34_dequant4x4)(DCTELEM *block, int Qdc, int Q);
51 52
     rv40_loop_filter_func rv40_h_loop_filter;
52 53
     rv40_loop_filter_func rv40_v_loop_filter;
53 54
 } RV34DSPContext;
... ...
@@ -40,6 +40,14 @@ typedef struct UltimotionDecodeContext {
40 40
     const uint8_t *ulti_codebook;
41 41
 } UltimotionDecodeContext;
42 42
 
43
+#define CHECK_OVERREAD_SIZE(size) \
44
+    do { \
45
+        if (buf_end - buf < (size)) { \
46
+            av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); \
47
+            return AVERROR_INVALIDDATA; \
48
+        } \
49
+    } while(0)
50
+
43 51
 static av_cold int ulti_decode_init(AVCodecContext *avctx)
44 52
 {
45 53
     UltimotionDecodeContext *s = avctx->priv_data;
... ...
@@ -224,6 +232,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
224 224
     int i;
225 225
     int skip;
226 226
     int tmp;
227
+    const uint8_t *buf_end = buf + buf_size;
227 228
 
228 229
     s->frame.reference = 3;
229 230
     s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
... ...
@@ -237,10 +246,12 @@ static int ulti_decode_frame(AVCodecContext *avctx,
237 237
         if(blocks >= s->blocks || y >= s->height)
238 238
             break;//all blocks decoded
239 239
 
240
+        CHECK_OVERREAD_SIZE(1);
240 241
         idx = *buf++;
241 242
         if((idx & 0xF8) == 0x70) {
242 243
             switch(idx) {
243 244
             case 0x70: //change modifier
245
+                CHECK_OVERREAD_SIZE(1);
244 246
                 modifier = *buf++;
245 247
                 if(modifier>1)
246 248
                     av_log(avctx, AV_LOG_INFO, "warning: modifier must be 0 or 1, got %i\n", modifier);
... ...
@@ -255,6 +266,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
255 255
                 done = 1;
256 256
                 break;
257 257
             case 0x74: //skip some blocks
258
+                CHECK_OVERREAD_SIZE(1);
258 259
                 skip = *buf++;
259 260
                 if ((blocks + skip) >= s->blocks)
260 261
                     break;
... ...
@@ -281,19 +293,24 @@ static int ulti_decode_frame(AVCodecContext *avctx,
281 281
                 chroma = 0;
282 282
             } else {
283 283
                 cf = 0;
284
-                if (idx)
284
+                if (idx) {
285
+                    CHECK_OVERREAD_SIZE(1);
285 286
                     chroma = *buf++;
287
+                }
286 288
             }
287 289
             for (i = 0; i < 4; i++) { // for every subblock
288 290
                 code = (idx >> (6 - i*2)) & 3; //extract 2 bits
289 291
                 if(!code) //skip subblock
290 292
                     continue;
291
-                if(cf)
293
+                if(cf) {
294
+                    CHECK_OVERREAD_SIZE(1);
292 295
                     chroma = *buf++;
296
+                }
293 297
                 tx = x + block_coords[i * 2];
294 298
                 ty = y + block_coords[(i * 2) + 1];
295 299
                 switch(code) {
296 300
                 case 1:
301
+                    CHECK_OVERREAD_SIZE(1);
297 302
                     tmp = *buf++;
298 303
 
299 304
                     angle = angle_by_index[(tmp >> 6) & 0x3];
... ...
@@ -314,6 +331,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
314 314
 
315 315
                 case 2:
316 316
                     if (modifier) { // unpack four luma samples
317
+                        CHECK_OVERREAD_SIZE(3);
317 318
                         tmp = bytestream_get_be24(&buf);
318 319
 
319 320
                         Y[0] = (tmp >> 18) & 0x3F;
... ...
@@ -322,6 +340,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
322 322
                         Y[3] = tmp & 0x3F;
323 323
                         angle = 16;
324 324
                     } else { // retrieve luma samples from codebook
325
+                        CHECK_OVERREAD_SIZE(2);
325 326
                         tmp = bytestream_get_be16(&buf);
326 327
 
327 328
                         angle = (tmp >> 12) & 0xF;
... ...
@@ -338,6 +357,8 @@ static int ulti_decode_frame(AVCodecContext *avctx,
338 338
                     if (modifier) { // all 16 luma samples
339 339
                         uint8_t Luma[16];
340 340
 
341
+                        CHECK_OVERREAD_SIZE(12);
342
+
341 343
                         tmp = bytestream_get_be24(&buf);
342 344
                         Luma[0] = (tmp >> 18) & 0x3F;
343 345
                         Luma[1] = (tmp >> 12) & 0x3F;
... ...
@@ -364,6 +385,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
364 364
 
365 365
                         ulti_convert_yuv(&s->frame, tx, ty, Luma, chroma);
366 366
                     } else {
367
+                        CHECK_OVERREAD_SIZE(4);
367 368
                         tmp = *buf++;
368 369
                         if(tmp & 0x80) {
369 370
                             angle = (tmp >> 4) & 0x7;
... ...
@@ -4548,7 +4548,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
4548 4548
             if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
4549 4549
 
4550 4550
             if (get_bits_count(&s->gb) > v->bits) {
4551
-                ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
4551
+                ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR);
4552 4552
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
4553 4553
                        get_bits_count(&s->gb), v->bits);
4554 4554
                 return;
... ...
@@ -4563,7 +4563,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
4563 4563
     }
4564 4564
     if (v->s.loop_filter)
4565 4565
         ff_draw_horiz_band(s, (s->mb_height - 1) * 16, 16);
4566
-    ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
4566
+    ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END);
4567 4567
 }
4568 4568
 
4569 4569
 /** Decode blocks of I-frame for advanced profile
... ...
@@ -4673,7 +4673,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
4673 4673
 
4674 4674
             if (get_bits_count(&s->gb) > v->bits) {
4675 4675
                 // TODO: may need modification to handle slice coding
4676
-                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
4676
+                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
4677 4677
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
4678 4678
                        get_bits_count(&s->gb), v->bits);
4679 4679
                 return;
... ...
@@ -4698,7 +4698,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
4698 4698
     if (v->s.loop_filter)
4699 4699
         ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16);
4700 4700
     ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
4701
-                    (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
4701
+                    (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
4702 4702
 }
4703 4703
 
4704 4704
 static void vc1_decode_p_blocks(VC1Context *v)
... ...
@@ -4749,7 +4749,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
4749 4749
                 vc1_apply_p_loop_filter(v);
4750 4750
             if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
4751 4751
                 // TODO: may need modification to handle slice coding
4752
-                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
4752
+                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
4753 4753
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
4754 4754
                        get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
4755 4755
                 return;
... ...
@@ -4773,7 +4773,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
4773 4773
     if (s->end_mb_y >= s->start_mb_y)
4774 4774
         ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
4775 4775
     ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
4776
-                    (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
4776
+                    (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
4777 4777
 }
4778 4778
 
4779 4779
 static void vc1_decode_b_blocks(VC1Context *v)
... ...
@@ -4818,7 +4818,7 @@ static void vc1_decode_b_blocks(VC1Context *v)
4818 4818
                 vc1_decode_b_mb(v);
4819 4819
             if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
4820 4820
                 // TODO: may need modification to handle slice coding
4821
-                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR));
4821
+                ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
4822 4822
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
4823 4823
                        get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
4824 4824
                 return;
... ...
@@ -4834,14 +4834,14 @@ static void vc1_decode_b_blocks(VC1Context *v)
4834 4834
     if (v->s.loop_filter)
4835 4835
         ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
4836 4836
     ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
4837
-                    (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END));
4837
+                    (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
4838 4838
 }
4839 4839
 
4840 4840
 static void vc1_decode_skip_blocks(VC1Context *v)
4841 4841
 {
4842 4842
     MpegEncContext *s = &v->s;
4843 4843
 
4844
-    ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END));
4844
+    ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
4845 4845
     s->first_slice_line = 1;
4846 4846
     for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
4847 4847
         s->mb_x = 0;
... ...
@@ -41,5 +41,3 @@ SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H)     += alsa-audio.h
41 41
 SKIPHEADERS-$(HAVE_SNDIO_H)              += sndio_common.h
42 42
 
43 43
 TESTPROGS = timefilter
44
-
45
-include $(SRC_PATH)/subdir.mak
... ...
@@ -163,5 +163,3 @@ DIRS = x86 libmpcodecs
163 163
 TESTPROGS = formats
164 164
 
165 165
 TOOLS = graph2dot lavfi-showfiltfmts
166
-
167
-include $(SRC_PATH)/subdir.mak
... ...
@@ -143,7 +143,7 @@ static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic,
143 143
         int w = dstpic->video->w;
144 144
         int h = dstpic->video->h;
145 145
         int refs = yadif->cur->linesize[i];
146
-        int df = (yadif->csp->comp[i].depth_minus1+1) / 8;
146
+        int df = (yadif->csp->comp[i].depth_minus1 + 8) / 8;
147 147
 
148 148
         if (i == 1 || i == 2) {
149 149
         /* Why is this not part of the per-plane description thing? */
... ...
@@ -210,7 +210,7 @@ static void return_frame(AVFilterContext *ctx, int is_second)
210 210
 
211 211
     if (!yadif->csp)
212 212
         yadif->csp = &av_pix_fmt_descriptors[link->format];
213
-    if (yadif->csp->comp[0].depth_minus1 == 15)
213
+    if (yadif->csp->comp[0].depth_minus1 / 8 == 1)
214 214
         yadif->filter_line = (void*)filter_line_c_16bit;
215 215
 
216 216
     filter(ctx, yadif->out, tff ^ !is_second, tff);
... ...
@@ -352,6 +352,9 @@ static int query_formats(AVFilterContext *ctx)
352 352
         AV_NE( PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE ),
353 353
         PIX_FMT_YUV440P,
354 354
         PIX_FMT_YUVJ440P,
355
+        AV_NE( PIX_FMT_YUV420P10BE, PIX_FMT_YUV420P10LE ),
356
+        AV_NE( PIX_FMT_YUV422P10BE, PIX_FMT_YUV422P10LE ),
357
+        AV_NE( PIX_FMT_YUV444P10BE, PIX_FMT_YUV444P10LE ),
355 358
         AV_NE( PIX_FMT_YUV420P16BE, PIX_FMT_YUV420P16LE ),
356 359
         AV_NE( PIX_FMT_YUV422P16BE, PIX_FMT_YUV422P16LE ),
357 360
         AV_NE( PIX_FMT_YUV444P16BE, PIX_FMT_YUV444P16LE ),
... ...
@@ -369,5 +369,3 @@ OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
369 369
 
370 370
 TESTPROGS = seek
371 371
 TOOLS     = pktdumper probetest
372
-
373
-include $(SRC_PATH)/subdir.mak
... ...
@@ -3504,7 +3504,7 @@ fail:
3504 3504
         av_freep(&s->streams[i]->priv_data);
3505 3505
         av_freep(&s->streams[i]->index_entries);
3506 3506
     }
3507
-    if (s->iformat && s->iformat->priv_class)
3507
+    if (s->oformat->priv_class)
3508 3508
         av_opt_free(s->priv_data);
3509 3509
     av_freep(&s->priv_data);
3510 3510
     return ret;
... ...
@@ -86,6 +86,4 @@ DIRS = arm bfin sh4 x86
86 86
 
87 87
 ARCH_HEADERS = bswap.h intmath.h intreadwrite.h timer.h
88 88
 
89
-include $(SRC_PATH)/subdir.mak
90
-
91 89
 $(SUBDIR)lzo-test$(EXESUF): ELIBS = -llzo2
... ...
@@ -6,5 +6,3 @@ FFLIBS = avutil
6 6
 HEADERS = postprocess.h
7 7
 
8 8
 OBJS = postprocess.o
9
-
10
-include $(SRC_PATH)/subdir.mak
... ...
@@ -8,5 +8,3 @@ HEADERS = swresample.h
8 8
 OBJS = swresample.o audioconvert.o resample.o rematrix.o
9 9
 
10 10
 TESTPROGS = swresample_test
11
-
12
-include $(SRC_PATH)/subdir.mak
... ...
@@ -26,5 +26,3 @@ $(SUBDIR)x86/swscale_mmx.o: CFLAGS += $(NOREDZONE_FLAGS)
26 26
 TESTPROGS = colorspace swscale
27 27
 
28 28
 DIRS = bfin mlib ppc sparc x86
29
-
30
-include $(SRC_PATH)/subdir.mak
... ...
@@ -127,4 +127,4 @@
127 127
 0, 472500, 84480, 0x13962590
128 128
 0, 476250, 84480, 0xde79482f
129 129
 0, 480000, 84480, 0x7d1ca064
130
-0, 483750, 84480, 0x7e1de54e
130
+0, 483750, 84480, 0x0998a064