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