Mercurial > libavcodec.hg
annotate error_resilience.c @ 2220:21947e176d4d libavcodec
get/set_sr_golomb() cleanup
author | michael |
---|---|
date | Fri, 10 Sep 2004 19:40:55 +0000 |
parents | 5ab35105671a |
children | 30d8b99e00f3 |
rev | line source |
---|---|
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1 /* |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
2 * Error resilience / concealment |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
3 * |
1739
07a484280a82
copyright year update of the files i touched and remembered, things look annoyingly unmaintained otherwise
michael
parents:
1731
diff
changeset
|
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
5 * |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
6 * This library is free software; you can redistribute it and/or |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
9 * version 2 of the License, or (at your option) any later version. |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
10 * |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
15 * |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
17 * License along with this library; if not, write to the Free Software |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
19 */ |
1106 | 20 |
21 /** | |
22 * @file error_resilience.c | |
23 * Error resilience / concealment. | |
24 */ | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
25 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
26 #include <limits.h> |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
27 |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
28 #include "avcodec.h" |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
29 #include "dsputil.h" |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
30 #include "mpegvideo.h" |
1144 | 31 #include "common.h" |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
32 |
1389 | 33 static void decode_mb(MpegEncContext *s){ |
34 s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize ) + s->mb_x * 16; | |
35 s->dest[1] = s->current_picture.data[1] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8; | |
36 s->dest[2] = s->current_picture.data[2] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8; | |
37 | |
38 MPV_decode_mb(s, s->block); | |
39 } | |
40 | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
41 /** |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
42 * replaces the current MB with a flat dc only version. |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
43 */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
44 static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int mb_x, int mb_y) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
45 { |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
46 int dc, dcu, dcv, y, i; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
47 for(i=0; i<4; i++){ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
48 dc= s->dc_val[0][mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
49 if(dc<0) dc=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
50 else if(dc>2040) dc=2040; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
51 for(y=0; y<8; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
52 int x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
53 for(x=0; x<8; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
54 dest_y[x + (i&1)*8 + (y + (i>>1)*8)*s->linesize]= dc/8; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
55 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
56 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
57 } |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
58 dcu = s->dc_val[1][mb_x + mb_y*s->mb_stride]; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
59 dcv = s->dc_val[2][mb_x + mb_y*s->mb_stride]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
60 if (dcu<0 ) dcu=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
61 else if(dcu>2040) dcu=2040; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
62 if (dcv<0 ) dcv=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
63 else if(dcv>2040) dcv=2040; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
64 for(y=0; y<8; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
65 int x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
66 for(x=0; x<8; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
67 dest_cb[x + y*(s->uvlinesize)]= dcu/8; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
68 dest_cr[x + y*(s->uvlinesize)]= dcv/8; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
69 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
70 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
71 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
72 |
1064 | 73 static void filter181(int16_t *data, int width, int height, int stride){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
74 int x,y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
75 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
76 /* horizontal filter */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
77 for(y=1; y<height-1; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
78 int prev_dc= data[0 + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
79 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
80 for(x=1; x<width-1; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
81 int dc; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
82 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
83 dc= - prev_dc |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
84 + data[x + y*stride]*8 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
85 - data[x + 1 + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
86 dc= (dc*10923 + 32768)>>16; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
87 prev_dc= data[x + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
88 data[x + y*stride]= dc; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
89 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
90 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
91 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
92 /* vertical filter */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
93 for(x=1; x<width-1; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
94 int prev_dc= data[x]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
95 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
96 for(y=1; y<height-1; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
97 int dc; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
98 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
99 dc= - prev_dc |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
100 + data[x + y *stride]*8 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
101 - data[x + (y+1)*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
102 dc= (dc*10923 + 32768)>>16; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
103 prev_dc= data[x + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
104 data[x + y*stride]= dc; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
105 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
106 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
107 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
108 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
109 /** |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
110 * guess the dc of blocks which dont have a undamaged dc |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
111 * @param w width in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
112 * @param h height in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
113 */ |
1064 | 114 static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, int is_luma){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
115 int b_x, b_y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
116 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
117 for(b_y=0; b_y<h; b_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
118 for(b_x=0; b_x<w; b_x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
119 int color[4]={1024,1024,1024,1024}; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
120 int distance[4]={9999,9999,9999,9999}; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
121 int mb_index, error, j; |
1064 | 122 int64_t guess, weight_sum; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
123 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
124 mb_index= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
125 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
126 error= s->error_status_table[mb_index]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
127 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
128 if(IS_INTER(s->current_picture.mb_type[mb_index])) continue; //inter |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
129 if(!(error&DC_ERROR)) continue; //dc-ok |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
130 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
131 /* right block */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
132 for(j=b_x+1; j<w; j++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
133 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
134 int error_j= s->error_status_table[mb_index_j]; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
135 int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
136 if(intra_j==0 || !(error_j&DC_ERROR)){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
137 color[0]= dc[j + b_y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
138 distance[0]= j-b_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
139 break; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
140 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
141 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
142 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
143 /* left block */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
144 for(j=b_x-1; j>=0; j--){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
145 int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
146 int error_j= s->error_status_table[mb_index_j]; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
147 int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
148 if(intra_j==0 || !(error_j&DC_ERROR)){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
149 color[1]= dc[j + b_y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
150 distance[1]= b_x-j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
151 break; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
152 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
153 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
154 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
155 /* bottom block */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
156 for(j=b_y+1; j<h; j++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
157 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
158 int error_j= s->error_status_table[mb_index_j]; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
159 int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
160 if(intra_j==0 || !(error_j&DC_ERROR)){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
161 color[2]= dc[b_x + j*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
162 distance[2]= j-b_y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
163 break; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
164 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
165 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
166 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
167 /* top block */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
168 for(j=b_y-1; j>=0; j--){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
169 int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
170 int error_j= s->error_status_table[mb_index_j]; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
171 int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
172 if(intra_j==0 || !(error_j&DC_ERROR)){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
173 color[3]= dc[b_x + j*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
174 distance[3]= b_y-j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
175 break; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
176 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
177 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
178 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
179 weight_sum=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
180 guess=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
181 for(j=0; j<4; j++){ |
1064 | 182 int64_t weight= 256*256*256*16/distance[j]; |
183 guess+= weight*(int64_t)color[j]; | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
184 weight_sum+= weight; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
185 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
186 guess= (guess + weight_sum/2) / weight_sum; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
187 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
188 dc[b_x + b_y*stride]= guess; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
189 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
190 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
191 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
192 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
193 /** |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
194 * simple horizontal deblocking filter used for error resilience |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
195 * @param w width in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
196 * @param h height in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
197 */ |
1064 | 198 static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
199 int b_x, b_y; |
1064 | 200 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
201 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
202 for(b_y=0; b_y<h; b_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
203 for(b_x=0; b_x<w-1; b_x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
204 int y; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
205 int left_status = s->error_status_table[( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
206 int right_status= s->error_status_table[((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
207 int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
208 int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
209 int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
210 int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
211 int offset= b_x*8 + b_y*stride*8; |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
212 int16_t *left_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ( b_x <<(1-is_luma))]; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
213 int16_t *right_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ((b_x+1)<<(1-is_luma))]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
214 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
215 if(!(left_damage||right_damage)) continue; // both undamaged |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
216 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
217 if( (!left_intra) && (!right_intra) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
218 && ABS(left_mv[0]-right_mv[0]) + ABS(left_mv[1]+right_mv[1]) < 2) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
219 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
220 for(y=0; y<8; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
221 int a,b,c,d; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
222 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
223 a= dst[offset + 7 + y*stride] - dst[offset + 6 + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
224 b= dst[offset + 8 + y*stride] - dst[offset + 7 + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
225 c= dst[offset + 9 + y*stride] - dst[offset + 8 + y*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
226 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
227 d= ABS(b) - ((ABS(a) + ABS(c) + 1)>>1); |
847 | 228 d= FFMAX(d, 0); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
229 if(b<0) d= -d; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
230 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
231 if(d==0) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
232 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
233 if(!(left_damage && right_damage)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
234 d= d*16/9; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
235 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
236 if(left_damage){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
237 dst[offset + 7 + y*stride] = cm[dst[offset + 7 + y*stride] + ((d*7)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
238 dst[offset + 6 + y*stride] = cm[dst[offset + 6 + y*stride] + ((d*5)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
239 dst[offset + 5 + y*stride] = cm[dst[offset + 5 + y*stride] + ((d*3)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
240 dst[offset + 4 + y*stride] = cm[dst[offset + 4 + y*stride] + ((d*1)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
241 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
242 if(right_damage){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
243 dst[offset + 8 + y*stride] = cm[dst[offset + 8 + y*stride] - ((d*7)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
244 dst[offset + 9 + y*stride] = cm[dst[offset + 9 + y*stride] - ((d*5)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
245 dst[offset + 10+ y*stride] = cm[dst[offset +10 + y*stride] - ((d*3)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
246 dst[offset + 11+ y*stride] = cm[dst[offset +11 + y*stride] - ((d*1)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
247 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
248 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
249 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
250 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
251 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
252 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
253 /** |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
254 * simple vertical deblocking filter used for error resilience |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
255 * @param w width in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
256 * @param h height in 8 pixel blocks |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
257 */ |
1064 | 258 static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
259 int b_x, b_y; |
1064 | 260 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
261 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
262 for(b_y=0; b_y<h-1; b_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
263 for(b_x=0; b_x<w; b_x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
264 int x; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
265 int top_status = s->error_status_table[(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
266 int bottom_status= s->error_status_table[(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
267 int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
268 int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
269 int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
270 int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
271 int offset= b_x*8 + b_y*stride*8; |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
272 int16_t *top_mv= s->current_picture.motion_val[0][s->b8_stride*( b_y <<(1-is_luma)) + (b_x<<(1-is_luma))]; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
273 int16_t *bottom_mv= s->current_picture.motion_val[0][s->b8_stride*((b_y+1)<<(1-is_luma)) + (b_x<<(1-is_luma))]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
274 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
275 if(!(top_damage||bottom_damage)) continue; // both undamaged |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
276 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
277 if( (!top_intra) && (!bottom_intra) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
278 && ABS(top_mv[0]-bottom_mv[0]) + ABS(top_mv[1]+bottom_mv[1]) < 2) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
279 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
280 for(x=0; x<8; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
281 int a,b,c,d; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
282 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
283 a= dst[offset + x + 7*stride] - dst[offset + x + 6*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
284 b= dst[offset + x + 8*stride] - dst[offset + x + 7*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
285 c= dst[offset + x + 9*stride] - dst[offset + x + 8*stride]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
286 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
287 d= ABS(b) - ((ABS(a) + ABS(c)+1)>>1); |
847 | 288 d= FFMAX(d, 0); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
289 if(b<0) d= -d; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
290 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
291 if(d==0) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
292 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
293 if(!(top_damage && bottom_damage)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
294 d= d*16/9; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
295 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
296 if(top_damage){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
297 dst[offset + x + 7*stride] = cm[dst[offset + x + 7*stride] + ((d*7)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
298 dst[offset + x + 6*stride] = cm[dst[offset + x + 6*stride] + ((d*5)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
299 dst[offset + x + 5*stride] = cm[dst[offset + x + 5*stride] + ((d*3)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
300 dst[offset + x + 4*stride] = cm[dst[offset + x + 4*stride] + ((d*1)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
301 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
302 if(bottom_damage){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
303 dst[offset + x + 8*stride] = cm[dst[offset + x + 8*stride] - ((d*7)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
304 dst[offset + x + 9*stride] = cm[dst[offset + x + 9*stride] - ((d*5)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
305 dst[offset + x + 10*stride] = cm[dst[offset + x + 10*stride] - ((d*3)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
306 dst[offset + x + 11*stride] = cm[dst[offset + x + 11*stride] - ((d*1)>>4)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
307 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
308 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
309 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
310 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
311 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
312 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
313 static void guess_mv(MpegEncContext *s){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
314 uint8_t fixed[s->mb_stride * s->mb_height]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
315 #define MV_FROZEN 3 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
316 #define MV_CHANGED 2 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
317 #define MV_UNCHANGED 1 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
318 const int mb_stride = s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
319 const int mb_width = s->mb_width; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
320 const int mb_height= s->mb_height; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
321 int i, depth, num_avail; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
322 int mb_x, mb_y; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
323 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
324 num_avail=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
325 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
326 const int mb_xy= s->mb_index2xy[ i ]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
327 int f=0; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
328 int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
329 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
330 if(IS_INTRA(s->current_picture.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
331 if(!(error&MV_ERROR)) f=MV_FROZEN; //inter with undamaged MV |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
332 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
333 fixed[mb_xy]= f; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
334 if(f==MV_FROZEN) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
335 num_avail++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
336 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
337 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
338 if((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width/2){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
339 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
340 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
341 const int mb_xy= mb_x + mb_y*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
342 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
343 if(IS_INTRA(s->current_picture.mb_type[mb_xy])) continue; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
344 if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
345 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
346 s->mv_dir = MV_DIR_FORWARD; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
347 s->mb_intra=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
348 s->mv_type = MV_TYPE_16X16; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
349 s->mb_skiped=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
350 |
853
eacc2dd8fd9d
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
847
diff
changeset
|
351 s->dsp.clear_blocks(s->block[0]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
352 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
353 s->mb_x= mb_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
354 s->mb_y= mb_y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
355 s->mv[0][0][0]= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
356 s->mv[0][0][1]= 0; |
1389 | 357 decode_mb(s); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
358 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
359 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
360 return; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
361 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
362 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
363 for(depth=0;; depth++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
364 int changed, pass, none_left; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
365 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
366 none_left=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
367 changed=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
368 for(pass=0; (changed || pass<2) && pass<10; pass++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
369 int mb_x, mb_y; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
370 int score_sum=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
371 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
372 changed=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
373 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
374 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
375 const int mb_xy= mb_x + mb_y*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
376 int mv_predictor[8][2]={{0}}; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
377 int pred_count=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
378 int j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
379 int best_score=256*256*256*64; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
380 int best_pred=0; |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
381 const int mot_stride= s->b8_stride; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
382 const int mot_index= mb_x*2 + mb_y*2*mot_stride; |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
383 int prev_x= s->current_picture.motion_val[0][mot_index][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
384 int prev_y= s->current_picture.motion_val[0][mot_index][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
385 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
386 if((mb_x^mb_y^pass)&1) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
387 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
388 if(fixed[mb_xy]==MV_FROZEN) continue; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
389 assert(!IS_INTRA(s->current_picture.mb_type[mb_xy])); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
390 assert(s->last_picture_ptr && s->last_picture_ptr->data[0]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
391 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
392 j=0; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
393 if(mb_x>0 && fixed[mb_xy-1 ]==MV_FROZEN) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
394 if(mb_x+1<mb_width && fixed[mb_xy+1 ]==MV_FROZEN) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
395 if(mb_y>0 && fixed[mb_xy-mb_stride]==MV_FROZEN) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
396 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_FROZEN) j=1; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
397 if(j==0) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
398 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
399 j=0; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
400 if(mb_x>0 && fixed[mb_xy-1 ]==MV_CHANGED) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
401 if(mb_x+1<mb_width && fixed[mb_xy+1 ]==MV_CHANGED) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
402 if(mb_y>0 && fixed[mb_xy-mb_stride]==MV_CHANGED) j=1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
403 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_CHANGED) j=1; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
404 if(j==0 && pass>1) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
405 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
406 none_left=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
407 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
408 if(mb_x>0 && fixed[mb_xy-1]){ |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
409 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - 2][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
410 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - 2][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
411 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
412 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
413 if(mb_x+1<mb_width && fixed[mb_xy+1]){ |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
414 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + 2][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
415 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + 2][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
416 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
417 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
418 if(mb_y>0 && fixed[mb_xy-mb_stride]){ |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
419 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*2][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
420 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*2][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
421 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
422 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
423 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
424 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*2][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
425 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*2][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
426 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
427 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
428 if(pred_count==0) continue; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
429 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
430 if(pred_count>1){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
431 int sum_x=0, sum_y=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
432 int max_x, max_y, min_x, min_y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
433 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
434 for(j=0; j<pred_count; j++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
435 sum_x+= mv_predictor[j][0]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
436 sum_y+= mv_predictor[j][1]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
437 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
438 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
439 /* mean */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
440 mv_predictor[pred_count][0] = sum_x/j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
441 mv_predictor[pred_count][1] = sum_y/j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
442 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
443 /* median */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
444 if(pred_count>=3){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
445 min_y= min_x= 99999; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
446 max_y= max_x=-99999; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
447 }else{ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
448 min_x=min_y=max_x=max_y=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
449 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
450 for(j=0; j<pred_count; j++){ |
847 | 451 max_x= FFMAX(max_x, mv_predictor[j][0]); |
452 max_y= FFMAX(max_y, mv_predictor[j][1]); | |
453 min_x= FFMIN(min_x, mv_predictor[j][0]); | |
454 min_y= FFMIN(min_y, mv_predictor[j][1]); | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
455 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
456 mv_predictor[pred_count+1][0] = sum_x - max_x - min_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
457 mv_predictor[pred_count+1][1] = sum_y - max_y - min_y; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
458 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
459 if(pred_count==4){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
460 mv_predictor[pred_count+1][0] /= 2; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
461 mv_predictor[pred_count+1][1] /= 2; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
462 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
463 pred_count+=2; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
464 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
465 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
466 /* zero MV */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
467 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
468 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
469 /* last MV */ |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
470 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
471 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
472 pred_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
473 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
474 s->mv_dir = MV_DIR_FORWARD; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
475 s->mb_intra=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
476 s->mv_type = MV_TYPE_16X16; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
477 s->mb_skiped=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
478 |
853
eacc2dd8fd9d
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
847
diff
changeset
|
479 s->dsp.clear_blocks(s->block[0]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
480 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
481 s->mb_x= mb_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
482 s->mb_y= mb_y; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
483 |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
484 for(j=0; j<pred_count; j++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
485 int score=0; |
1064 | 486 uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
487 |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
488 s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
489 s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1]; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
490 |
1389 | 491 decode_mb(s); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
492 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
493 if(mb_x>0 && fixed[mb_xy-1]){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
494 int k; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
495 for(k=0; k<16; k++) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
496 score += ABS(src[k*s->linesize-1 ]-src[k*s->linesize ]); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
497 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
498 if(mb_x+1<mb_width && fixed[mb_xy+1]){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
499 int k; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
500 for(k=0; k<16; k++) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
501 score += ABS(src[k*s->linesize+15]-src[k*s->linesize+16]); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
502 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
503 if(mb_y>0 && fixed[mb_xy-mb_stride]){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
504 int k; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
505 for(k=0; k<16; k++) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
506 score += ABS(src[k-s->linesize ]-src[k ]); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
507 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
508 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
509 int k; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
510 for(k=0; k<16; k++) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
511 score += ABS(src[k+s->linesize*15]-src[k+s->linesize*16]); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
512 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
513 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
514 if(score <= best_score){ // <= will favor the last MV |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
515 best_score= score; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
516 best_pred= j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
517 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
518 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
519 score_sum+= best_score; |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
520 //FIXME no need to set s->current_picture.motion_val[0][mot_index][0] explicit |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
521 s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0]; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
522 s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
523 |
1389 | 524 decode_mb(s); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
525 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
526 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
527 if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
528 fixed[mb_xy]=MV_CHANGED; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
529 changed++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
530 }else |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
531 fixed[mb_xy]=MV_UNCHANGED; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
532 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
533 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
534 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
535 // printf(".%d/%d", changed, score_sum); fflush(stdout); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
536 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
537 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
538 if(none_left) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
539 return; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
540 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
541 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
542 int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
543 if(fixed[mb_xy]) |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
544 fixed[mb_xy]=MV_FROZEN; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
545 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
546 // printf(":"); fflush(stdout); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
547 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
548 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
549 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
550 static int is_intra_more_likely(MpegEncContext *s){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
551 int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y; |
904
06776293eabb
use spatial error concealment if we dont have a previous frame
michaelni
parents:
903
diff
changeset
|
552 |
1138 | 553 if(s->last_picture_ptr==NULL) return 1; //no previous frame available -> use spatial prediction |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
554 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
555 undamaged_count=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
556 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
557 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
558 const int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
559 if(!((error&DC_ERROR) && (error&MV_ERROR))) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
560 undamaged_count++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
561 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
562 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
563 if(undamaged_count < 5) return 0; //allmost all MBs damaged -> use temporal prediction |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
564 |
847 | 565 skip_amount= FFMAX(undamaged_count/50, 1); //check only upto 50 MBs |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
566 is_intra_likely=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
567 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
568 j=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
569 for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
570 for(mb_x= 0; mb_x<s->mb_width; mb_x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
571 int error; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
572 const int mb_xy= mb_x + mb_y*s->mb_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
573 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
574 error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
575 if((error&DC_ERROR) && (error&MV_ERROR)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
576 continue; //skip damaged |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
577 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
578 j++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
579 if((j%skip_amount) != 0) continue; //skip a few to speed things up |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
580 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
581 if(s->pict_type==I_TYPE){ |
1064 | 582 uint8_t *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; |
583 uint8_t *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize; | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
584 |
1708 | 585 is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); |
586 is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16); | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
587 }else{ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
588 if(IS_INTRA(s->current_picture.mb_type[mb_xy])) |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
589 is_intra_likely++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
590 else |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
591 is_intra_likely--; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
592 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
593 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
594 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
595 //printf("is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
596 return is_intra_likely > 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
597 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
598 |
1144 | 599 void ff_er_frame_start(MpegEncContext *s){ |
600 if(!s->error_resilience) return; | |
601 | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
602 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)); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
603 s->error_count= 3*s->mb_num; |
1144 | 604 } |
605 | |
606 /** | |
607 * adds a slice. | |
608 * @param endx x component of the last macroblock, can be -1 for the last of the previous line | |
609 * @param status the status at the end (MV_END, AC_ERROR, ...), it is assumed that no earlier end or | |
610 * error of the same type occured | |
611 */ | |
612 void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status){ | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
613 const int start_i= clip(startx + starty * s->mb_width , 0, s->mb_num-1); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
614 const int end_i = clip(endx + endy * s->mb_width , 0, s->mb_num); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
615 const int start_xy= s->mb_index2xy[start_i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
616 const int end_xy = s->mb_index2xy[end_i]; |
1144 | 617 int mask= -1; |
618 | |
619 if(!s->error_resilience) return; | |
620 | |
621 mask &= ~VP_START; | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
622 if(status & (AC_ERROR|AC_END)){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
623 mask &= ~(AC_ERROR|AC_END); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
624 s->error_count -= end_i - start_i + 1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
625 } |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
626 if(status & (DC_ERROR|DC_END)){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
627 mask &= ~(DC_ERROR|DC_END); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
628 s->error_count -= end_i - start_i + 1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
629 } |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
630 if(status & (MV_ERROR|MV_END)){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
631 mask &= ~(MV_ERROR|MV_END); |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
632 s->error_count -= end_i - start_i + 1; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
633 } |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
634 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
635 if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) s->error_count= INT_MAX; |
1144 | 636 |
637 if(mask == ~0x7F){ | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
638 memset(&s->error_status_table[start_xy], 0, (end_xy - start_xy) * sizeof(uint8_t)); |
1144 | 639 }else{ |
640 int i; | |
641 for(i=start_xy; i<end_xy; i++){ | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
642 s->error_status_table[ i ] &= mask; |
1144 | 643 } |
644 } | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
645 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
646 if(end_i == s->mb_num) |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
647 s->error_count= INT_MAX; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
648 else{ |
1144 | 649 s->error_status_table[end_xy] &= mask; |
650 s->error_status_table[end_xy] |= status; | |
651 } | |
1175
d2fd27d01df8
fixing slice decoding, dunno why the regression tests didnt catch that ...
michaelni
parents:
1144
diff
changeset
|
652 |
d2fd27d01df8
fixing slice decoding, dunno why the regression tests didnt catch that ...
michaelni
parents:
1144
diff
changeset
|
653 s->error_status_table[start_xy] |= VP_START; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
654 |
2095 | 655 if(start_xy > 0 && s->avctx->thread_count <= 1 && s->avctx->skip_top*s->mb_width < start_i){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
656 int prev_status= s->error_status_table[ s->mb_index2xy[start_i - 1] ]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
657 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
658 prev_status &= ~ VP_START; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
659 if(prev_status != (MV_END|DC_END|AC_END)) s->error_count= INT_MAX; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
660 } |
1144 | 661 } |
662 | |
663 void ff_er_frame_end(MpegEncContext *s){ | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
664 int i, mb_x, mb_y, error, error_type; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
665 int distance; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
666 int threshold_part[4]= {100,100,100}; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
667 int threshold= 50; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
668 int is_intra_likely; |
1144 | 669 |
2095 | 670 if(!s->error_resilience || s->error_count==0 || |
671 s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return; | |
1144 | 672 |
2095 | 673 av_log(s->avctx, AV_LOG_INFO, "concealing %d errors\n", s->error_count); |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
674 |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
675 if(s->current_picture.motion_val[0] == NULL){ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
676 int size = s->b8_stride * 2 * s->mb_height; |
1731 | 677 Picture *pic= s->current_picture_ptr; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
678 |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1417
diff
changeset
|
679 av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); |
1731 | 680 |
681 for(i=0; i<2; i++){ | |
1952 | 682 pic->ref_index[i]= av_mallocz(size * sizeof(uint8_t)); |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
683 pic->motion_val_base[i]= av_mallocz((size+2) * 2 * sizeof(uint16_t)); |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
684 pic->motion_val[i]= pic->motion_val_base[i]+2; |
1731 | 685 } |
686 pic->motion_subsample_log2= 3; | |
687 s->current_picture= *s->current_picture_ptr; | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
688 } |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
689 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
690 if(s->avctx->debug&FF_DEBUG_ER){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
691 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
692 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
693 int status= s->error_status_table[mb_x + mb_y*s->mb_stride]; |
1144 | 694 |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1417
diff
changeset
|
695 av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status); |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
696 } |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1417
diff
changeset
|
697 av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
1144 | 698 } |
699 } | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
700 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
701 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
702 /* handle overlapping slices */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
703 for(error_type=1; error_type<=3; error_type++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
704 int end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
705 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
706 for(i=s->mb_num-1; i>=0; i--){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
707 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
708 int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
709 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
710 if(error&(1<<error_type)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
711 end_ok=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
712 if(error&(8<<error_type)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
713 end_ok=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
714 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
715 if(!end_ok) |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
716 s->error_status_table[mb_xy]|= 1<<error_type; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
717 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
718 if(error&VP_START) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
719 end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
720 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
721 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
722 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
723 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
724 /* handle slices with partitions of different length */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
725 if(s->partitioned_frame){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
726 int end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
727 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
728 for(i=s->mb_num-1; i>=0; i--){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
729 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
730 int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
731 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
732 if(error&AC_END) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
733 end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
734 if((error&MV_END) || (error&DC_END) || (error&AC_ERROR)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
735 end_ok=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
736 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
737 if(!end_ok) |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
738 s->error_status_table[mb_xy]|= AC_ERROR; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
739 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
740 if(error&VP_START) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
741 end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
742 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
743 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
744 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
745 /* handle missing slices */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
746 if(s->error_resilience>=4){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
747 int end_ok=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
748 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
749 for(i=s->mb_num-2; i>=s->mb_width+100; i--){ //FIXME +100 hack |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
750 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
751 int error1= s->error_status_table[mb_xy ]; |
1285 | 752 int error2= s->error_status_table[s->mb_index2xy[i+1]]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
753 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
754 if(error1&VP_START) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
755 end_ok=1; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
756 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
757 if( error2==(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
758 && error1!=(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
759 && ((error1&AC_END) || (error1&DC_END) || (error1&MV_END))){ //end & uninited |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
760 end_ok=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
761 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
762 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
763 if(!end_ok) |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
764 s->error_status_table[mb_xy]|= DC_ERROR|AC_ERROR|MV_ERROR; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
765 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
766 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
767 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
768 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
769 /* backward mark errors */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
770 distance=9999999; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
771 for(error_type=1; error_type<=3; error_type++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
772 for(i=s->mb_num-1; i>=0; i--){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
773 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
774 int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
775 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
776 if(!s->mbskip_table[mb_xy]) //FIXME partition specific |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
777 distance++; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
778 if(error&(1<<error_type)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
779 distance= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
780 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
781 if(s->partitioned_frame){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
782 if(distance < threshold_part[error_type-1]) |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
783 s->error_status_table[mb_xy]|= 1<<error_type; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
784 }else{ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
785 if(distance < threshold) |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
786 s->error_status_table[mb_xy]|= 1<<error_type; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
787 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
788 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
789 if(error&VP_START) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
790 distance= 9999999; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
791 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
792 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
793 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
794 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
795 /* forward mark errors */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
796 error=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
797 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
798 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
799 int old_error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
800 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
801 if(old_error&VP_START) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
802 error= old_error& (DC_ERROR|AC_ERROR|MV_ERROR); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
803 else{ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
804 error|= old_error& (DC_ERROR|AC_ERROR|MV_ERROR); |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
805 s->error_status_table[mb_xy]|= error; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
806 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
807 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
808 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
809 /* handle not partitioned case */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
810 if(!s->partitioned_frame){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
811 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
812 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
813 error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
814 if(error&(AC_ERROR|DC_ERROR|MV_ERROR)) |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
815 error|= AC_ERROR|DC_ERROR|MV_ERROR; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
816 s->error_status_table[mb_xy]= error; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
817 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
818 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
819 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
820 is_intra_likely= is_intra_more_likely(s); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
821 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
822 /* set unknown mb-type to most likely */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
823 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
824 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
825 error= s->error_status_table[mb_xy]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
826 if(!((error&DC_ERROR) && (error&MV_ERROR))) |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
827 continue; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
828 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
829 if(is_intra_likely) |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
830 s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
831 else |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
832 s->current_picture.mb_type[mb_xy]= MB_TYPE_16x16 | MB_TYPE_L0; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
833 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
834 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
835 /* handle inter blocks with damaged AC */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
836 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
837 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
838 const int mb_xy= mb_x + mb_y * s->mb_stride; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
839 const int mb_type= s->current_picture.mb_type[mb_xy]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
840 error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
841 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
842 if(IS_INTRA(mb_type)) continue; //intra |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
843 if(error&MV_ERROR) continue; //inter with damaged MV |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
844 if(!(error&AC_ERROR)) continue; //undamaged inter |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
845 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
846 s->mv_dir = MV_DIR_FORWARD; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
847 s->mb_intra=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
848 s->mb_skiped=0; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
849 if(IS_8X8(mb_type)){ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
850 int mb_index= mb_x*2 + mb_y*2*s->b8_stride; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
851 int j; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
852 s->mv_type = MV_TYPE_8X8; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
853 for(j=0; j<4; j++){ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
854 s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][0]; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
855 s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
856 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
857 }else{ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
858 s->mv_type = MV_TYPE_16X16; |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
859 s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][0]; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
860 s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][1]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
861 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
862 |
853
eacc2dd8fd9d
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
847
diff
changeset
|
863 s->dsp.clear_blocks(s->block[0]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
864 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
865 s->mb_x= mb_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
866 s->mb_y= mb_y; |
1389 | 867 decode_mb(s); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
868 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
869 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
870 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
871 /* guess MVs */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
872 if(s->pict_type==B_TYPE){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
873 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
874 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
875 int xy= mb_x*2 + mb_y*2*s->b8_stride; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
876 const int mb_xy= mb_x + mb_y * s->mb_stride; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
877 const int mb_type= s->current_picture.mb_type[mb_xy]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
878 error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
879 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
880 if(IS_INTRA(mb_type)) continue; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
881 if(!(error&MV_ERROR)) continue; //inter with undamaged MV |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
882 if(!(error&AC_ERROR)) continue; //undamaged inter |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
883 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
884 s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
885 s->mb_intra=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
886 s->mv_type = MV_TYPE_16X16; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
887 s->mb_skiped=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
888 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
889 if(s->pp_time){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
890 int time_pp= s->pp_time; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
891 int time_pb= s->pb_time; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
892 |
1668
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
893 s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
894 s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
895 s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp; |
30746f429df6
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents:
1598
diff
changeset
|
896 s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
897 }else{ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
898 s->mv[0][0][0]= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
899 s->mv[0][0][1]= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
900 s->mv[1][0][0]= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
901 s->mv[1][0][1]= 0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
902 } |
853
eacc2dd8fd9d
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
847
diff
changeset
|
903 |
eacc2dd8fd9d
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
847
diff
changeset
|
904 s->dsp.clear_blocks(s->block[0]); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
905 s->mb_x= mb_x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
906 s->mb_y= mb_y; |
1389 | 907 decode_mb(s); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
908 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
909 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
910 }else |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
911 guess_mv(s); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
912 |
1381 | 913 #ifdef HAVE_XVMC |
914 /* the filters below are not XvMC compatible, skip them */ | |
915 if(s->avctx->xvmc_acceleration) goto ec_clean; | |
916 #endif | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
917 /* fill DC for inter blocks */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
918 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
919 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
920 int dc, dcu, dcv, y, n; |
1064 | 921 int16_t *dc_ptr; |
922 uint8_t *dest_y, *dest_cb, *dest_cr; | |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
923 const int mb_xy= mb_x + mb_y * s->mb_stride; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
924 const int mb_type= s->current_picture.mb_type[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
925 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
926 error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
927 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
928 if(IS_INTRA(mb_type) && s->partitioned_frame) continue; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
929 // if(error&MV_ERROR) continue; //inter data damaged FIXME is this good? |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
930 |
903 | 931 dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; |
932 dest_cb= s->current_picture.data[1] + mb_x*8 + mb_y*8 *s->uvlinesize; | |
933 dest_cr= s->current_picture.data[2] + mb_x*8 + mb_y*8 *s->uvlinesize; | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
934 |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
935 dc_ptr= &s->dc_val[0][mb_x*2 + mb_y*2*s->b8_stride]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
936 for(n=0; n<4; n++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
937 dc=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
938 for(y=0; y<8; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
939 int x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
940 for(x=0; x<8; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
941 dc+= dest_y[x + (n&1)*8 + (y + (n>>1)*8)*s->linesize]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
942 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
943 } |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
944 dc_ptr[(n&1) + (n>>1)*s->b8_stride]= (dc+4)>>3; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
945 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
946 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
947 dcu=dcv=0; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
948 for(y=0; y<8; y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
949 int x; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
950 for(x=0; x<8; x++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
951 dcu+=dest_cb[x + y*(s->uvlinesize)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
952 dcv+=dest_cr[x + y*(s->uvlinesize)]; |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
953 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
954 } |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
955 s->dc_val[1][mb_x + mb_y*s->mb_stride]= (dcu+4)>>3; |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
956 s->dc_val[2][mb_x + mb_y*s->mb_stride]= (dcv+4)>>3; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
957 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
958 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
959 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
960 /* guess DC for damaged blocks */ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
961 guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1); |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
962 guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride, 0); |
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
963 guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride, 0); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
964 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
965 /* filter luma DC */ |
1938
e2501e6e7ff7
unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents:
1827
diff
changeset
|
966 filter181(s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride); |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
967 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
968 #if 1 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
969 /* render DC only intra */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
970 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
971 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1064 | 972 uint8_t *dest_y, *dest_cb, *dest_cr; |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
973 const int mb_xy= mb_x + mb_y * s->mb_stride; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
974 const int mb_type= s->current_picture.mb_type[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
975 |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
976 error= s->error_status_table[mb_xy]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
977 |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
978 if(IS_INTER(mb_type)) continue; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
979 if(!(error&AC_ERROR)) continue; //undamaged |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
980 |
903 | 981 dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; |
982 dest_cb= s->current_picture.data[1] + mb_x*8 + mb_y*8 *s->uvlinesize; | |
983 dest_cr= s->current_picture.data[2] + mb_x*8 + mb_y*8 *s->uvlinesize; | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
984 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
985 put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y); |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
986 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
987 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
988 #endif |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
989 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
990 if(s->avctx->error_concealment&FF_EC_DEBLOCK){ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
991 /* filter horizontal block boundaries */ |
903 | 992 h_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); |
993 h_block_filter(s, s->current_picture.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); | |
994 h_block_filter(s, s->current_picture.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
995 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
996 /* filter vertical block boundaries */ |
903 | 997 v_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize , 1); |
998 v_block_filter(s, s->current_picture.data[1], s->mb_width , s->mb_height , s->uvlinesize, 0); | |
999 v_block_filter(s, s->current_picture.data[2], s->mb_width , s->mb_height , s->uvlinesize, 0); | |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1000 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1001 |
1417 | 1002 #ifdef HAVE_XVMC |
1381 | 1003 ec_clean: |
1417 | 1004 #endif |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1005 /* clean a few tables */ |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1006 for(i=0; i<s->mb_num; i++){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
1007 const int mb_xy= s->mb_index2xy[i]; |
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
1008 int error= s->error_status_table[mb_xy]; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1009 |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1010 if(s->pict_type!=B_TYPE && (error&(DC_ERROR|MV_ERROR|AC_ERROR))){ |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
1011 s->mbskip_table[mb_xy]=0; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1012 } |
1177
fea03d2c4946
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead of mb_x + mb_y*mb_width and 1+mb_x + (1+mb_y)*(mb_width+2) and ... mixture
michaelni
parents:
1175
diff
changeset
|
1013 s->mbintra_table[mb_xy]=1; |
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1014 } |
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
diff
changeset
|
1015 } |