Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * This file is part of FFmpeg. | ||
3 | * | ||
4 | * FFmpeg 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 | * FFmpeg 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 FFmpeg; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #include "error_resilience.h" | ||
20 | #include "mpegvideo.h" | ||
21 | #include "mpegvideodec.h" | ||
22 | #include "mpeg_er.h" | ||
23 | |||
24 | 33309 | static void set_erpic(ERPicture *dst, Picture *src) | |
25 | { | ||
26 | int i; | ||
27 | |||
28 | 33309 | memset(dst, 0, sizeof(*dst)); | |
29 |
2/2✓ Branch 0 taken 299 times.
✓ Branch 1 taken 33010 times.
|
33309 | if (!src) { |
30 | 299 | dst->f = NULL; | |
31 | 299 | dst->tf = NULL; | |
32 | 299 | return; | |
33 | } | ||
34 | |||
35 | 33010 | dst->f = src->f; | |
36 | 33010 | dst->tf = &src->tf; | |
37 | |||
38 |
2/2✓ Branch 0 taken 66020 times.
✓ Branch 1 taken 33010 times.
|
99030 | for (i = 0; i < 2; i++) { |
39 | 66020 | dst->motion_val[i] = src->motion_val[i]; | |
40 | 66020 | dst->ref_index[i] = src->ref_index[i]; | |
41 | } | ||
42 | |||
43 | 33010 | dst->mb_type = src->mb_type; | |
44 | 33010 | dst->field_picture = src->field_picture; | |
45 | } | ||
46 | |||
47 | 11103 | void ff_mpeg_er_frame_start(MpegEncContext *s) | |
48 | { | ||
49 | 11103 | ERContext *er = &s->er; | |
50 | |||
51 | 11103 | set_erpic(&er->cur_pic, s->current_picture_ptr); | |
52 | 11103 | set_erpic(&er->next_pic, s->next_picture_ptr); | |
53 | 11103 | set_erpic(&er->last_pic, s->last_picture_ptr); | |
54 | |||
55 | 11103 | er->pp_time = s->pp_time; | |
56 | 11103 | er->pb_time = s->pb_time; | |
57 | 11103 | er->quarter_sample = s->quarter_sample; | |
58 | 11103 | er->partitioned_frame = s->partitioned_frame; | |
59 | |||
60 | 11103 | ff_er_frame_start(er); | |
61 | 11103 | } | |
62 | |||
63 | 59062 | static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, | |
64 | int (*mv)[2][4][2], int mb_x, int mb_y, | ||
65 | int mb_intra, int mb_skipped) | ||
66 | { | ||
67 | 59062 | MpegEncContext *s = opaque; | |
68 | |||
69 | 59062 | s->mv_dir = mv_dir; | |
70 | 59062 | s->mv_type = mv_type; | |
71 | 59062 | s->mb_intra = mb_intra; | |
72 | 59062 | s->mb_skipped = mb_skipped; | |
73 | 59062 | s->mb_x = mb_x; | |
74 | 59062 | s->mb_y = mb_y; | |
75 | 59062 | s->mcsel = 0; | |
76 | 59062 | memcpy(s->mv, mv, sizeof(*mv)); | |
77 | |||
78 | 59062 | ff_init_block_index(s); | |
79 | 59062 | ff_update_block_index(s, s->avctx->bits_per_raw_sample, | |
80 | 59062 | s->avctx->lowres, s->chroma_x_shift); | |
81 | |||
82 | 59062 | s->bdsp.clear_blocks(s->block[0]); | |
83 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59062 times.
|
59062 | if (!s->chroma_y_shift) |
84 | ✗ | s->bdsp.clear_blocks(s->block[6]); | |
85 | |||
86 | 59062 | s->dest[0] = s->current_picture.f->data[0] + | |
87 | 59062 | s->mb_y * 16 * s->linesize + | |
88 | 59062 | s->mb_x * 16; | |
89 | 59062 | s->dest[1] = s->current_picture.f->data[1] + | |
90 | 59062 | s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + | |
91 | 59062 | s->mb_x * (16 >> s->chroma_x_shift); | |
92 | 59062 | s->dest[2] = s->current_picture.f->data[2] + | |
93 | 59062 | s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + | |
94 | 59062 | s->mb_x * (16 >> s->chroma_x_shift); | |
95 | |||
96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59062 times.
|
59062 | if (ref) |
97 | ✗ | av_log(s->avctx, AV_LOG_DEBUG, | |
98 | "Interlaced error concealment is not fully implemented\n"); | ||
99 | 59062 | ff_mpv_reconstruct_mb(s, s->block); | |
100 | 59062 | } | |
101 | |||
102 | 627 | int ff_mpeg_er_init(MpegEncContext *s) | |
103 | { | ||
104 | 627 | ERContext *er = &s->er; | |
105 | 627 | int mb_array_size = s->mb_height * s->mb_stride; | |
106 | int i; | ||
107 | |||
108 | 627 | er->avctx = s->avctx; | |
109 | |||
110 | 627 | er->mb_index2xy = s->mb_index2xy; | |
111 | 627 | er->mb_num = s->mb_num; | |
112 | 627 | er->mb_width = s->mb_width; | |
113 | 627 | er->mb_height = s->mb_height; | |
114 | 627 | er->mb_stride = s->mb_stride; | |
115 | 627 | er->b8_stride = s->b8_stride; | |
116 | |||
117 | 627 | er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride * (4*sizeof(int) + 1)); | |
118 | 627 | er->error_status_table = av_mallocz(mb_array_size); | |
119 |
2/4✓ Branch 0 taken 627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 627 times.
|
627 | if (!er->er_temp_buffer || !er->error_status_table) |
120 | ✗ | goto fail; | |
121 | |||
122 | 627 | er->mbskip_table = s->mbskip_table; | |
123 | 627 | er->mbintra_table = s->mbintra_table; | |
124 | |||
125 |
2/2✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 627 times.
|
2508 | for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++) |
126 | 1881 | er->dc_val[i] = s->dc_val[i]; | |
127 | |||
128 | 627 | er->decode_mb = mpeg_er_decode_mb; | |
129 | 627 | er->opaque = s; | |
130 | |||
131 | 627 | return 0; | |
132 | ✗ | fail: | |
133 | ✗ | av_freep(&er->er_temp_buffer); | |
134 | ✗ | av_freep(&er->error_status_table); | |
135 | ✗ | return AVERROR(ENOMEM); | |
136 | } | ||
137 |