... | ... |
@@ -29,58 +29,21 @@ |
29 | 29 |
|
30 | 30 |
#include "avcodec.h" |
31 | 31 |
#include "dsputil.h" |
32 |
+#include "error_resilience.h" |
|
32 | 33 |
#include "mpegvideo.h" |
33 |
-#include "h264.h" |
|
34 | 34 |
#include "rectangle.h" |
35 | 35 |
#include "thread.h" |
36 | 36 |
|
37 |
-/* |
|
38 |
- * H264 redefines mb_intra so it is not mistakely used (its uninitialized in h264) |
|
39 |
- * but error concealment must support both h264 and h263 thus we must undo this |
|
40 |
- */ |
|
41 |
-#undef mb_intra |
|
42 |
- |
|
43 |
-static void decode_mb(MpegEncContext *s, int ref) |
|
44 |
-{ |
|
45 |
- s->dest[0] = s->current_picture.f.data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16; |
|
46 |
- s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); |
|
47 |
- s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); |
|
48 |
- |
|
49 |
- if (CONFIG_H264_DECODER && s->codec_id == AV_CODEC_ID_H264) { |
|
50 |
- H264Context *h = (void*)s; |
|
51 |
- h->mb_xy = s->mb_x + s->mb_y * s->mb_stride; |
|
52 |
- memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache)); |
|
53 |
- assert(ref >= 0); |
|
54 |
- /* FIXME: It is possible albeit uncommon that slice references |
|
55 |
- * differ between slices. We take the easy approach and ignore |
|
56 |
- * it for now. If this turns out to have any relevance in |
|
57 |
- * practice then correct remapping should be added. */ |
|
58 |
- if (ref >= h->ref_count[0]) |
|
59 |
- ref = 0; |
|
60 |
- fill_rectangle(&s->current_picture.f.ref_index[0][4 * h->mb_xy], |
|
61 |
- 2, 2, 2, ref, 1); |
|
62 |
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); |
|
63 |
- fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, |
|
64 |
- pack16to32(s->mv[0][0][0], s->mv[0][0][1]), 4); |
|
65 |
- assert(!FRAME_MBAFF); |
|
66 |
- ff_h264_hl_decode_mb(h); |
|
67 |
- } else { |
|
68 |
- assert(ref == 0); |
|
69 |
- ff_MPV_decode_mb(s, s->block); |
|
70 |
- } |
|
71 |
-} |
|
72 |
- |
|
73 | 37 |
/** |
74 | 38 |
* @param stride the number of MVs to get to the next row |
75 | 39 |
* @param mv_step the number of MVs per row or column in a macroblock |
76 | 40 |
*/ |
77 |
-static void set_mv_strides(MpegEncContext *s, int *mv_step, int *stride) |
|
41 |
+static void set_mv_strides(ERContext *s, int *mv_step, int *stride) |
|
78 | 42 |
{ |
79 |
- if (s->codec_id == AV_CODEC_ID_H264) { |
|
80 |
- H264Context *h = (void*)s; |
|
43 |
+ if (s->avctx->codec_id == AV_CODEC_ID_H264) { |
|
81 | 44 |
assert(s->quarter_sample); |
82 | 45 |
*mv_step = 4; |
83 |
- *stride = h->b_stride; |
|
46 |
+ *stride = s->mb_width * 4; |
|
84 | 47 |
} else { |
85 | 48 |
*mv_step = 2; |
86 | 49 |
*stride = s->b8_stride; |
... | ... |
@@ -90,9 +53,10 @@ static void set_mv_strides(MpegEncContext *s, int *mv_step, int *stride) |
90 | 90 |
/** |
91 | 91 |
* Replace the current MB with a flat dc-only version. |
92 | 92 |
*/ |
93 |
-static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, |
|
93 |
+static void put_dc(ERContext *s, uint8_t *dest_y, uint8_t *dest_cb, |
|
94 | 94 |
uint8_t *dest_cr, int mb_x, int mb_y) |
95 | 95 |
{ |
96 |
+ int *linesize = s->cur_pic->f.linesize; |
|
96 | 97 |
int dc, dcu, dcv, y, i; |
97 | 98 |
for (i = 0; i < 4; i++) { |
98 | 99 |
dc = s->dc_val[0][mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * s->b8_stride]; |
... | ... |
@@ -103,7 +67,7 @@ static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, |
103 | 103 |
for (y = 0; y < 8; y++) { |
104 | 104 |
int x; |
105 | 105 |
for (x = 0; x < 8; x++) |
106 |
- dest_y[x + (i & 1) * 8 + (y + (i >> 1) * 8) * s->linesize] = dc / 8; |
|
106 |
+ dest_y[x + (i & 1) * 8 + (y + (i >> 1) * 8) * linesize[0]] = dc / 8; |
|
107 | 107 |
} |
108 | 108 |
} |
109 | 109 |
dcu = s->dc_val[1][mb_x + mb_y * s->mb_stride]; |
... | ... |
@@ -119,8 +83,8 @@ static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, |
119 | 119 |
for (y = 0; y < 8; y++) { |
120 | 120 |
int x; |
121 | 121 |
for (x = 0; x < 8; x++) { |
122 |
- dest_cb[x + y * s->uvlinesize] = dcu / 8; |
|
123 |
- dest_cr[x + y * s->uvlinesize] = dcv / 8; |
|
122 |
+ dest_cb[x + y * linesize[1]] = dcu / 8; |
|
123 |
+ dest_cr[x + y * linesize[2]] = dcv / 8; |
|
124 | 124 |
} |
125 | 125 |
} |
126 | 126 |
} |
... | ... |
@@ -166,7 +130,7 @@ static void filter181(int16_t *data, int width, int height, int stride) |
166 | 166 |
* @param w width in 8 pixel blocks |
167 | 167 |
* @param h height in 8 pixel blocks |
168 | 168 |
*/ |
169 |
-static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
|
169 |
+static void guess_dc(ERContext *s, int16_t *dc, int w, |
|
170 | 170 |
int h, int stride, int is_luma) |
171 | 171 |
{ |
172 | 172 |
int b_x, b_y; |
... | ... |
@@ -180,7 +144,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
180 | 180 |
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride; |
181 | 181 |
error = s->error_status_table[mb_index]; |
182 | 182 |
|
183 |
- if (IS_INTER(s->current_picture.f.mb_type[mb_index])) |
|
183 |
+ if (IS_INTER(s->cur_pic->f.mb_type[mb_index])) |
|
184 | 184 |
continue; // inter |
185 | 185 |
if (!(error & ER_DC_ERROR)) |
186 | 186 |
continue; // dc-ok |
... | ... |
@@ -189,7 +153,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
189 | 189 |
for (j = b_x + 1; j < w; j++) { |
190 | 190 |
int mb_index_j = (j >> is_luma) + (b_y >> is_luma) * s->mb_stride; |
191 | 191 |
int error_j = s->error_status_table[mb_index_j]; |
192 |
- int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); |
|
192 |
+ int intra_j = IS_INTRA(s->cur_pic->f.mb_type[mb_index_j]); |
|
193 | 193 |
if (intra_j == 0 || !(error_j & ER_DC_ERROR)) { |
194 | 194 |
color[0] = dc[j + b_y * stride]; |
195 | 195 |
distance[0] = j - b_x; |
... | ... |
@@ -201,7 +165,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
201 | 201 |
for (j = b_x - 1; j >= 0; j--) { |
202 | 202 |
int mb_index_j = (j >> is_luma) + (b_y >> is_luma) * s->mb_stride; |
203 | 203 |
int error_j = s->error_status_table[mb_index_j]; |
204 |
- int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); |
|
204 |
+ int intra_j = IS_INTRA(s->cur_pic->f.mb_type[mb_index_j]); |
|
205 | 205 |
if (intra_j == 0 || !(error_j & ER_DC_ERROR)) { |
206 | 206 |
color[1] = dc[j + b_y * stride]; |
207 | 207 |
distance[1] = b_x - j; |
... | ... |
@@ -213,7 +177,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
213 | 213 |
for (j = b_y + 1; j < h; j++) { |
214 | 214 |
int mb_index_j = (b_x >> is_luma) + (j >> is_luma) * s->mb_stride; |
215 | 215 |
int error_j = s->error_status_table[mb_index_j]; |
216 |
- int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); |
|
216 |
+ int intra_j = IS_INTRA(s->cur_pic->f.mb_type[mb_index_j]); |
|
217 | 217 |
|
218 | 218 |
if (intra_j == 0 || !(error_j & ER_DC_ERROR)) { |
219 | 219 |
color[2] = dc[b_x + j * stride]; |
... | ... |
@@ -226,7 +190,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
226 | 226 |
for (j = b_y - 1; j >= 0; j--) { |
227 | 227 |
int mb_index_j = (b_x >> is_luma) + (j >> is_luma) * s->mb_stride; |
228 | 228 |
int error_j = s->error_status_table[mb_index_j]; |
229 |
- int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); |
|
229 |
+ int intra_j = IS_INTRA(s->cur_pic->f.mb_type[mb_index_j]); |
|
230 | 230 |
if (intra_j == 0 || !(error_j & ER_DC_ERROR)) { |
231 | 231 |
color[3] = dc[b_x + j * stride]; |
232 | 232 |
distance[3] = b_y - j; |
... | ... |
@@ -252,7 +216,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w, |
252 | 252 |
* @param w width in 8 pixel blocks |
253 | 253 |
* @param h height in 8 pixel blocks |
254 | 254 |
*/ |
255 |
-static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, |
|
255 |
+static void h_block_filter(ERContext *s, uint8_t *dst, int w, |
|
256 | 256 |
int h, int stride, int is_luma) |
257 | 257 |
{ |
258 | 258 |
int b_x, b_y, mvx_stride, mvy_stride; |
... | ... |
@@ -266,13 +230,13 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, |
266 | 266 |
int y; |
267 | 267 |
int left_status = s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]; |
268 | 268 |
int right_status = s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]; |
269 |
- int left_intra = IS_INTRA(s->current_picture.f.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]); |
|
270 |
- int right_intra = IS_INTRA(s->current_picture.f.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]); |
|
269 |
+ int left_intra = IS_INTRA(s->cur_pic->f.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]); |
|
270 |
+ int right_intra = IS_INTRA(s->cur_pic->f.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]); |
|
271 | 271 |
int left_damage = left_status & ER_MB_ERROR; |
272 | 272 |
int right_damage = right_status & ER_MB_ERROR; |
273 | 273 |
int offset = b_x * 8 + b_y * stride * 8; |
274 |
- int16_t *left_mv = s->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x]; |
|
275 |
- int16_t *right_mv = s->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)]; |
|
274 |
+ int16_t *left_mv = s->cur_pic->f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x]; |
|
275 |
+ int16_t *right_mv = s->cur_pic->f.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)]; |
|
276 | 276 |
if (!(left_damage || right_damage)) |
277 | 277 |
continue; // both undamaged |
278 | 278 |
if ((!left_intra) && (!right_intra) && |
... | ... |
@@ -320,7 +284,7 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, |
320 | 320 |
* @param w width in 8 pixel blocks |
321 | 321 |
* @param h height in 8 pixel blocks |
322 | 322 |
*/ |
323 |
-static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, |
|
323 |
+static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h, |
|
324 | 324 |
int stride, int is_luma) |
325 | 325 |
{ |
326 | 326 |
int b_x, b_y, mvx_stride, mvy_stride; |
... | ... |
@@ -334,14 +298,14 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, |
334 | 334 |
int x; |
335 | 335 |
int top_status = s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]; |
336 | 336 |
int bottom_status = s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]; |
337 |
- int top_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]); |
|
338 |
- int bottom_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]); |
|
337 |
+ int top_intra = IS_INTRA(s->cur_pic->f.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]); |
|
338 |
+ int bottom_intra = IS_INTRA(s->cur_pic->f.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]); |
|
339 | 339 |
int top_damage = top_status & ER_MB_ERROR; |
340 | 340 |
int bottom_damage = bottom_status & ER_MB_ERROR; |
341 | 341 |
int offset = b_x * 8 + b_y * stride * 8; |
342 | 342 |
|
343 |
- int16_t *top_mv = s->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x]; |
|
344 |
- int16_t *bottom_mv = s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x]; |
|
343 |
+ int16_t *top_mv = s->cur_pic->f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x]; |
|
344 |
+ int16_t *bottom_mv = s->cur_pic->f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x]; |
|
345 | 345 |
|
346 | 346 |
if (!(top_damage || bottom_damage)) |
347 | 347 |
continue; // both undamaged |
... | ... |
@@ -386,7 +350,7 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, |
386 | 386 |
} |
387 | 387 |
} |
388 | 388 |
|
389 |
-static void guess_mv(MpegEncContext *s) |
|
389 |
+static void guess_mv(ERContext *s) |
|
390 | 390 |
{ |
391 | 391 |
uint8_t *fixed = s->er_temp_buffer; |
392 | 392 |
#define MV_FROZEN 3 |
... | ... |
@@ -406,7 +370,7 @@ static void guess_mv(MpegEncContext *s) |
406 | 406 |
int f = 0; |
407 | 407 |
int error = s->error_status_table[mb_xy]; |
408 | 408 |
|
409 |
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) |
|
409 |
+ if (IS_INTRA(s->cur_pic->f.mb_type[mb_xy])) |
|
410 | 410 |
f = MV_FROZEN; // intra // FIXME check |
411 | 411 |
if (!(error & ER_MV_ERROR)) |
412 | 412 |
f = MV_FROZEN; // inter with undamaged MV |
... | ... |
@@ -419,32 +383,19 @@ static void guess_mv(MpegEncContext *s) |
419 | 419 |
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || |
420 | 420 |
num_avail <= mb_width / 2) { |
421 | 421 |
for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
422 |
- s->mb_x = 0; |
|
423 |
- s->mb_y = mb_y; |
|
424 |
- ff_init_block_index(s); |
|
425 | 422 |
for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
426 | 423 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
424 |
+ int mv_dir = (s->last_pic && s->last_pic->f.data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD; |
|
427 | 425 |
|
428 |
- ff_update_block_index(s); |
|
429 |
- |
|
430 |
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) |
|
426 |
+ if (IS_INTRA(s->cur_pic->f.mb_type[mb_xy])) |
|
431 | 427 |
continue; |
432 | 428 |
if (!(s->error_status_table[mb_xy] & ER_MV_ERROR)) |
433 | 429 |
continue; |
434 | 430 |
|
435 |
- s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD |
|
436 |
- : MV_DIR_BACKWARD; |
|
437 |
- s->mb_intra = 0; |
|
438 |
- s->mv_type = MV_TYPE_16X16; |
|
439 |
- s->mb_skipped = 0; |
|
440 |
- |
|
441 |
- s->dsp.clear_blocks(s->block[0]); |
|
442 |
- |
|
443 |
- s->mb_x = mb_x; |
|
444 |
- s->mb_y = mb_y; |
|
445 | 431 |
s->mv[0][0][0] = 0; |
446 | 432 |
s->mv[0][0][1] = 0; |
447 |
- decode_mb(s, 0); |
|
433 |
+ s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv, |
|
434 |
+ mb_x, mb_y, 0, 0); |
|
448 | 435 |
} |
449 | 436 |
} |
450 | 437 |
return; |
... | ... |
@@ -461,9 +412,6 @@ static void guess_mv(MpegEncContext *s) |
461 | 461 |
|
462 | 462 |
changed = 0; |
463 | 463 |
for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
464 |
- s->mb_x = 0; |
|
465 |
- s->mb_y = mb_y; |
|
466 |
- ff_init_block_index(s); |
|
467 | 464 |
for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
468 | 465 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
469 | 466 |
int mv_predictor[8][2] = { { 0 } }; |
... | ... |
@@ -475,15 +423,13 @@ static void guess_mv(MpegEncContext *s) |
475 | 475 |
const int mot_index = (mb_x + mb_y * mot_stride) * mot_step; |
476 | 476 |
int prev_x, prev_y, prev_ref; |
477 | 477 |
|
478 |
- ff_update_block_index(s); |
|
479 |
- |
|
480 | 478 |
if ((mb_x ^ mb_y ^ pass) & 1) |
481 | 479 |
continue; |
482 | 480 |
|
483 | 481 |
if (fixed[mb_xy] == MV_FROZEN) |
484 | 482 |
continue; |
485 |
- assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy])); |
|
486 |
- assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]); |
|
483 |
+ assert(!IS_INTRA(s->cur_pic->f.mb_type[mb_xy])); |
|
484 |
+ assert(s->last_pic && s->last_pic->f.data[0]); |
|
487 | 485 |
|
488 | 486 |
j = 0; |
489 | 487 |
if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN) |
... | ... |
@@ -513,38 +459,38 @@ static void guess_mv(MpegEncContext *s) |
513 | 513 |
|
514 | 514 |
if (mb_x > 0 && fixed[mb_xy - 1]) { |
515 | 515 |
mv_predictor[pred_count][0] = |
516 |
- s->current_picture.f.motion_val[0][mot_index - mot_step][0]; |
|
516 |
+ s->cur_pic->f.motion_val[0][mot_index - mot_step][0]; |
|
517 | 517 |
mv_predictor[pred_count][1] = |
518 |
- s->current_picture.f.motion_val[0][mot_index - mot_step][1]; |
|
518 |
+ s->cur_pic->f.motion_val[0][mot_index - mot_step][1]; |
|
519 | 519 |
ref[pred_count] = |
520 |
- s->current_picture.f.ref_index[0][4 * (mb_xy - 1)]; |
|
520 |
+ s->cur_pic->f.ref_index[0][4 * (mb_xy - 1)]; |
|
521 | 521 |
pred_count++; |
522 | 522 |
} |
523 | 523 |
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { |
524 | 524 |
mv_predictor[pred_count][0] = |
525 |
- s->current_picture.f.motion_val[0][mot_index + mot_step][0]; |
|
525 |
+ s->cur_pic->f.motion_val[0][mot_index + mot_step][0]; |
|
526 | 526 |
mv_predictor[pred_count][1] = |
527 |
- s->current_picture.f.motion_val[0][mot_index + mot_step][1]; |
|
527 |
+ s->cur_pic->f.motion_val[0][mot_index + mot_step][1]; |
|
528 | 528 |
ref[pred_count] = |
529 |
- s->current_picture.f.ref_index[0][4 * (mb_xy + 1)]; |
|
529 |
+ s->cur_pic->f.ref_index[0][4 * (mb_xy + 1)]; |
|
530 | 530 |
pred_count++; |
531 | 531 |
} |
532 | 532 |
if (mb_y > 0 && fixed[mb_xy - mb_stride]) { |
533 | 533 |
mv_predictor[pred_count][0] = |
534 |
- s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][0]; |
|
534 |
+ s->cur_pic->f.motion_val[0][mot_index - mot_stride * mot_step][0]; |
|
535 | 535 |
mv_predictor[pred_count][1] = |
536 |
- s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][1]; |
|
536 |
+ s->cur_pic->f.motion_val[0][mot_index - mot_stride * mot_step][1]; |
|
537 | 537 |
ref[pred_count] = |
538 |
- s->current_picture.f.ref_index[0][4 * (mb_xy - s->mb_stride)]; |
|
538 |
+ s->cur_pic->f.ref_index[0][4 * (mb_xy - s->mb_stride)]; |
|
539 | 539 |
pred_count++; |
540 | 540 |
} |
541 | 541 |
if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) { |
542 | 542 |
mv_predictor[pred_count][0] = |
543 |
- s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][0]; |
|
543 |
+ s->cur_pic->f.motion_val[0][mot_index + mot_stride * mot_step][0]; |
|
544 | 544 |
mv_predictor[pred_count][1] = |
545 |
- s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][1]; |
|
545 |
+ s->cur_pic->f.motion_val[0][mot_index + mot_stride * mot_step][1]; |
|
546 | 546 |
ref[pred_count] = |
547 |
- s->current_picture.f.ref_index[0][4 * (mb_xy + s->mb_stride)]; |
|
547 |
+ s->cur_pic->f.ref_index[0][4 * (mb_xy + s->mb_stride)]; |
|
548 | 548 |
pred_count++; |
549 | 549 |
} |
550 | 550 |
if (pred_count == 0) |
... | ... |
@@ -602,19 +548,19 @@ skip_mean_and_median: |
602 | 602 |
if (s->avctx->codec_id == AV_CODEC_ID_H264) { |
603 | 603 |
// FIXME |
604 | 604 |
} else { |
605 |
- ff_thread_await_progress(&s->last_picture_ptr->f, |
|
605 |
+ ff_thread_await_progress(&s->last_pic->f, |
|
606 | 606 |
mb_y, 0); |
607 | 607 |
} |
608 |
- if (!s->last_picture.f.motion_val[0] || |
|
609 |
- !s->last_picture.f.ref_index[0]) |
|
608 |
+ if (!s->last_pic->f.motion_val[0] || |
|
609 |
+ !s->last_pic->f.ref_index[0]) |
|
610 | 610 |
goto skip_last_mv; |
611 |
- prev_x = s->last_picture.f.motion_val[0][mot_index][0]; |
|
612 |
- prev_y = s->last_picture.f.motion_val[0][mot_index][1]; |
|
613 |
- prev_ref = s->last_picture.f.ref_index[0][4 * mb_xy]; |
|
611 |
+ prev_x = s->last_pic->f.motion_val[0][mot_index][0]; |
|
612 |
+ prev_y = s->last_pic->f.motion_val[0][mot_index][1]; |
|
613 |
+ prev_ref = s->last_pic->f.ref_index[0][4 * mb_xy]; |
|
614 | 614 |
} else { |
615 |
- prev_x = s->current_picture.f.motion_val[0][mot_index][0]; |
|
616 |
- prev_y = s->current_picture.f.motion_val[0][mot_index][1]; |
|
617 |
- prev_ref = s->current_picture.f.ref_index[0][4 * mb_xy]; |
|
615 |
+ prev_x = s->cur_pic->f.motion_val[0][mot_index][0]; |
|
616 |
+ prev_y = s->cur_pic->f.motion_val[0][mot_index][1]; |
|
617 |
+ prev_ref = s->cur_pic->f.ref_index[0][4 * mb_xy]; |
|
618 | 618 |
} |
619 | 619 |
|
620 | 620 |
/* last MV */ |
... | ... |
@@ -624,54 +570,47 @@ skip_mean_and_median: |
624 | 624 |
pred_count++; |
625 | 625 |
|
626 | 626 |
skip_last_mv: |
627 |
- s->mv_dir = MV_DIR_FORWARD; |
|
628 |
- s->mb_intra = 0; |
|
629 |
- s->mv_type = MV_TYPE_16X16; |
|
630 |
- s->mb_skipped = 0; |
|
631 |
- |
|
632 |
- s->dsp.clear_blocks(s->block[0]); |
|
633 |
- |
|
634 |
- s->mb_x = mb_x; |
|
635 |
- s->mb_y = mb_y; |
|
636 | 627 |
|
637 | 628 |
for (j = 0; j < pred_count; j++) { |
629 |
+ int *linesize = s->cur_pic->f.linesize; |
|
638 | 630 |
int score = 0; |
639 |
- uint8_t *src = s->current_picture.f.data[0] + |
|
640 |
- mb_x * 16 + mb_y * 16 * s->linesize; |
|
631 |
+ uint8_t *src = s->cur_pic->f.data[0] + |
|
632 |
+ mb_x * 16 + mb_y * 16 * linesize[0]; |
|
641 | 633 |
|
642 |
- s->current_picture.f.motion_val[0][mot_index][0] = |
|
634 |
+ s->cur_pic->f.motion_val[0][mot_index][0] = |
|
643 | 635 |
s->mv[0][0][0] = mv_predictor[j][0]; |
644 |
- s->current_picture.f.motion_val[0][mot_index][1] = |
|
636 |
+ s->cur_pic->f.motion_val[0][mot_index][1] = |
|
645 | 637 |
s->mv[0][0][1] = mv_predictor[j][1]; |
646 | 638 |
|
647 | 639 |
// predictor intra or otherwise not available |
648 | 640 |
if (ref[j] < 0) |
649 | 641 |
continue; |
650 | 642 |
|
651 |
- decode_mb(s, ref[j]); |
|
643 |
+ s->decode_mb(s->opaque, ref[j], MV_DIR_FORWARD, |
|
644 |
+ MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); |
|
652 | 645 |
|
653 | 646 |
if (mb_x > 0 && fixed[mb_xy - 1]) { |
654 | 647 |
int k; |
655 | 648 |
for (k = 0; k < 16; k++) |
656 |
- score += FFABS(src[k * s->linesize - 1] - |
|
657 |
- src[k * s->linesize]); |
|
649 |
+ score += FFABS(src[k * linesize[0] - 1] - |
|
650 |
+ src[k * linesize[0]]); |
|
658 | 651 |
} |
659 | 652 |
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { |
660 | 653 |
int k; |
661 | 654 |
for (k = 0; k < 16; k++) |
662 |
- score += FFABS(src[k * s->linesize + 15] - |
|
663 |
- src[k * s->linesize + 16]); |
|
655 |
+ score += FFABS(src[k * linesize[0] + 15] - |
|
656 |
+ src[k * linesize[0] + 16]); |
|
664 | 657 |
} |
665 | 658 |
if (mb_y > 0 && fixed[mb_xy - mb_stride]) { |
666 | 659 |
int k; |
667 | 660 |
for (k = 0; k < 16; k++) |
668 |
- score += FFABS(src[k - s->linesize] - src[k]); |
|
661 |
+ score += FFABS(src[k - linesize[0]] - src[k]); |
|
669 | 662 |
} |
670 | 663 |
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) { |
671 | 664 |
int k; |
672 | 665 |
for (k = 0; k < 16; k++) |
673 |
- score += FFABS(src[k + s->linesize * 15] - |
|
674 |
- src[k + s->linesize * 16]); |
|
666 |
+ score += FFABS(src[k + linesize[0] * 15] - |
|
667 |
+ src[k + linesize[0] * 16]); |
|
675 | 668 |
} |
676 | 669 |
|
677 | 670 |
if (score <= best_score) { // <= will favor the last MV |
... | ... |
@@ -685,11 +624,12 @@ skip_last_mv: |
685 | 685 |
|
686 | 686 |
for (i = 0; i < mot_step; i++) |
687 | 687 |
for (j = 0; j < mot_step; j++) { |
688 |
- s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; |
|
689 |
- s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; |
|
688 |
+ s->cur_pic->f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; |
|
689 |
+ s->cur_pic->f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; |
|
690 | 690 |
} |
691 | 691 |
|
692 |
- decode_mb(s, ref[best_pred]); |
|
692 |
+ s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD, |
|
693 |
+ MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); |
|
693 | 694 |
|
694 | 695 |
|
695 | 696 |
if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) { |
... | ... |
@@ -712,11 +652,11 @@ skip_last_mv: |
712 | 712 |
} |
713 | 713 |
} |
714 | 714 |
|
715 |
-static int is_intra_more_likely(MpegEncContext *s) |
|
715 |
+static int is_intra_more_likely(ERContext *s) |
|
716 | 716 |
{ |
717 | 717 |
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y; |
718 | 718 |
|
719 |
- if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) |
|
719 |
+ if (!s->last_pic || !s->last_pic->f.data[0]) |
|
720 | 720 |
return 1; // no previous frame available -> use spatial prediction |
721 | 721 |
|
722 | 722 |
undamaged_count = 0; |
... | ... |
@@ -727,12 +667,8 @@ static int is_intra_more_likely(MpegEncContext *s) |
727 | 727 |
undamaged_count++; |
728 | 728 |
} |
729 | 729 |
|
730 |
- if (s->codec_id == AV_CODEC_ID_H264) { |
|
731 |
- H264Context *h = (void*) s; |
|
732 |
- if (h->list_count <= 0 || h->ref_count[0] <= 0 || |
|
733 |
- !h->ref_list[0][0].f.data[0]) |
|
734 |
- return 1; |
|
735 |
- } |
|
730 |
+ if (s->avctx->codec_id == AV_CODEC_ID_H264 && s->ref_count <= 0) |
|
731 |
+ return 1; |
|
736 | 732 |
|
737 | 733 |
if (undamaged_count < 5) |
738 | 734 |
return 0; // almost all MBs damaged -> use temporal prediction |
... | ... |
@@ -740,7 +676,7 @@ static int is_intra_more_likely(MpegEncContext *s) |
740 | 740 |
// prevent dsp.sad() check, that requires access to the image |
741 | 741 |
if (CONFIG_MPEG_XVMC_DECODER && |
742 | 742 |
s->avctx->xvmc_acceleration && |
743 |
- s->pict_type == AV_PICTURE_TYPE_I) |
|
743 |
+ s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I) |
|
744 | 744 |
return 1; |
745 | 745 |
|
746 | 746 |
skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs |
... | ... |
@@ -761,25 +697,25 @@ static int is_intra_more_likely(MpegEncContext *s) |
761 | 761 |
if ((j % skip_amount) != 0) |
762 | 762 |
continue; |
763 | 763 |
|
764 |
- if (s->pict_type == AV_PICTURE_TYPE_I) { |
|
765 |
- uint8_t *mb_ptr = s->current_picture.f.data[0] + |
|
766 |
- mb_x * 16 + mb_y * 16 * s->linesize; |
|
767 |
- uint8_t *last_mb_ptr = s->last_picture.f.data[0] + |
|
768 |
- mb_x * 16 + mb_y * 16 * s->linesize; |
|
764 |
+ if (s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I) { |
|
765 |
+ int *linesize = s->cur_pic->f.linesize; |
|
766 |
+ uint8_t *mb_ptr = s->cur_pic->f.data[0] + |
|
767 |
+ mb_x * 16 + mb_y * 16 * linesize[0]; |
|
768 |
+ uint8_t *last_mb_ptr = s->last_pic->f.data[0] + |
|
769 |
+ mb_x * 16 + mb_y * 16 * linesize[0]; |
|
769 | 770 |
|
770 | 771 |
if (s->avctx->codec_id == AV_CODEC_ID_H264) { |
771 | 772 |
// FIXME |
772 | 773 |
} else { |
773 |
- ff_thread_await_progress(&s->last_picture_ptr->f, |
|
774 |
- mb_y, 0); |
|
774 |
+ ff_thread_await_progress(&s->last_pic->f, mb_y, 0); |
|
775 | 775 |
} |
776 |
- is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr, |
|
777 |
- s->linesize, 16); |
|
778 |
- is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, |
|
779 |
- last_mb_ptr + s->linesize * 16, |
|
780 |
- s->linesize, 16); |
|
776 |
+ is_intra_likely += s->dsp->sad[0](NULL, last_mb_ptr, mb_ptr, |
|
777 |
+ linesize[0], 16); |
|
778 |
+ is_intra_likely -= s->dsp->sad[0](NULL, last_mb_ptr, |
|
779 |
+ last_mb_ptr + linesize[0] * 16, |
|
780 |
+ linesize[0], 16); |
|
781 | 781 |
} else { |
782 |
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) |
|
782 |
+ if (IS_INTRA(s->cur_pic->f.mb_type[mb_xy])) |
|
783 | 783 |
is_intra_likely++; |
784 | 784 |
else |
785 | 785 |
is_intra_likely--; |
... | ... |
@@ -789,9 +725,9 @@ static int is_intra_more_likely(MpegEncContext *s) |
789 | 789 |
return is_intra_likely > 0; |
790 | 790 |
} |
791 | 791 |
|
792 |
-void ff_er_frame_start(MpegEncContext *s) |
|
792 |
+void ff_er_frame_start(ERContext *s) |
|
793 | 793 |
{ |
794 |
- if (!s->err_recognition) |
|
794 |
+ if (!s->avctx->err_recognition) |
|
795 | 795 |
return; |
796 | 796 |
|
797 | 797 |
memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END, |
... | ... |
@@ -807,7 +743,7 @@ void ff_er_frame_start(MpegEncContext *s) |
807 | 807 |
* @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...), it is |
808 | 808 |
* assumed that no earlier end or error of the same type occurred |
809 | 809 |
*/ |
810 |
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty, |
|
810 |
+void ff_er_add_slice(ERContext *s, int startx, int starty, |
|
811 | 811 |
int endx, int endy, int status) |
812 | 812 |
{ |
813 | 813 |
const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1); |
... | ... |
@@ -825,7 +761,7 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, |
825 | 825 |
return; |
826 | 826 |
} |
827 | 827 |
|
828 |
- if (!s->err_recognition) |
|
828 |
+ if (!s->avctx->err_recognition) |
|
829 | 829 |
return; |
830 | 830 |
|
831 | 831 |
mask &= ~VP_START; |
... | ... |
@@ -875,37 +811,36 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, |
875 | 875 |
} |
876 | 876 |
} |
877 | 877 |
|
878 |
-void ff_er_frame_end(MpegEncContext *s) |
|
878 |
+void ff_er_frame_end(ERContext *s) |
|
879 | 879 |
{ |
880 |
+ int *linesize = s->cur_pic->f.linesize; |
|
880 | 881 |
int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error; |
881 | 882 |
int distance; |
882 | 883 |
int threshold_part[4] = { 100, 100, 100 }; |
883 | 884 |
int threshold = 50; |
884 | 885 |
int is_intra_likely; |
885 | 886 |
int size = s->b8_stride * 2 * s->mb_height; |
886 |
- Picture *pic = s->current_picture_ptr; |
|
887 | 887 |
|
888 | 888 |
/* We do not support ER of field pictures yet, |
889 | 889 |
* though it should not crash if enabled. */ |
890 |
- if (!s->err_recognition || s->error_count == 0 || |
|
890 |
+ if (!s->avctx->err_recognition || s->error_count == 0 || |
|
891 | 891 |
s->avctx->hwaccel || |
892 | 892 |
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || |
893 |
- s->picture_structure != PICT_FRAME || |
|
893 |
+ !s->cur_pic || s->cur_pic->field_picture || |
|
894 | 894 |
s->error_count == 3 * s->mb_width * |
895 | 895 |
(s->avctx->skip_top + s->avctx->skip_bottom)) { |
896 | 896 |
return; |
897 | 897 |
}; |
898 | 898 |
|
899 |
- if (s->current_picture.f.motion_val[0] == NULL) { |
|
899 |
+ if (s->cur_pic->f.motion_val[0] == NULL) { |
|
900 | 900 |
av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); |
901 | 901 |
|
902 | 902 |
for (i = 0; i < 2; i++) { |
903 |
- pic->f.ref_index[i] = av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t)); |
|
904 |
- pic->motion_val_base[i] = av_mallocz((size + 4) * 2 * sizeof(uint16_t)); |
|
905 |
- pic->f.motion_val[i] = pic->motion_val_base[i] + 4; |
|
903 |
+ s->cur_pic->f.ref_index[i] = av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t)); |
|
904 |
+ s->cur_pic->motion_val_base[i] = av_mallocz((size + 4) * 2 * sizeof(uint16_t)); |
|
905 |
+ s->cur_pic->f.motion_val[i] = s->cur_pic->motion_val_base[i] + 4; |
|
906 | 906 |
} |
907 |
- pic->f.motion_subsample_log2 = 3; |
|
908 |
- s->current_picture = *s->current_picture_ptr; |
|
907 |
+ s->cur_pic->f.motion_subsample_log2 = 3; |
|
909 | 908 |
} |
910 | 909 |
|
911 | 910 |
if (s->avctx->debug & FF_DEBUG_ER) { |
... | ... |
@@ -964,7 +899,7 @@ void ff_er_frame_end(MpegEncContext *s) |
964 | 964 |
} |
965 | 965 |
|
966 | 966 |
/* handle missing slices */ |
967 |
- if (s->err_recognition & AV_EF_EXPLODE) { |
|
967 |
+ if (s->avctx->err_recognition & AV_EF_EXPLODE) { |
|
968 | 968 |
int end_ok = 1; |
969 | 969 |
|
970 | 970 |
// FIXME + 100 hack |
... | ... |
@@ -1063,30 +998,28 @@ void ff_er_frame_end(MpegEncContext *s) |
1063 | 1063 |
continue; |
1064 | 1064 |
|
1065 | 1065 |
if (is_intra_likely) |
1066 |
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; |
|
1066 |
+ s->cur_pic->f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; |
|
1067 | 1067 |
else |
1068 |
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0; |
|
1068 |
+ s->cur_pic->f.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0; |
|
1069 | 1069 |
} |
1070 | 1070 |
|
1071 | 1071 |
// change inter to intra blocks if no reference frames are available |
1072 |
- if (!s->last_picture.f.data[0] && !s->next_picture.f.data[0]) |
|
1072 |
+ if (!(s->last_pic && s->last_pic->f.data[0]) && |
|
1073 |
+ !(s->next_pic && s->next_pic->f.data[0])) |
|
1073 | 1074 |
for (i = 0; i < s->mb_num; i++) { |
1074 | 1075 |
const int mb_xy = s->mb_index2xy[i]; |
1075 |
- if (!IS_INTRA(s->current_picture.f.mb_type[mb_xy])) |
|
1076 |
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; |
|
1076 |
+ if (!IS_INTRA(s->cur_pic->f.mb_type[mb_xy])) |
|
1077 |
+ s->cur_pic->f.mb_type[mb_xy] = MB_TYPE_INTRA4x4; |
|
1077 | 1078 |
} |
1078 | 1079 |
|
1079 | 1080 |
/* handle inter blocks with damaged AC */ |
1080 | 1081 |
for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
1081 |
- s->mb_x = 0; |
|
1082 |
- s->mb_y = mb_y; |
|
1083 |
- ff_init_block_index(s); |
|
1084 | 1082 |
for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
1085 | 1083 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
1086 |
- const int mb_type = s->current_picture.f.mb_type[mb_xy]; |
|
1087 |
- int dir = !s->last_picture.f.data[0]; |
|
1088 |
- |
|
1089 |
- ff_update_block_index(s); |
|
1084 |
+ const int mb_type = s->cur_pic->f.mb_type[mb_xy]; |
|
1085 |
+ const int dir = !(s->last_pic && s->last_pic->f.data[0]); |
|
1086 |
+ const int mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD; |
|
1087 |
+ int mv_type; |
|
1090 | 1088 |
|
1091 | 1089 |
error = s->error_status_table[mb_xy]; |
1092 | 1090 |
|
... | ... |
@@ -1097,43 +1030,33 @@ void ff_er_frame_end(MpegEncContext *s) |
1097 | 1097 |
if (!(error & ER_AC_ERROR)) |
1098 | 1098 |
continue; // undamaged inter |
1099 | 1099 |
|
1100 |
- s->mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD; |
|
1101 |
- s->mb_intra = 0; |
|
1102 |
- s->mb_skipped = 0; |
|
1103 | 1100 |
if (IS_8X8(mb_type)) { |
1104 | 1101 |
int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride; |
1105 | 1102 |
int j; |
1106 |
- s->mv_type = MV_TYPE_8X8; |
|
1103 |
+ mv_type = MV_TYPE_8X8; |
|
1107 | 1104 |
for (j = 0; j < 4; j++) { |
1108 |
- s->mv[0][j][0] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0]; |
|
1109 |
- s->mv[0][j][1] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1]; |
|
1105 |
+ s->mv[0][j][0] = s->cur_pic->f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0]; |
|
1106 |
+ s->mv[0][j][1] = s->cur_pic->f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1]; |
|
1110 | 1107 |
} |
1111 | 1108 |
} else { |
1112 |
- s->mv_type = MV_TYPE_16X16; |
|
1113 |
- s->mv[0][0][0] = s->current_picture.f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0]; |
|
1114 |
- s->mv[0][0][1] = s->current_picture.f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1]; |
|
1109 |
+ mv_type = MV_TYPE_16X16; |
|
1110 |
+ s->mv[0][0][0] = s->cur_pic->f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0]; |
|
1111 |
+ s->mv[0][0][1] = s->cur_pic->f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1]; |
|
1115 | 1112 |
} |
1116 | 1113 |
|
1117 |
- s->dsp.clear_blocks(s->block[0]); |
|
1118 |
- |
|
1119 |
- s->mb_x = mb_x; |
|
1120 |
- s->mb_y = mb_y; |
|
1121 |
- decode_mb(s, 0 /* FIXME h264 partitioned slices need this set */); |
|
1114 |
+ s->decode_mb(s->opaque, 0 /* FIXME h264 partitioned slices need this set */, |
|
1115 |
+ mv_dir, mv_type, &s->mv, mb_x, mb_y, 0, 0); |
|
1122 | 1116 |
} |
1123 | 1117 |
} |
1124 | 1118 |
|
1125 | 1119 |
/* guess MVs */ |
1126 |
- if (s->pict_type == AV_PICTURE_TYPE_B) { |
|
1120 |
+ if (s->cur_pic->f.pict_type == AV_PICTURE_TYPE_B) { |
|
1127 | 1121 |
for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
1128 |
- s->mb_x = 0; |
|
1129 |
- s->mb_y = mb_y; |
|
1130 |
- ff_init_block_index(s); |
|
1131 | 1122 |
for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
1132 | 1123 |
int xy = mb_x * 2 + mb_y * 2 * s->b8_stride; |
1133 | 1124 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
1134 |
- const int mb_type = s->current_picture.f.mb_type[mb_xy]; |
|
1135 |
- |
|
1136 |
- ff_update_block_index(s); |
|
1125 |
+ const int mb_type = s->cur_pic->f.mb_type[mb_xy]; |
|
1126 |
+ int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; |
|
1137 | 1127 |
|
1138 | 1128 |
error = s->error_status_table[mb_xy]; |
1139 | 1129 |
|
... | ... |
@@ -1144,24 +1067,21 @@ void ff_er_frame_end(MpegEncContext *s) |
1144 | 1144 |
if (!(error & ER_AC_ERROR)) |
1145 | 1145 |
continue; // undamaged inter |
1146 | 1146 |
|
1147 |
- s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; |
|
1148 |
- if (!s->last_picture.f.data[0]) |
|
1149 |
- s->mv_dir &= ~MV_DIR_FORWARD; |
|
1150 |
- if (!s->next_picture.f.data[0]) |
|
1151 |
- s->mv_dir &= ~MV_DIR_BACKWARD; |
|
1152 |
- s->mb_intra = 0; |
|
1153 |
- s->mv_type = MV_TYPE_16X16; |
|
1154 |
- s->mb_skipped = 0; |
|
1147 |
+ if (!(s->last_pic && s->last_pic->f.data[0])) |
|
1148 |
+ mv_dir &= ~MV_DIR_FORWARD; |
|
1149 |
+ if (!(s->next_pic && s->next_pic->f.data[0])) |
|
1150 |
+ mv_dir &= ~MV_DIR_BACKWARD; |
|
1155 | 1151 |
|
1156 | 1152 |
if (s->pp_time) { |
1157 | 1153 |
int time_pp = s->pp_time; |
1158 | 1154 |
int time_pb = s->pb_time; |
1159 | 1155 |
|
1160 |
- ff_thread_await_progress(&s->next_picture_ptr->f, mb_y, 0); |
|
1161 |
- s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] * time_pb / time_pp; |
|
1162 |
- s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] * time_pb / time_pp; |
|
1163 |
- s->mv[1][0][0] = s->next_picture.f.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp; |
|
1164 |
- s->mv[1][0][1] = s->next_picture.f.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp; |
|
1156 |
+ ff_thread_await_progress(&s->next_pic->f, mb_y, 0); |
|
1157 |
+ |
|
1158 |
+ s->mv[0][0][0] = s->next_pic->f.motion_val[0][xy][0] * time_pb / time_pp; |
|
1159 |
+ s->mv[0][0][1] = s->next_pic->f.motion_val[0][xy][1] * time_pb / time_pp; |
|
1160 |
+ s->mv[1][0][0] = s->next_pic->f.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp; |
|
1161 |
+ s->mv[1][0][1] = s->next_pic->f.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp; |
|
1165 | 1162 |
} else { |
1166 | 1163 |
s->mv[0][0][0] = 0; |
1167 | 1164 |
s->mv[0][0][1] = 0; |
... | ... |
@@ -1169,10 +1089,8 @@ void ff_er_frame_end(MpegEncContext *s) |
1169 | 1169 |
s->mv[1][0][1] = 0; |
1170 | 1170 |
} |
1171 | 1171 |
|
1172 |
- s->dsp.clear_blocks(s->block[0]); |
|
1173 |
- s->mb_x = mb_x; |
|
1174 |
- s->mb_y = mb_y; |
|
1175 |
- decode_mb(s, 0); |
|
1172 |
+ s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv, |
|
1173 |
+ mb_x, mb_y, 0, 0); |
|
1176 | 1174 |
} |
1177 | 1175 |
} |
1178 | 1176 |
} else |
... | ... |
@@ -1188,7 +1106,7 @@ void ff_er_frame_end(MpegEncContext *s) |
1188 | 1188 |
int16_t *dc_ptr; |
1189 | 1189 |
uint8_t *dest_y, *dest_cb, *dest_cr; |
1190 | 1190 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
1191 |
- const int mb_type = s->current_picture.f.mb_type[mb_xy]; |
|
1191 |
+ const int mb_type = s->cur_pic->f.mb_type[mb_xy]; |
|
1192 | 1192 |
|
1193 | 1193 |
error = s->error_status_table[mb_xy]; |
1194 | 1194 |
|
... | ... |
@@ -1197,9 +1115,9 @@ void ff_er_frame_end(MpegEncContext *s) |
1197 | 1197 |
// if (error & ER_MV_ERROR) |
1198 | 1198 |
// continue; // inter data damaged FIXME is this good? |
1199 | 1199 |
|
1200 |
- dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize; |
|
1201 |
- dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize; |
|
1202 |
- dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize; |
|
1200 |
+ dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0]; |
|
1201 |
+ dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1]; |
|
1202 |
+ dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2]; |
|
1203 | 1203 |
|
1204 | 1204 |
dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride]; |
1205 | 1205 |
for (n = 0; n < 4; n++) { |
... | ... |
@@ -1208,7 +1126,7 @@ void ff_er_frame_end(MpegEncContext *s) |
1208 | 1208 |
int x; |
1209 | 1209 |
for (x = 0; x < 8; x++) |
1210 | 1210 |
dc += dest_y[x + (n & 1) * 8 + |
1211 |
- (y + (n >> 1) * 8) * s->linesize]; |
|
1211 |
+ (y + (n >> 1) * 8) * linesize[0]]; |
|
1212 | 1212 |
} |
1213 | 1213 |
dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3; |
1214 | 1214 |
} |
... | ... |
@@ -1217,8 +1135,8 @@ void ff_er_frame_end(MpegEncContext *s) |
1217 | 1217 |
for (y = 0; y < 8; y++) { |
1218 | 1218 |
int x; |
1219 | 1219 |
for (x = 0; x < 8; x++) { |
1220 |
- dcu += dest_cb[x + y * s->uvlinesize]; |
|
1221 |
- dcv += dest_cr[x + y * s->uvlinesize]; |
|
1220 |
+ dcu += dest_cb[x + y * linesize[1]]; |
|
1221 |
+ dcv += dest_cr[x + y * linesize[2]]; |
|
1222 | 1222 |
} |
1223 | 1223 |
} |
1224 | 1224 |
s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3; |
... | ... |
@@ -1239,7 +1157,7 @@ void ff_er_frame_end(MpegEncContext *s) |
1239 | 1239 |
for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
1240 | 1240 |
uint8_t *dest_y, *dest_cb, *dest_cr; |
1241 | 1241 |
const int mb_xy = mb_x + mb_y * s->mb_stride; |
1242 |
- const int mb_type = s->current_picture.f.mb_type[mb_xy]; |
|
1242 |
+ const int mb_type = s->cur_pic->f.mb_type[mb_xy]; |
|
1243 | 1243 |
|
1244 | 1244 |
error = s->error_status_table[mb_xy]; |
1245 | 1245 |
|
... | ... |
@@ -1248,9 +1166,9 @@ void ff_er_frame_end(MpegEncContext *s) |
1248 | 1248 |
if (!(error & ER_AC_ERROR)) |
1249 | 1249 |
continue; // undamaged |
1250 | 1250 |
|
1251 |
- dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize; |
|
1252 |
- dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize; |
|
1253 |
- dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize; |
|
1251 |
+ dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0]; |
|
1252 |
+ dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1]; |
|
1253 |
+ dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2]; |
|
1254 | 1254 |
|
1255 | 1255 |
put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y); |
1256 | 1256 |
} |
... | ... |
@@ -1258,20 +1176,20 @@ void ff_er_frame_end(MpegEncContext *s) |
1258 | 1258 |
|
1259 | 1259 |
if (s->avctx->error_concealment & FF_EC_DEBLOCK) { |
1260 | 1260 |
/* filter horizontal block boundaries */ |
1261 |
- h_block_filter(s, s->current_picture.f.data[0], s->mb_width * 2, |
|
1262 |
- s->mb_height * 2, s->linesize, 1); |
|
1263 |
- h_block_filter(s, s->current_picture.f.data[1], s->mb_width, |
|
1264 |
- s->mb_height , s->uvlinesize, 0); |
|
1265 |
- h_block_filter(s, s->current_picture.f.data[2], s->mb_width, |
|
1266 |
- s->mb_height , s->uvlinesize, 0); |
|
1261 |
+ h_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2, |
|
1262 |
+ s->mb_height * 2, linesize[0], 1); |
|
1263 |
+ h_block_filter(s, s->cur_pic->f.data[1], s->mb_width, |
|
1264 |
+ s->mb_height, linesize[1], 0); |
|
1265 |
+ h_block_filter(s, s->cur_pic->f.data[2], s->mb_width, |
|
1266 |
+ s->mb_height, linesize[2], 0); |
|
1267 | 1267 |
|
1268 | 1268 |
/* filter vertical block boundaries */ |
1269 |
- v_block_filter(s, s->current_picture.f.data[0], s->mb_width * 2, |
|
1270 |
- s->mb_height * 2, s->linesize, 1); |
|
1271 |
- v_block_filter(s, s->current_picture.f.data[1], s->mb_width, |
|
1272 |
- s->mb_height , s->uvlinesize, 0); |
|
1273 |
- v_block_filter(s, s->current_picture.f.data[2], s->mb_width, |
|
1274 |
- s->mb_height , s->uvlinesize, 0); |
|
1269 |
+ v_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2, |
|
1270 |
+ s->mb_height * 2, linesize[0], 1); |
|
1271 |
+ v_block_filter(s, s->cur_pic->f.data[1], s->mb_width, |
|
1272 |
+ s->mb_height, linesize[1], 0); |
|
1273 |
+ v_block_filter(s, s->cur_pic->f.data[2], s->mb_width, |
|
1274 |
+ s->mb_height, linesize[2], 0); |
|
1275 | 1275 |
} |
1276 | 1276 |
|
1277 | 1277 |
ec_clean: |
... | ... |
@@ -1280,10 +1198,13 @@ ec_clean: |
1280 | 1280 |
const int mb_xy = s->mb_index2xy[i]; |
1281 | 1281 |
int error = s->error_status_table[mb_xy]; |
1282 | 1282 |
|
1283 |
- if (s->pict_type != AV_PICTURE_TYPE_B && |
|
1283 |
+ if (s->cur_pic->f.pict_type != AV_PICTURE_TYPE_B && |
|
1284 | 1284 |
(error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) { |
1285 | 1285 |
s->mbskip_table[mb_xy] = 0; |
1286 | 1286 |
} |
1287 | 1287 |
s->mbintra_table[mb_xy] = 1; |
1288 | 1288 |
} |
1289 |
+ s->cur_pic = NULL; |
|
1290 |
+ s->next_pic = NULL; |
|
1291 |
+ s->last_pic = NULL; |
|
1289 | 1292 |
} |
1290 | 1293 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,74 @@ |
0 |
+/* |
|
1 |
+ * |
|
2 |
+ * This file is part of Libav. |
|
3 |
+ * |
|
4 |
+ * Libav is free software; you can redistribute it and/or |
|
5 |
+ * modify it under the terms of the GNU Lesser General Public |
|
6 |
+ * License as published by the Free Software Foundation; either |
|
7 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
8 |
+ * |
|
9 |
+ * Libav is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 |
+ * Lesser General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU Lesser General Public |
|
15 |
+ * License along with Libav; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 |
+ */ |
|
18 |
+ |
|
19 |
+#ifndef AVCODEC_ERROR_RESILIENCE_H |
|
20 |
+#define AVCODEC_ERROR_RESILIENCE_H |
|
21 |
+ |
|
22 |
+///< current MB is the first after a resync marker |
|
23 |
+#define VP_START 1 |
|
24 |
+#define ER_AC_ERROR 2 |
|
25 |
+#define ER_DC_ERROR 4 |
|
26 |
+#define ER_MV_ERROR 8 |
|
27 |
+#define ER_AC_END 16 |
|
28 |
+#define ER_DC_END 32 |
|
29 |
+#define ER_MV_END 64 |
|
30 |
+ |
|
31 |
+#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR) |
|
32 |
+#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END) |
|
33 |
+ |
|
34 |
+typedef struct ERContext { |
|
35 |
+ AVCodecContext *avctx; |
|
36 |
+ DSPContext *dsp; |
|
37 |
+ |
|
38 |
+ int *mb_index2xy; |
|
39 |
+ int mb_num; |
|
40 |
+ int mb_width, mb_height; |
|
41 |
+ int mb_stride; |
|
42 |
+ int b8_stride; |
|
43 |
+ |
|
44 |
+ int error_count, error_occurred; |
|
45 |
+ uint8_t *error_status_table; |
|
46 |
+ uint8_t *er_temp_buffer; |
|
47 |
+ int16_t *dc_val[3]; |
|
48 |
+ uint8_t *mbskip_table; |
|
49 |
+ uint8_t *mbintra_table; |
|
50 |
+ int mv[2][4][2]; |
|
51 |
+ |
|
52 |
+ struct Picture *cur_pic; |
|
53 |
+ struct Picture *last_pic; |
|
54 |
+ struct Picture *next_pic; |
|
55 |
+ |
|
56 |
+ uint16_t pp_time; |
|
57 |
+ uint16_t pb_time; |
|
58 |
+ int quarter_sample; |
|
59 |
+ int partitioned_frame; |
|
60 |
+ int ref_count; |
|
61 |
+ |
|
62 |
+ void (*decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, |
|
63 |
+ int (*mv)[2][4][2], |
|
64 |
+ int mb_x, int mb_y, int mb_intra, int mb_skipped); |
|
65 |
+ void *opaque; |
|
66 |
+} ERContext; |
|
67 |
+ |
|
68 |
+void ff_er_frame_start(ERContext *s); |
|
69 |
+void ff_er_frame_end(ERContext *s); |
|
70 |
+void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, |
|
71 |
+ int status); |
|
72 |
+ |
|
73 |
+#endif /* AVCODEC_ERROR_RESILIENCE_H */ |
... | ... |
@@ -188,7 +188,7 @@ static int decode_slice(MpegEncContext *s){ |
188 | 188 |
/* per-row end of slice checks */ |
189 | 189 |
if(s->msmpeg4_version){ |
190 | 190 |
if(s->resync_mb_y + s->slice_height == s->mb_y){ |
191 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
191 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
192 | 192 |
|
193 | 193 |
return 0; |
194 | 194 |
} |
... | ... |
@@ -229,7 +229,7 @@ static int decode_slice(MpegEncContext *s){ |
229 | 229 |
if(s->loop_filter) |
230 | 230 |
ff_h263_loop_filter(s); |
231 | 231 |
|
232 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask); |
|
232 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask); |
|
233 | 233 |
|
234 | 234 |
s->padding_bug_score--; |
235 | 235 |
|
... | ... |
@@ -242,11 +242,11 @@ static int decode_slice(MpegEncContext *s){ |
242 | 242 |
return 0; |
243 | 243 |
}else if(ret==SLICE_NOEND){ |
244 | 244 |
av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy); |
245 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, ER_MB_END&part_mask); |
|
245 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, ER_MB_END&part_mask); |
|
246 | 246 |
return -1; |
247 | 247 |
} |
248 | 248 |
av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy); |
249 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask); |
|
249 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask); |
|
250 | 250 |
|
251 | 251 |
return -1; |
252 | 252 |
} |
... | ... |
@@ -325,7 +325,7 @@ static int decode_slice(MpegEncContext *s){ |
325 | 325 |
else if(left<0){ |
326 | 326 |
av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left); |
327 | 327 |
}else |
328 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
328 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
329 | 329 |
|
330 | 330 |
return 0; |
331 | 331 |
} |
... | ... |
@@ -334,7 +334,7 @@ static int decode_slice(MpegEncContext *s){ |
334 | 334 |
get_bits_left(&s->gb), |
335 | 335 |
show_bits(&s->gb, 24), s->padding_bug_score); |
336 | 336 |
|
337 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask); |
|
337 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask); |
|
338 | 338 |
|
339 | 339 |
return -1; |
340 | 340 |
} |
... | ... |
@@ -638,7 +638,7 @@ retry: |
638 | 638 |
return -1; |
639 | 639 |
} |
640 | 640 |
|
641 |
- ff_er_frame_start(s); |
|
641 |
+ ff_mpeg_er_frame_start(s); |
|
642 | 642 |
|
643 | 643 |
//the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type |
644 | 644 |
//which is not available before ff_MPV_frame_start() |
... | ... |
@@ -662,7 +662,7 @@ retry: |
662 | 662 |
if(ff_h263_resync(s)<0) |
663 | 663 |
break; |
664 | 664 |
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x) |
665 |
- s->error_occurred = 1; |
|
665 |
+ s->er.error_occurred = 1; |
|
666 | 666 |
} |
667 | 667 |
|
668 | 668 |
if(s->msmpeg4_version<4 && s->h263_pred) |
... | ... |
@@ -673,7 +673,7 @@ retry: |
673 | 673 |
|
674 | 674 |
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I) |
675 | 675 |
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){ |
676 |
- s->error_status_table[s->mb_num-1]= ER_MB_ERROR; |
|
676 |
+ s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; |
|
677 | 677 |
} |
678 | 678 |
|
679 | 679 |
assert(s->bitstream_buffer_size==0); |
... | ... |
@@ -710,7 +710,7 @@ frame_end: |
710 | 710 |
} |
711 | 711 |
|
712 | 712 |
intrax8_decoded: |
713 |
- ff_er_frame_end(s); |
|
713 |
+ ff_er_frame_end(&s->er); |
|
714 | 714 |
|
715 | 715 |
if (avctx->hwaccel) { |
716 | 716 |
if (avctx->hwaccel->end_frame(avctx) < 0) |
... | ... |
@@ -78,6 +78,33 @@ static const enum AVPixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = { |
78 | 78 |
AV_PIX_FMT_NONE |
79 | 79 |
}; |
80 | 80 |
|
81 |
+static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, |
|
82 |
+ int (*mv)[2][4][2], |
|
83 |
+ int mb_x, int mb_y, int mb_intra, int mb_skipped) |
|
84 |
+{ |
|
85 |
+ H264Context *h = opaque; |
|
86 |
+ MpegEncContext *s = &h->s; |
|
87 |
+ |
|
88 |
+ s->mb_x = mb_x; |
|
89 |
+ s->mb_y = mb_y; |
|
90 |
+ h->mb_xy = s->mb_x + s->mb_y * s->mb_stride; |
|
91 |
+ memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache)); |
|
92 |
+ assert(ref >= 0); |
|
93 |
+ /* FIXME: It is possible albeit uncommon that slice references |
|
94 |
+ * differ between slices. We take the easy approach and ignore |
|
95 |
+ * it for now. If this turns out to have any relevance in |
|
96 |
+ * practice then correct remapping should be added. */ |
|
97 |
+ if (ref >= h->ref_count[0]) |
|
98 |
+ ref = 0; |
|
99 |
+ fill_rectangle(&s->current_picture.f.ref_index[0][4 * h->mb_xy], |
|
100 |
+ 2, 2, 2, ref, 1); |
|
101 |
+ fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); |
|
102 |
+ fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, |
|
103 |
+ pack16to32(s->mv[0][0][0], s->mv[0][0][1]), 4); |
|
104 |
+ assert(!FRAME_MBAFF); |
|
105 |
+ ff_h264_hl_decode_mb(h); |
|
106 |
+} |
|
107 |
+ |
|
81 | 108 |
/** |
82 | 109 |
* Check if the top & left blocks are available if needed and |
83 | 110 |
* change the dc mode so it only uses the available blocks. |
... | ... |
@@ -960,6 +987,9 @@ static int context_init(H264Context *h) |
960 | 960 |
h->ref_cache[1][scan8[7] + 1] = |
961 | 961 |
h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE; |
962 | 962 |
|
963 |
+ h->s.er.decode_mb = h264_er_decode_mb; |
|
964 |
+ h->s.er.opaque = h; |
|
965 |
+ |
|
963 | 966 |
return 0; |
964 | 967 |
|
965 | 968 |
fail: |
... | ... |
@@ -1299,7 +1329,7 @@ int ff_h264_frame_start(H264Context *h) |
1299 | 1299 |
|
1300 | 1300 |
if (ff_MPV_frame_start(s, s->avctx) < 0) |
1301 | 1301 |
return -1; |
1302 |
- ff_er_frame_start(s); |
|
1302 |
+ ff_mpeg_er_frame_start(s); |
|
1303 | 1303 |
/* |
1304 | 1304 |
* ff_MPV_frame_start uses pict_type to derive key_frame. |
1305 | 1305 |
* This is incorrect for H.264; IDR markings must be used. |
... | ... |
@@ -2340,7 +2370,7 @@ static int field_end(H264Context *h, int in_setup) |
2340 | 2340 |
* causes problems for the first MB line, too. |
2341 | 2341 |
*/ |
2342 | 2342 |
if (!FIELD_PICTURE) |
2343 |
- ff_er_frame_end(s); |
|
2343 |
+ ff_er_frame_end(&s->er); |
|
2344 | 2344 |
|
2345 | 2345 |
ff_MPV_frame_end(s); |
2346 | 2346 |
|
... | ... |
@@ -3068,11 +3098,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0) |
3068 | 3068 |
if (h->slice_type_nos != AV_PICTURE_TYPE_I) { |
3069 | 3069 |
s->last_picture_ptr = &h->ref_list[0][0]; |
3070 | 3070 |
s->last_picture_ptr->owner2 = s; |
3071 |
+ s->er.last_pic = s->last_picture_ptr; |
|
3071 | 3072 |
ff_copy_picture(&s->last_picture, s->last_picture_ptr); |
3072 | 3073 |
} |
3073 | 3074 |
if (h->slice_type_nos == AV_PICTURE_TYPE_B) { |
3074 | 3075 |
s->next_picture_ptr = &h->ref_list[1][0]; |
3075 | 3076 |
s->next_picture_ptr->owner2 = s; |
3077 |
+ s->er.next_pic = s->next_picture_ptr; |
|
3076 | 3078 |
ff_copy_picture(&s->next_picture, s->next_picture_ptr); |
3077 | 3079 |
} |
3078 | 3080 |
|
... | ... |
@@ -3639,6 +3671,15 @@ static void decode_finish_row(H264Context *h) |
3639 | 3639 |
s->picture_structure == PICT_BOTTOM_FIELD); |
3640 | 3640 |
} |
3641 | 3641 |
|
3642 |
+static void er_add_slice(H264Context *h, int startx, int starty, |
|
3643 |
+ int endx, int endy, int status) |
|
3644 |
+{ |
|
3645 |
+ ERContext *er = &h->s.er; |
|
3646 |
+ |
|
3647 |
+ er->ref_count = h->ref_count[0]; |
|
3648 |
+ ff_er_add_slice(er, startx, starty, endx, endy, status); |
|
3649 |
+} |
|
3650 |
+ |
|
3642 | 3651 |
static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3643 | 3652 |
{ |
3644 | 3653 |
H264Context *h = *(void **)arg; |
... | ... |
@@ -3686,7 +3727,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3686 | 3686 |
|
3687 | 3687 |
if ((s->workaround_bugs & FF_BUG_TRUNCATED) && |
3688 | 3688 |
h->cabac.bytestream > h->cabac.bytestream_end + 2) { |
3689 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1, |
|
3689 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1, |
|
3690 | 3690 |
s->mb_y, ER_MB_END); |
3691 | 3691 |
if (s->mb_x >= lf_x_start) |
3692 | 3692 |
loop_filter(h, lf_x_start, s->mb_x + 1); |
... | ... |
@@ -3697,7 +3738,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3697 | 3697 |
"error while decoding MB %d %d, bytestream (%td)\n", |
3698 | 3698 |
s->mb_x, s->mb_y, |
3699 | 3699 |
h->cabac.bytestream_end - h->cabac.bytestream); |
3700 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3700 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3701 | 3701 |
s->mb_y, ER_MB_ERROR); |
3702 | 3702 |
return -1; |
3703 | 3703 |
} |
... | ... |
@@ -3717,7 +3758,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3717 | 3717 |
if (eos || s->mb_y >= s->mb_height) { |
3718 | 3718 |
tprintf(s->avctx, "slice end %d %d\n", |
3719 | 3719 |
get_bits_count(&s->gb), s->gb.size_in_bits); |
3720 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1, |
|
3720 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1, |
|
3721 | 3721 |
s->mb_y, ER_MB_END); |
3722 | 3722 |
if (s->mb_x > lf_x_start) |
3723 | 3723 |
loop_filter(h, lf_x_start, s->mb_x); |
... | ... |
@@ -3744,7 +3785,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3744 | 3744 |
if (ret < 0) { |
3745 | 3745 |
av_log(h->s.avctx, AV_LOG_ERROR, |
3746 | 3746 |
"error while decoding MB %d %d\n", s->mb_x, s->mb_y); |
3747 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3747 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3748 | 3748 |
s->mb_y, ER_MB_ERROR); |
3749 | 3749 |
return -1; |
3750 | 3750 |
} |
... | ... |
@@ -3764,13 +3805,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3764 | 3764 |
get_bits_count(&s->gb), s->gb.size_in_bits); |
3765 | 3765 |
|
3766 | 3766 |
if (get_bits_left(&s->gb) == 0) { |
3767 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, |
|
3767 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, |
|
3768 | 3768 |
s->mb_x - 1, s->mb_y, |
3769 | 3769 |
ER_MB_END); |
3770 | 3770 |
|
3771 | 3771 |
return 0; |
3772 | 3772 |
} else { |
3773 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, |
|
3773 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, |
|
3774 | 3774 |
s->mb_x - 1, s->mb_y, |
3775 | 3775 |
ER_MB_END); |
3776 | 3776 |
|
... | ... |
@@ -3783,7 +3824,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3783 | 3783 |
tprintf(s->avctx, "slice end %d %d\n", |
3784 | 3784 |
get_bits_count(&s->gb), s->gb.size_in_bits); |
3785 | 3785 |
if (get_bits_left(&s->gb) == 0) { |
3786 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, |
|
3786 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, |
|
3787 | 3787 |
s->mb_x - 1, s->mb_y, |
3788 | 3788 |
ER_MB_END); |
3789 | 3789 |
if (s->mb_x > lf_x_start) |
... | ... |
@@ -3791,7 +3832,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) |
3791 | 3791 |
|
3792 | 3792 |
return 0; |
3793 | 3793 |
} else { |
3794 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3794 |
+ er_add_slice(h, s->resync_mb_x, s->resync_mb_y, s->mb_x, |
|
3795 | 3795 |
s->mb_y, ER_MB_ERROR); |
3796 | 3796 |
|
3797 | 3797 |
return -1; |
... | ... |
@@ -3823,7 +3864,7 @@ static int execute_decode_slices(H264Context *h, int context_count) |
3823 | 3823 |
for (i = 1; i < context_count; i++) { |
3824 | 3824 |
hx = h->thread_context[i]; |
3825 | 3825 |
hx->s.err_recognition = avctx->err_recognition; |
3826 |
- hx->s.error_count = 0; |
|
3826 |
+ hx->s.er.error_count = 0; |
|
3827 | 3827 |
} |
3828 | 3828 |
|
3829 | 3829 |
avctx->execute(avctx, decode_slice, h->thread_context, |
... | ... |
@@ -3836,7 +3877,7 @@ static int execute_decode_slices(H264Context *h, int context_count) |
3836 | 3836 |
s->droppable = hx->s.droppable; |
3837 | 3837 |
s->picture_structure = hx->s.picture_structure; |
3838 | 3838 |
for (i = 1; i < context_count; i++) |
3839 |
- h->s.error_count += h->thread_context[i]->s.error_count; |
|
3839 |
+ h->s.er.error_count += h->thread_context[i]->s.er.error_count; |
|
3840 | 3840 |
} |
3841 | 3841 |
|
3842 | 3842 |
return 0; |
... | ... |
@@ -784,7 +784,7 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of |
784 | 784 |
} |
785 | 785 |
|
786 | 786 |
error: |
787 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, |
|
787 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, |
|
788 | 788 |
(s->mb_x>>1)-1, (s->mb_y>>1)-1, |
789 | 789 |
ER_MB_END ); |
790 | 790 |
return 0; |
... | ... |
@@ -1565,7 +1565,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) |
1565 | 1565 |
if (ff_MPV_frame_start(s, avctx) < 0) |
1566 | 1566 |
return -1; |
1567 | 1567 |
|
1568 |
- ff_er_frame_start(s); |
|
1568 |
+ ff_mpeg_er_frame_start(s); |
|
1569 | 1569 |
|
1570 | 1570 |
/* first check if we must repeat the frame */ |
1571 | 1571 |
s->current_picture_ptr->f.repeat_pict = 0; |
... | ... |
@@ -1856,7 +1856,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) |
1856 | 1856 |
int mb_y = s->start_mb_y; |
1857 | 1857 |
const int field_pic = s->picture_structure != PICT_FRAME; |
1858 | 1858 |
|
1859 |
- s->error_count = (3 * (s->end_mb_y - s->start_mb_y) * s->mb_width) >> field_pic; |
|
1859 |
+ s->er.error_count = (3 * (s->end_mb_y - s->start_mb_y) * s->mb_width) >> field_pic; |
|
1860 | 1860 |
|
1861 | 1861 |
for (;;) { |
1862 | 1862 |
uint32_t start_code; |
... | ... |
@@ -1866,14 +1866,14 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) |
1866 | 1866 |
emms_c(); |
1867 | 1867 |
av_dlog(c, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n", |
1868 | 1868 |
ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, |
1869 |
- s->start_mb_y, s->end_mb_y, s->error_count); |
|
1869 |
+ s->start_mb_y, s->end_mb_y, s->er.error_count); |
|
1870 | 1870 |
if (ret < 0) { |
1871 | 1871 |
if (c->err_recognition & AV_EF_EXPLODE) |
1872 | 1872 |
return ret; |
1873 | 1873 |
if (s->resync_mb_x >= 0 && s->resync_mb_y >= 0) |
1874 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR); |
|
1874 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR); |
|
1875 | 1875 |
} else { |
1876 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END | ER_DC_END | ER_MV_END); |
|
1876 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END | ER_DC_END | ER_MV_END); |
|
1877 | 1877 |
} |
1878 | 1878 |
|
1879 | 1879 |
if (s->mb_y == s->end_mb_y) |
... | ... |
@@ -1915,7 +1915,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) |
1915 | 1915 |
|
1916 | 1916 |
s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_MPEG2; |
1917 | 1917 |
|
1918 |
- ff_er_frame_end(s); |
|
1918 |
+ ff_er_frame_end(&s->er); |
|
1919 | 1919 |
|
1920 | 1920 |
ff_MPV_frame_end(s); |
1921 | 1921 |
|
... | ... |
@@ -2210,7 +2210,7 @@ static int decode_chunks(AVCodecContext *avctx, |
2210 | 2210 |
|
2211 | 2211 |
avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*)); |
2212 | 2212 |
for (i = 0; i < s->slice_count; i++) |
2213 |
- s2->error_count += s2->thread_context[i]->error_count; |
|
2213 |
+ s2->er.error_count += s2->thread_context[i]->er.error_count; |
|
2214 | 2214 |
} |
2215 | 2215 |
|
2216 | 2216 |
if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) |
... | ... |
@@ -2252,7 +2252,7 @@ static int decode_chunks(AVCodecContext *avctx, |
2252 | 2252 |
s2->thread_context, NULL, |
2253 | 2253 |
s->slice_count, sizeof(void*)); |
2254 | 2254 |
for (i = 0; i < s->slice_count; i++) |
2255 |
- s2->error_count += s2->thread_context[i]->error_count; |
|
2255 |
+ s2->er.error_count += s2->thread_context[i]->er.error_count; |
|
2256 | 2256 |
s->slice_count = 0; |
2257 | 2257 |
} |
2258 | 2258 |
if (last_code == 0 || last_code == SLICE_MIN_START_CODE) { |
... | ... |
@@ -2411,9 +2411,9 @@ static int decode_chunks(AVCodecContext *avctx, |
2411 | 2411 |
if (avctx->err_recognition & AV_EF_EXPLODE) |
2412 | 2412 |
return ret; |
2413 | 2413 |
if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0) |
2414 |
- ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR); |
|
2414 |
+ ff_er_add_slice(&s2->er, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR); |
|
2415 | 2415 |
} else { |
2416 |
- ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END); |
|
2416 |
+ ff_er_add_slice(&s2->er, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END); |
|
2417 | 2417 |
} |
2418 | 2418 |
} |
2419 | 2419 |
} |
... | ... |
@@ -796,13 +796,13 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s) |
796 | 796 |
|
797 | 797 |
mb_num= mpeg4_decode_partition_a(s); |
798 | 798 |
if(mb_num<0){ |
799 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error); |
|
799 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error); |
|
800 | 800 |
return -1; |
801 | 801 |
} |
802 | 802 |
|
803 | 803 |
if(s->resync_mb_x + s->resync_mb_y*s->mb_width + mb_num > s->mb_num){ |
804 | 804 |
av_log(s->avctx, AV_LOG_ERROR, "slice below monitor ...\n"); |
805 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error); |
|
805 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error); |
|
806 | 806 |
return -1; |
807 | 807 |
} |
808 | 808 |
|
... | ... |
@@ -823,15 +823,15 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s) |
823 | 823 |
return -1; |
824 | 824 |
} |
825 | 825 |
} |
826 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, part_a_end); |
|
826 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, part_a_end); |
|
827 | 827 |
|
828 | 828 |
if( mpeg4_decode_partition_b(s, mb_num) < 0){ |
829 | 829 |
if(s->pict_type==AV_PICTURE_TYPE_P) |
830 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR); |
|
830 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR); |
|
831 | 831 |
return -1; |
832 | 832 |
}else{ |
833 | 833 |
if(s->pict_type==AV_PICTURE_TYPE_P) |
834 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END); |
|
834 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END); |
|
835 | 835 |
} |
836 | 836 |
|
837 | 837 |
return 0; |
... | ... |
@@ -147,6 +147,33 @@ const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[] = { |
147 | 147 |
AV_PIX_FMT_NONE |
148 | 148 |
}; |
149 | 149 |
|
150 |
+static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, |
|
151 |
+ int (*mv)[2][4][2], |
|
152 |
+ int mb_x, int mb_y, int mb_intra, int mb_skipped) |
|
153 |
+{ |
|
154 |
+ MpegEncContext *s = opaque; |
|
155 |
+ |
|
156 |
+ s->mv_dir = mv_dir; |
|
157 |
+ s->mv_type = mv_type; |
|
158 |
+ s->mb_intra = mb_intra; |
|
159 |
+ s->mb_skipped = mb_skipped; |
|
160 |
+ s->mb_x = mb_x; |
|
161 |
+ s->mb_y = mb_y; |
|
162 |
+ memcpy(s->mv, mv, sizeof(*mv)); |
|
163 |
+ |
|
164 |
+ ff_init_block_index(s); |
|
165 |
+ ff_update_block_index(s); |
|
166 |
+ |
|
167 |
+ s->dsp.clear_blocks(s->block[0]); |
|
168 |
+ |
|
169 |
+ s->dest[0] = s->current_picture.f.data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16; |
|
170 |
+ s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); |
|
171 |
+ s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); |
|
172 |
+ |
|
173 |
+ assert(ref == 0); |
|
174 |
+ ff_MPV_decode_mb(s, s->block); |
|
175 |
+} |
|
176 |
+ |
|
150 | 177 |
const uint8_t *avpriv_mpv_find_start_code(const uint8_t *restrict p, |
151 | 178 |
const uint8_t *end, |
152 | 179 |
uint32_t * restrict state) |
... | ... |
@@ -723,6 +750,43 @@ void ff_MPV_decode_defaults(MpegEncContext *s) |
723 | 723 |
ff_MPV_common_defaults(s); |
724 | 724 |
} |
725 | 725 |
|
726 |
+static int init_er(MpegEncContext *s) |
|
727 |
+{ |
|
728 |
+ ERContext *er = &s->er; |
|
729 |
+ int mb_array_size = s->mb_height * s->mb_stride; |
|
730 |
+ int i; |
|
731 |
+ |
|
732 |
+ er->avctx = s->avctx; |
|
733 |
+ er->dsp = &s->dsp; |
|
734 |
+ |
|
735 |
+ er->mb_index2xy = s->mb_index2xy; |
|
736 |
+ er->mb_num = s->mb_num; |
|
737 |
+ er->mb_width = s->mb_width; |
|
738 |
+ er->mb_height = s->mb_height; |
|
739 |
+ er->mb_stride = s->mb_stride; |
|
740 |
+ er->b8_stride = s->b8_stride; |
|
741 |
+ |
|
742 |
+ er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride); |
|
743 |
+ er->error_status_table = av_mallocz(mb_array_size); |
|
744 |
+ if (!er->er_temp_buffer || !er->error_status_table) |
|
745 |
+ goto fail; |
|
746 |
+ |
|
747 |
+ er->mbskip_table = s->mbskip_table; |
|
748 |
+ er->mbintra_table = s->mbintra_table; |
|
749 |
+ |
|
750 |
+ for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++) |
|
751 |
+ er->dc_val[i] = s->dc_val[i]; |
|
752 |
+ |
|
753 |
+ er->decode_mb = mpeg_er_decode_mb; |
|
754 |
+ er->opaque = s; |
|
755 |
+ |
|
756 |
+ return 0; |
|
757 |
+fail: |
|
758 |
+ av_freep(&er->er_temp_buffer); |
|
759 |
+ av_freep(&er->error_status_table); |
|
760 |
+ return AVERROR(ENOMEM); |
|
761 |
+} |
|
762 |
+ |
|
726 | 763 |
/** |
727 | 764 |
* Initialize and allocates MpegEncContext fields dependent on the resolution. |
728 | 765 |
*/ |
... | ... |
@@ -801,11 +865,6 @@ static int init_context_frame(MpegEncContext *s) |
801 | 801 |
|
802 | 802 |
} |
803 | 803 |
|
804 |
- FF_ALLOC_OR_GOTO(s->avctx, s->er_temp_buffer, |
|
805 |
- mb_array_size * sizeof(uint8_t), fail); |
|
806 |
- FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, |
|
807 |
- mb_array_size * sizeof(uint8_t), fail); |
|
808 |
- |
|
809 | 804 |
if (s->codec_id == AV_CODEC_ID_MPEG4 || |
810 | 805 |
(s->flags & CODEC_FLAG_INTERLACED_ME)) { |
811 | 806 |
/* interlaced direct mode decoding tables */ |
... | ... |
@@ -873,7 +932,7 @@ static int init_context_frame(MpegEncContext *s) |
873 | 873 |
2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH); |
874 | 874 |
} |
875 | 875 |
|
876 |
- return 0; |
|
876 |
+ return init_er(s); |
|
877 | 877 |
fail: |
878 | 878 |
return AVERROR(ENOMEM); |
879 | 879 |
} |
... | ... |
@@ -1054,8 +1113,8 @@ static int free_context_frame(MpegEncContext *s) |
1054 | 1054 |
|
1055 | 1055 |
av_freep(&s->mbskip_table); |
1056 | 1056 |
|
1057 |
- av_freep(&s->error_status_table); |
|
1058 |
- av_freep(&s->er_temp_buffer); |
|
1057 |
+ av_freep(&s->er.error_status_table); |
|
1058 |
+ av_freep(&s->er.er_temp_buffer); |
|
1059 | 1059 |
av_freep(&s->mb_index2xy); |
1060 | 1060 |
av_freep(&s->lambda_table); |
1061 | 1061 |
av_freep(&s->cplx_tab); |
... | ... |
@@ -1589,7 +1648,7 @@ void ff_MPV_frame_end(MpegEncContext *s) |
1589 | 1589 |
// just to make sure that all data is rendered. |
1590 | 1590 |
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) { |
1591 | 1591 |
ff_xvmc_field_end(s); |
1592 |
- } else if ((s->error_count || s->encoding) && |
|
1592 |
+ } else if ((s->er.error_count || s->encoding) && |
|
1593 | 1593 |
!s->avctx->hwaccel && |
1594 | 1594 |
!(s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) && |
1595 | 1595 |
s->unrestricted_mv && |
... | ... |
@@ -2792,6 +2851,22 @@ void ff_set_qscale(MpegEncContext * s, int qscale) |
2792 | 2792 |
|
2793 | 2793 |
void ff_MPV_report_decode_progress(MpegEncContext *s) |
2794 | 2794 |
{ |
2795 |
- if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->error_occurred) |
|
2795 |
+ if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) |
|
2796 | 2796 |
ff_thread_report_progress(&s->current_picture_ptr->f, s->mb_y, 0); |
2797 | 2797 |
} |
2798 |
+ |
|
2799 |
+void ff_mpeg_er_frame_start(MpegEncContext *s) |
|
2800 |
+{ |
|
2801 |
+ ERContext *er = &s->er; |
|
2802 |
+ |
|
2803 |
+ er->cur_pic = s->current_picture_ptr; |
|
2804 |
+ er->last_pic = s->last_picture_ptr; |
|
2805 |
+ er->next_pic = s->next_picture_ptr; |
|
2806 |
+ |
|
2807 |
+ er->pp_time = s->pp_time; |
|
2808 |
+ er->pb_time = s->pb_time; |
|
2809 |
+ er->quarter_sample = s->quarter_sample; |
|
2810 |
+ er->partitioned_frame = s->partitioned_frame; |
|
2811 |
+ |
|
2812 |
+ ff_er_frame_start(er); |
|
2813 |
+} |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
|
31 | 31 |
#include "avcodec.h" |
32 | 32 |
#include "dsputil.h" |
33 |
+#include "error_resilience.h" |
|
33 | 34 |
#include "get_bits.h" |
34 | 35 |
#include "put_bits.h" |
35 | 36 |
#include "ratecontrol.h" |
... | ... |
@@ -484,19 +485,6 @@ typedef struct MpegEncContext { |
484 | 484 |
int last_bits; ///< temp var used for calculating the above vars |
485 | 485 |
|
486 | 486 |
/* error concealment / resync */ |
487 |
- int error_count, error_occurred; |
|
488 |
- uint8_t *error_status_table; ///< table of the error status of each MB |
|
489 |
-#define VP_START 1 ///< current MB is the first after a resync marker |
|
490 |
-#define ER_AC_ERROR 2 |
|
491 |
-#define ER_DC_ERROR 4 |
|
492 |
-#define ER_MV_ERROR 8 |
|
493 |
-#define ER_AC_END 16 |
|
494 |
-#define ER_DC_END 32 |
|
495 |
-#define ER_MV_END 64 |
|
496 |
- |
|
497 |
-#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR) |
|
498 |
-#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END) |
|
499 |
- |
|
500 | 487 |
int resync_mb_x; ///< x position of last resync marker |
501 | 488 |
int resync_mb_y; ///< y position of last resync marker |
502 | 489 |
GetBitContext last_resync_gb; ///< used to search for the next resync marker |
... | ... |
@@ -701,15 +689,14 @@ typedef struct MpegEncContext { |
701 | 701 |
int mpv_flags; ///< flags set by private options |
702 | 702 |
int quantizer_noise_shaping; |
703 | 703 |
|
704 |
- /* error resilience stuff */ |
|
705 |
- uint8_t *er_temp_buffer; |
|
706 |
- |
|
707 | 704 |
/* temp buffers for rate control */ |
708 | 705 |
float *cplx_tab, *bits_tab; |
709 | 706 |
|
710 | 707 |
/* flag to indicate a reinitialization is required, e.g. after |
711 | 708 |
* a frame size change */ |
712 | 709 |
int context_reinit; |
710 |
+ |
|
711 |
+ ERContext er; |
|
713 | 712 |
} MpegEncContext; |
714 | 713 |
|
715 | 714 |
#define REBASE_PICTURE(pic, new_ctx, old_ctx) \ |
... | ... |
@@ -787,9 +774,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src |
787 | 787 |
const uint8_t *avpriv_mpv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); |
788 | 788 |
void ff_set_qscale(MpegEncContext * s, int qscale); |
789 | 789 |
|
790 |
-void ff_er_frame_start(MpegEncContext *s); |
|
791 |
-void ff_er_frame_end(MpegEncContext *s); |
|
792 |
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status); |
|
790 |
+void ff_mpeg_er_frame_start(MpegEncContext *s); |
|
793 | 791 |
|
794 | 792 |
int ff_dct_common_init(MpegEncContext *s); |
795 | 793 |
void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], |
... | ... |
@@ -3037,7 +3037,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) |
3037 | 3037 |
MERGE(b_count); |
3038 | 3038 |
MERGE(skip_count); |
3039 | 3039 |
MERGE(misc_bits); |
3040 |
- MERGE(error_count); |
|
3040 |
+ MERGE(er.error_count); |
|
3041 | 3041 |
MERGE(padding_bug_score); |
3042 | 3042 |
MERGE(current_picture.f.error[0]); |
3043 | 3043 |
MERGE(current_picture.f.error[1]); |
... | ... |
@@ -406,7 +406,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, |
406 | 406 |
return ret; |
407 | 407 |
} |
408 | 408 |
|
409 |
- ff_er_frame_start(s); |
|
409 |
+ ff_mpeg_er_frame_start(s); |
|
410 | 410 |
|
411 | 411 |
v->bits = buf_size * 8; |
412 | 412 |
|
... | ... |
@@ -419,7 +419,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, |
419 | 419 |
|
420 | 420 |
ff_vc1_decode_blocks(v); |
421 | 421 |
|
422 |
- ff_er_frame_end(s); |
|
422 |
+ ff_er_frame_end(&s->er); |
|
423 | 423 |
|
424 | 424 |
ff_MPV_frame_end(s); |
425 | 425 |
|
... | ... |
@@ -528,13 +528,13 @@ static int rv10_decode_packet(AVCodecContext *avctx, |
528 | 528 |
|
529 | 529 |
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) { |
530 | 530 |
if(s->current_picture_ptr){ //FIXME write parser so we always have complete frames? |
531 |
- ff_er_frame_end(s); |
|
531 |
+ ff_er_frame_end(&s->er); |
|
532 | 532 |
ff_MPV_frame_end(s); |
533 | 533 |
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0; |
534 | 534 |
} |
535 | 535 |
if(ff_MPV_frame_start(s, avctx) < 0) |
536 | 536 |
return -1; |
537 |
- ff_er_frame_start(s); |
|
537 |
+ ff_mpeg_er_frame_start(s); |
|
538 | 538 |
} else { |
539 | 539 |
if (s->current_picture_ptr->f.pict_type != s->pict_type) { |
540 | 540 |
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); |
... | ... |
@@ -626,7 +626,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, |
626 | 626 |
if(ret == SLICE_END) break; |
627 | 627 |
} |
628 | 628 |
|
629 |
- ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
629 |
+ ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
630 | 630 |
|
631 | 631 |
return active_bits_size; |
632 | 632 |
} |
... | ... |
@@ -697,7 +697,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, |
697 | 697 |
} |
698 | 698 |
|
699 | 699 |
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ |
700 |
- ff_er_frame_end(s); |
|
700 |
+ ff_er_frame_end(&s->er); |
|
701 | 701 |
ff_MPV_frame_end(s); |
702 | 702 |
|
703 | 703 |
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
... | ... |
@@ -1428,7 +1428,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int |
1428 | 1428 |
else |
1429 | 1429 |
res = rv34_decode_intra_macroblock(r, r->intra_types + s->mb_x * 4 + 4); |
1430 | 1430 |
if(res < 0){ |
1431 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR); |
|
1431 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR); |
|
1432 | 1432 |
return -1; |
1433 | 1433 |
} |
1434 | 1434 |
if (++s->mb_x == s->mb_width) { |
... | ... |
@@ -1451,7 +1451,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int |
1451 | 1451 |
s->first_slice_line=0; |
1452 | 1452 |
s->mb_num_left--; |
1453 | 1453 |
} |
1454 |
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
1454 |
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); |
|
1455 | 1455 |
|
1456 | 1456 |
return s->mb_y == s->mb_height; |
1457 | 1457 |
} |
... | ... |
@@ -1564,7 +1564,7 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict) |
1564 | 1564 |
MpegEncContext *s = &r->s; |
1565 | 1565 |
int got_picture = 0; |
1566 | 1566 |
|
1567 |
- ff_er_frame_end(s); |
|
1567 |
+ ff_er_frame_end(&s->er); |
|
1568 | 1568 |
ff_MPV_frame_end(s); |
1569 | 1569 |
s->mb_num_left = 0; |
1570 | 1570 |
|
... | ... |
@@ -1646,7 +1646,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, |
1646 | 1646 |
if (s->mb_num_left > 0) { |
1647 | 1647 |
av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.", |
1648 | 1648 |
s->mb_num_left); |
1649 |
- ff_er_frame_end(s); |
|
1649 |
+ ff_er_frame_end(&s->er); |
|
1650 | 1650 |
ff_MPV_frame_end(s); |
1651 | 1651 |
} |
1652 | 1652 |
|
... | ... |
@@ -1667,7 +1667,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, |
1667 | 1667 |
s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I; |
1668 | 1668 |
if (ff_MPV_frame_start(s, s->avctx) < 0) |
1669 | 1669 |
return -1; |
1670 |
- ff_er_frame_start(s); |
|
1670 |
+ ff_mpeg_er_frame_start(s); |
|
1671 | 1671 |
if (!r->tmp_b_block_base) { |
1672 | 1672 |
int i; |
1673 | 1673 |
|
... | ... |
@@ -1766,7 +1766,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, |
1766 | 1766 |
av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n"); |
1767 | 1767 |
/* always mark the current frame as finished, frame-mt supports |
1768 | 1768 |
* only complete frames */ |
1769 |
- ff_er_frame_end(s); |
|
1769 |
+ ff_er_frame_end(&s->er); |
|
1770 | 1770 |
ff_MPV_frame_end(s); |
1771 | 1771 |
s->mb_num_left = 0; |
1772 | 1772 |
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0); |
... | ... |
@@ -4434,7 +4434,7 @@ static void vc1_decode_i_blocks(VC1Context *v) |
4434 | 4434 |
if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq); |
4435 | 4435 |
|
4436 | 4436 |
if (get_bits_count(&s->gb) > v->bits) { |
4437 |
- ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4437 |
+ ff_er_add_slice(&s->er, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4438 | 4438 |
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", |
4439 | 4439 |
get_bits_count(&s->gb), v->bits); |
4440 | 4440 |
return; |
... | ... |
@@ -4452,7 +4452,7 @@ static void vc1_decode_i_blocks(VC1Context *v) |
4452 | 4452 |
|
4453 | 4453 |
/* This is intentionally mb_height and not end_mb_y - unlike in advanced |
4454 | 4454 |
* profile, these only differ are when decoding MSS2 rectangles. */ |
4455 |
- ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END); |
|
4455 |
+ ff_er_add_slice(&s->er, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END); |
|
4456 | 4456 |
} |
4457 | 4457 |
|
4458 | 4458 |
/** Decode blocks of I-frame for advanced profile |
... | ... |
@@ -4562,7 +4562,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) |
4562 | 4562 |
|
4563 | 4563 |
if (get_bits_count(&s->gb) > v->bits) { |
4564 | 4564 |
// TODO: may need modification to handle slice coding |
4565 |
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4565 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4566 | 4566 |
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", |
4567 | 4567 |
get_bits_count(&s->gb), v->bits); |
4568 | 4568 |
return; |
... | ... |
@@ -4586,7 +4586,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) |
4586 | 4586 |
} |
4587 | 4587 |
if (v->s.loop_filter) |
4588 | 4588 |
ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16); |
4589 |
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4589 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4590 | 4590 |
(s->end_mb_y << v->field_mode) - 1, ER_MB_END); |
4591 | 4591 |
} |
4592 | 4592 |
|
... | ... |
@@ -4638,7 +4638,7 @@ static void vc1_decode_p_blocks(VC1Context *v) |
4638 | 4638 |
vc1_apply_p_loop_filter(v); |
4639 | 4639 |
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { |
4640 | 4640 |
// TODO: may need modification to handle slice coding |
4641 |
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4641 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4642 | 4642 |
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", |
4643 | 4643 |
get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y); |
4644 | 4644 |
return; |
... | ... |
@@ -4661,7 +4661,7 @@ static void vc1_decode_p_blocks(VC1Context *v) |
4661 | 4661 |
} |
4662 | 4662 |
if (s->end_mb_y >= s->start_mb_y) |
4663 | 4663 |
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); |
4664 |
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4664 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4665 | 4665 |
(s->end_mb_y << v->field_mode) - 1, ER_MB_END); |
4666 | 4666 |
} |
4667 | 4667 |
|
... | ... |
@@ -4707,7 +4707,7 @@ static void vc1_decode_b_blocks(VC1Context *v) |
4707 | 4707 |
vc1_decode_b_mb(v); |
4708 | 4708 |
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { |
4709 | 4709 |
// TODO: may need modification to handle slice coding |
4710 |
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4710 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR); |
|
4711 | 4711 |
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", |
4712 | 4712 |
get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y); |
4713 | 4713 |
return; |
... | ... |
@@ -4722,7 +4722,7 @@ static void vc1_decode_b_blocks(VC1Context *v) |
4722 | 4722 |
} |
4723 | 4723 |
if (v->s.loop_filter) |
4724 | 4724 |
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); |
4725 |
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4725 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, |
|
4726 | 4726 |
(s->end_mb_y << v->field_mode) - 1, ER_MB_END); |
4727 | 4727 |
} |
4728 | 4728 |
|
... | ... |
@@ -4730,7 +4730,7 @@ static void vc1_decode_skip_blocks(VC1Context *v) |
4730 | 4730 |
{ |
4731 | 4731 |
MpegEncContext *s = &v->s; |
4732 | 4732 |
|
4733 |
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END); |
|
4733 |
+ ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END); |
|
4734 | 4734 |
s->first_slice_line = 1; |
4735 | 4735 |
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { |
4736 | 4736 |
s->mb_x = 0; |
... | ... |
@@ -5558,7 +5558,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, |
5558 | 5558 |
if (avctx->hwaccel->end_frame(avctx) < 0) |
5559 | 5559 |
goto err; |
5560 | 5560 |
} else { |
5561 |
- ff_er_frame_start(s); |
|
5561 |
+ ff_mpeg_er_frame_start(s); |
|
5562 | 5562 |
|
5563 | 5563 |
v->bits = buf_size * 8; |
5564 | 5564 |
v->end_mb_x = s->mb_width; |
... | ... |
@@ -5635,7 +5635,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, |
5635 | 5635 |
get_bits_count(&s->gb), s->gb.size_in_bits); |
5636 | 5636 |
// if (get_bits_count(&s->gb) > buf_size * 8) |
5637 | 5637 |
// return -1; |
5638 |
- ff_er_frame_end(s); |
|
5638 |
+ ff_er_frame_end(&s->er); |
|
5639 | 5639 |
} |
5640 | 5640 |
|
5641 | 5641 |
ff_MPV_frame_end(s); |