Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Common mpeg video decoding code | ||
3 | * Copyright (c) 2000,2001 Fabrice Bellard | ||
4 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include <limits.h> | ||
24 | |||
25 | #include "config_components.h" | ||
26 | |||
27 | #include "libavutil/avassert.h" | ||
28 | #include "libavutil/emms.h" | ||
29 | #include "libavutil/imgutils.h" | ||
30 | #include "libavutil/internal.h" | ||
31 | #include "libavutil/video_enc_params.h" | ||
32 | |||
33 | #include "avcodec.h" | ||
34 | #include "decode.h" | ||
35 | #include "h264chroma.h" | ||
36 | #include "internal.h" | ||
37 | #include "mpegutils.h" | ||
38 | #include "mpegvideo.h" | ||
39 | #include "mpegvideodec.h" | ||
40 | #include "mpeg4videodec.h" | ||
41 | #include "libavutil/refstruct.h" | ||
42 | #include "thread.h" | ||
43 | #include "threadprogress.h" | ||
44 | #include "wmv2dec.h" | ||
45 | |||
46 | 636 | int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) | |
47 | { | ||
48 | enum ThreadingStatus thread_status; | ||
49 | |||
50 | 636 | ff_mpv_common_defaults(s); | |
51 | |||
52 | 636 | s->avctx = avctx; | |
53 | 636 | s->width = avctx->coded_width; | |
54 | 636 | s->height = avctx->coded_height; | |
55 | 636 | s->codec_id = avctx->codec->id; | |
56 | 636 | s->workaround_bugs = avctx->workaround_bugs; | |
57 | |||
58 | /* convert fourcc to upper case */ | ||
59 | 636 | s->codec_tag = ff_toupper4(avctx->codec_tag); | |
60 | |||
61 | 636 | ff_mpv_idct_init(s); | |
62 | |||
63 | 636 | ff_h264chroma_init(&s->h264chroma, 8); //for lowres | |
64 | |||
65 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 636 times.
|
636 | if (s->picture_pool) // VC-1 can call this multiple times |
66 | ✗ | return 0; | |
67 | |||
68 | 636 | thread_status = ff_thread_sync_ref(avctx, offsetof(MpegEncContext, picture_pool)); | |
69 |
2/2✓ Branch 0 taken 628 times.
✓ Branch 1 taken 8 times.
|
636 | if (thread_status != FF_THREAD_IS_COPY) { |
70 | 628 | s->picture_pool = ff_mpv_alloc_pic_pool(thread_status != FF_THREAD_NO_FRAME_THREADING); | |
71 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 628 times.
|
628 | if (!s->picture_pool) |
72 | ✗ | return AVERROR(ENOMEM); | |
73 | } | ||
74 | 636 | return 0; | |
75 | } | ||
76 | |||
77 | 18 | int ff_mpeg_update_thread_context(AVCodecContext *dst, | |
78 | const AVCodecContext *src) | ||
79 | { | ||
80 | 18 | MpegEncContext *const s1 = src->priv_data; | |
81 | 18 | MpegEncContext *const s = dst->priv_data; | |
82 | int ret; | ||
83 | |||
84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if (dst == src) |
85 | ✗ | return 0; | |
86 | |||
87 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | av_assert0(s != s1); |
88 | |||
89 | // FIXME can parameters change on I-frames? | ||
90 | // in that case dst may need a reinit | ||
91 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 10 times.
|
18 | if (!s->context_initialized) { |
92 | 8 | void *private_ctx = s->private_ctx; | |
93 | int err; | ||
94 | 8 | memcpy(s, s1, sizeof(*s)); | |
95 | |||
96 | 8 | s->context_initialized = 0; | |
97 | 8 | s->context_reinit = 0; | |
98 | 8 | s->avctx = dst; | |
99 | 8 | s->private_ctx = private_ctx; | |
100 | |||
101 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (s1->context_initialized) { |
102 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if ((err = ff_mpv_common_init(s)) < 0) |
103 | ✗ | return err; | |
104 | } | ||
105 | } | ||
106 | |||
107 |
3/6✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
|
18 | if (s->height != s1->height || s->width != s1->width || s->context_reinit) { |
108 | ✗ | s->height = s1->height; | |
109 | ✗ | s->width = s1->width; | |
110 | ✗ | if ((ret = ff_mpv_common_frame_size_change(s)) < 0) | |
111 | ✗ | return ret; | |
112 | } | ||
113 | |||
114 | 18 | s->quarter_sample = s1->quarter_sample; | |
115 | |||
116 | 18 | s->picture_number = s1->picture_number; | |
117 | |||
118 | 18 | ff_mpv_replace_picture(&s->cur_pic, &s1->cur_pic); | |
119 | 18 | ff_mpv_replace_picture(&s->last_pic, &s1->last_pic); | |
120 | 18 | ff_mpv_replace_picture(&s->next_pic, &s1->next_pic); | |
121 | |||
122 | 18 | s->linesize = s1->linesize; | |
123 | 18 | s->uvlinesize = s1->uvlinesize; | |
124 | |||
125 | // Error/bug resilience | ||
126 | 18 | s->workaround_bugs = s1->workaround_bugs; | |
127 | 18 | s->padding_bug_score = s1->padding_bug_score; | |
128 | |||
129 | // MPEG-4 timing info | ||
130 | 18 | memcpy(&s->last_time_base, &s1->last_time_base, | |
131 | 18 | (char *) &s1->pb_field_time + sizeof(s1->pb_field_time) - | |
132 | 18 | (char *) &s1->last_time_base); | |
133 | |||
134 | // B-frame info | ||
135 | 18 | s->low_delay = s1->low_delay; | |
136 | |||
137 | // MPEG-2/interlacing info | ||
138 | 18 | memcpy(&s->progressive_sequence, &s1->progressive_sequence, | |
139 | (char *) &s1->rtp_mode - (char *) &s1->progressive_sequence); | ||
140 | |||
141 | 18 | return 0; | |
142 | } | ||
143 | |||
144 | 636 | int ff_mpv_decode_close(AVCodecContext *avctx) | |
145 | { | ||
146 | 636 | MpegEncContext *s = avctx->priv_data; | |
147 | |||
148 | 636 | av_refstruct_pool_uninit(&s->picture_pool); | |
149 | 636 | ff_mpv_common_end(s); | |
150 | 636 | return 0; | |
151 | } | ||
152 | |||
153 | 47 | int ff_mpv_common_frame_size_change(MpegEncContext *s) | |
154 | { | ||
155 | 47 | int err = 0; | |
156 | |||
157 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
47 | if (!s->context_initialized) |
158 | ✗ | return AVERROR(EINVAL); | |
159 | |||
160 | 47 | ff_mpv_free_context_frame(s); | |
161 | |||
162 | 47 | ff_mpv_unref_picture(&s->last_pic); | |
163 | 47 | ff_mpv_unref_picture(&s->next_pic); | |
164 | 47 | ff_mpv_unref_picture(&s->cur_pic); | |
165 | |||
166 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
|
94 | if ((s->width || s->height) && |
167 | 47 | (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) | |
168 | ✗ | goto fail; | |
169 | |||
170 | /* set chroma shifts */ | ||
171 | 47 | err = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, | |
172 | &s->chroma_x_shift, | ||
173 | &s->chroma_y_shift); | ||
174 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
47 | if (err < 0) |
175 | ✗ | goto fail; | |
176 | |||
177 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
|
47 | if ((err = ff_mpv_init_context_frame(s))) |
178 | ✗ | goto fail; | |
179 | |||
180 | 47 | memset(s->thread_context, 0, sizeof(s->thread_context)); | |
181 | 47 | s->thread_context[0] = s; | |
182 | |||
183 |
2/4✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
|
47 | if (s->width && s->height) { |
184 | 47 | err = ff_mpv_init_duplicate_contexts(s); | |
185 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
47 | if (err < 0) |
186 | ✗ | goto fail; | |
187 | } | ||
188 | 47 | s->context_reinit = 0; | |
189 | |||
190 | 47 | return 0; | |
191 | ✗ | fail: | |
192 | ✗ | ff_mpv_free_context_frame(s); | |
193 | ✗ | s->context_reinit = 1; | |
194 | ✗ | return err; | |
195 | } | ||
196 | |||
197 | 11259 | static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference) | |
198 | { | ||
199 | 11259 | AVCodecContext *avctx = s->avctx; | |
200 | 11259 | MPVPicture *pic = av_refstruct_pool_get(s->picture_pool); | |
201 | int ret; | ||
202 | |||
203 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11259 times.
|
11259 | if (!pic) |
204 | ✗ | return AVERROR(ENOMEM); | |
205 | |||
206 | 11259 | dst->ptr = pic; | |
207 | |||
208 | 11259 | pic->reference = reference; | |
209 | |||
210 | /* WM Image / Screen codecs allocate internal buffers with different | ||
211 | * dimensions / colorspaces; ignore user-defined callbacks for these. */ | ||
212 |
1/2✓ Branch 0 taken 11259 times.
✗ Branch 1 not taken.
|
11259 | if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && |
213 |
1/2✓ Branch 0 taken 11259 times.
✗ Branch 1 not taken.
|
11259 | avctx->codec_id != AV_CODEC_ID_VC1IMAGE && |
214 |
2/2✓ Branch 0 taken 11177 times.
✓ Branch 1 taken 82 times.
|
11259 | avctx->codec_id != AV_CODEC_ID_MSS2) { |
215 | 11177 | ret = ff_thread_get_buffer(avctx, pic->f, | |
216 | reference ? AV_GET_BUFFER_FLAG_REF : 0); | ||
217 | } else { | ||
218 | 82 | pic->f->width = avctx->width; | |
219 | 82 | pic->f->height = avctx->height; | |
220 | 82 | pic->f->format = avctx->pix_fmt; | |
221 | 82 | ret = avcodec_default_get_buffer2(avctx, pic->f, 0); | |
222 | } | ||
223 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11259 times.
|
11259 | if (ret < 0) |
224 | ✗ | goto fail; | |
225 | |||
226 | 11259 | ret = ff_mpv_pic_check_linesize(avctx, pic->f, &s->linesize, &s->uvlinesize); | |
227 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11259 times.
|
11259 | if (ret < 0) |
228 | ✗ | goto fail; | |
229 | |||
230 | 11259 | ret = ff_hwaccel_frame_priv_alloc(avctx, &pic->hwaccel_picture_private); | |
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11259 times.
|
11259 | if (ret < 0) |
232 | ✗ | goto fail; | |
233 | |||
234 | av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width); | ||
235 | av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height || | ||
236 | FFALIGN(s->mb_height, 2) == s->buffer_pools.alloc_mb_height); | ||
237 | av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); | ||
238 | 11259 | ret = ff_mpv_alloc_pic_accessories(s->avctx, dst, &s->sc, | |
239 | &s->buffer_pools, s->mb_height); | ||
240 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11259 times.
|
11259 | if (ret < 0) |
241 | ✗ | goto fail; | |
242 | |||
243 | 11259 | return 0; | |
244 | ✗ | fail: | |
245 | ✗ | ff_mpv_unref_picture(dst); | |
246 | ✗ | return ret; | |
247 | } | ||
248 | |||
249 | 21 | static int av_cold alloc_dummy_frame(MpegEncContext *s, MPVWorkPicture *dst) | |
250 | { | ||
251 | MPVPicture *pic; | ||
252 | 21 | int ret = alloc_picture(s, dst, 1); | |
253 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (ret < 0) |
254 | ✗ | return ret; | |
255 | |||
256 | 21 | pic = dst->ptr; | |
257 | 21 | pic->dummy = 1; | |
258 | |||
259 | 21 | ff_thread_progress_report(&pic->progress, INT_MAX); | |
260 | |||
261 | 21 | return 0; | |
262 | } | ||
263 | |||
264 | 21 | static void color_frame(AVFrame *frame, int luma) | |
265 | { | ||
266 | int h_chroma_shift, v_chroma_shift; | ||
267 | |||
268 |
2/2✓ Branch 0 taken 9888 times.
✓ Branch 1 taken 21 times.
|
9909 | for (int i = 0; i < frame->height; i++) |
269 | 9888 | memset(frame->data[0] + frame->linesize[0] * i, luma, frame->width); | |
270 | |||
271 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (!frame->data[1]) |
272 | ✗ | return; | |
273 | 21 | av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift); | |
274 |
2/2✓ Branch 0 taken 4944 times.
✓ Branch 1 taken 21 times.
|
4965 | for (int i = 0; i < AV_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) { |
275 | 4944 | memset(frame->data[1] + frame->linesize[1] * i, | |
276 | 4944 | 0x80, AV_CEIL_RSHIFT(frame->width, h_chroma_shift)); | |
277 | 4944 | memset(frame->data[2] + frame->linesize[2] * i, | |
278 | 4944 | 0x80, AV_CEIL_RSHIFT(frame->width, h_chroma_shift)); | |
279 | } | ||
280 | } | ||
281 | |||
282 | 11948 | int ff_mpv_alloc_dummy_frames(MpegEncContext *s) | |
283 | { | ||
284 | 11948 | AVCodecContext *avctx = s->avctx; | |
285 | int ret; | ||
286 | |||
287 | av_assert1(!s->last_pic.ptr || s->last_pic.ptr->f->buf[0]); | ||
288 | av_assert1(!s->next_pic.ptr || s->next_pic.ptr->f->buf[0]); | ||
289 |
4/4✓ Branch 0 taken 335 times.
✓ Branch 1 taken 11613 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 314 times.
|
11948 | if (!s->last_pic.ptr && s->pict_type != AV_PICTURE_TYPE_I) { |
290 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
21 | if (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr) |
291 | ✗ | av_log(avctx, AV_LOG_DEBUG, | |
292 | "allocating dummy last picture for B frame\n"); | ||
293 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 6 times.
|
21 | else if (s->codec_id != AV_CODEC_ID_H261 /* H.261 has no keyframes */ && |
294 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
|
15 | (s->picture_structure == PICT_FRAME || s->first_field)) |
295 | ✗ | av_log(avctx, AV_LOG_ERROR, | |
296 | "warning: first frame is no keyframe\n"); | ||
297 | |||
298 | /* Allocate a dummy frame */ | ||
299 | 21 | ret = alloc_dummy_frame(s, &s->last_pic); | |
300 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (ret < 0) |
301 | ✗ | return ret; | |
302 | |||
303 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (!avctx->hwaccel) { |
304 |
2/4✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
|
21 | int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80; |
305 | 21 | color_frame(s->last_pic.ptr->f, luma_val); | |
306 | } | ||
307 | } | ||
308 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11948 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11948 | if (!s->next_pic.ptr && s->pict_type == AV_PICTURE_TYPE_B) { |
309 | /* Allocate a dummy frame */ | ||
310 | ✗ | ret = alloc_dummy_frame(s, &s->next_pic); | |
311 | ✗ | if (ret < 0) | |
312 | ✗ | return ret; | |
313 | } | ||
314 | |||
315 |
4/6✓ Branch 0 taken 10710 times.
✓ Branch 1 taken 1238 times.
✓ Branch 2 taken 10710 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10710 times.
|
11948 | av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_pic.ptr && |
316 | s->last_pic.ptr->f->buf[0])); | ||
317 | |||
318 | 11948 | return 0; | |
319 | } | ||
320 | |||
321 | /** | ||
322 | * generic function called after decoding | ||
323 | * the header and before a frame is decoded. | ||
324 | */ | ||
325 | 11238 | int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) | |
326 | { | ||
327 | int ret; | ||
328 | |||
329 | 11238 | s->mb_skipped = 0; | |
330 | |||
331 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 11238 times.
|
11238 | if (!ff_thread_can_start_frame(avctx)) { |
332 | ✗ | av_log(avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n"); | |
333 | ✗ | return AVERROR_BUG; | |
334 | } | ||
335 | |||
336 | 11238 | ff_mpv_unref_picture(&s->cur_pic); | |
337 | 11238 | ret = alloc_picture(s, &s->cur_pic, | |
338 |
3/4✓ Branch 0 taken 8567 times.
✓ Branch 1 taken 2671 times.
✓ Branch 2 taken 8567 times.
✗ Branch 3 not taken.
|
11238 | s->pict_type != AV_PICTURE_TYPE_B && !s->droppable); |
339 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11238 times.
|
11238 | if (ret < 0) |
340 | ✗ | return ret; | |
341 | |||
342 |
2/2✓ Branch 0 taken 779 times.
✓ Branch 1 taken 10459 times.
|
11238 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first; |
343 | 22476 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * | |
344 |
3/4✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 8753 times.
✓ Branch 2 taken 2485 times.
✗ Branch 3 not taken.
|
11238 | (!s->progressive_frame && !s->progressive_sequence); |
345 | 11238 | s->cur_pic.ptr->field_picture = s->picture_structure != PICT_FRAME; | |
346 | |||
347 | 11238 | s->cur_pic.ptr->f->pict_type = s->pict_type; | |
348 |
2/2✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 10000 times.
|
11238 | if (s->pict_type == AV_PICTURE_TYPE_I) |
349 | 1238 | s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_KEY; | |
350 | else | ||
351 | 10000 | s->cur_pic.ptr->f->flags &= ~AV_FRAME_FLAG_KEY; | |
352 | |||
353 |
2/2✓ Branch 0 taken 8567 times.
✓ Branch 1 taken 2671 times.
|
11238 | if (s->pict_type != AV_PICTURE_TYPE_B) { |
354 | 8567 | ff_mpv_workpic_from_pic(&s->last_pic, s->next_pic.ptr); | |
355 |
1/2✓ Branch 0 taken 8567 times.
✗ Branch 1 not taken.
|
8567 | if (!s->droppable) |
356 | 8567 | ff_mpv_workpic_from_pic(&s->next_pic, s->cur_pic.ptr); | |
357 | } | ||
358 | ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", | ||
359 | (void*)s->last_pic.ptr, (void*)s->next_pic.ptr, (void*)s->cur_pic.ptr, | ||
360 | s->last_pic.ptr ? s->last_pic.ptr->f->data[0] : NULL, | ||
361 | s->next_pic.ptr ? s->next_pic.ptr->f->data[0] : NULL, | ||
362 | s->cur_pic.ptr ? s->cur_pic.ptr->f->data[0] : NULL, | ||
363 | s->pict_type, s->droppable); | ||
364 | |||
365 | 11238 | ret = ff_mpv_alloc_dummy_frames(s); | |
366 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11238 times.
|
11238 | if (ret < 0) |
367 | ✗ | return ret; | |
368 | |||
369 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11238 times.
|
11238 | if (s->avctx->debug & FF_DEBUG_NOMC) |
370 | ✗ | color_frame(s->cur_pic.ptr->f, 0x80); | |
371 | |||
372 | 11238 | return 0; | |
373 | } | ||
374 | |||
375 | /* called after a frame has been decoded. */ | ||
376 | 11238 | void ff_mpv_frame_end(MpegEncContext *s) | |
377 | { | ||
378 | 11238 | emms_c(); | |
379 | |||
380 |
2/2✓ Branch 0 taken 8567 times.
✓ Branch 1 taken 2671 times.
|
11238 | if (s->cur_pic.reference) |
381 | 8567 | ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX); | |
382 | 11238 | } | |
383 | |||
384 | 11040 | void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict) | |
385 | { | ||
386 | 11040 | ff_print_debug_info2(s->avctx, pict, p->mb_type, | |
387 | 11040 | p->qscale_table, p->motion_val, | |
388 | 11040 | p->mb_width, p->mb_height, p->mb_stride, s->quarter_sample); | |
389 | 11040 | } | |
390 | |||
391 | 10268 | int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, | |
392 | const MPVPicture *p, int qp_type) | ||
393 | { | ||
394 | AVVideoEncParams *par; | ||
395 |
2/2✓ Branch 0 taken 6431 times.
✓ Branch 1 taken 3837 times.
|
10268 | int mult = (qp_type == FF_MPV_QSCALE_TYPE_MPEG1) ? 2 : 1; |
396 | 10268 | unsigned int nb_mb = p->mb_height * p->mb_width; | |
397 | |||
398 |
2/2✓ Branch 0 taken 10226 times.
✓ Branch 1 taken 42 times.
|
10268 | if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS)) |
399 | 10226 | return 0; | |
400 | |||
401 | 42 | par = av_video_enc_params_create_side_data(f, AV_VIDEO_ENC_PARAMS_MPEG2, nb_mb); | |
402 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
|
42 | if (!par) |
403 | ✗ | return AVERROR(ENOMEM); | |
404 | |||
405 |
2/2✓ Branch 0 taken 756 times.
✓ Branch 1 taken 42 times.
|
798 | for (unsigned y = 0; y < p->mb_height; y++) |
406 |
2/2✓ Branch 0 taken 16632 times.
✓ Branch 1 taken 756 times.
|
17388 | for (unsigned x = 0; x < p->mb_width; x++) { |
407 | 16632 | const unsigned int block_idx = y * p->mb_width + x; | |
408 | 16632 | const unsigned int mb_xy = y * p->mb_stride + x; | |
409 | 16632 | AVVideoBlockParams *const b = av_video_enc_params_block(par, block_idx); | |
410 | |||
411 | 16632 | b->src_x = x * 16; | |
412 | 16632 | b->src_y = y * 16; | |
413 | 16632 | b->w = 16; | |
414 | 16632 | b->h = 16; | |
415 | |||
416 | 16632 | b->delta_qp = p->qscale_table[mb_xy] * mult; | |
417 | } | ||
418 | |||
419 | 42 | return 0; | |
420 | } | ||
421 | |||
422 | 170482 | void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h) | |
423 | { | ||
424 | 170482 | ff_draw_horiz_band(s->avctx, s->cur_pic.ptr->f, | |
425 |
2/2✓ Branch 0 taken 167023 times.
✓ Branch 1 taken 3459 times.
|
170482 | s->last_pic.ptr ? s->last_pic.ptr->f : NULL, |
426 | y, h, s->picture_structure, | ||
427 | s->first_field, s->low_delay); | ||
428 | 170482 | } | |
429 | |||
430 | 82 | void ff_mpeg_flush(AVCodecContext *avctx) | |
431 | { | ||
432 | 82 | MpegEncContext *const s = avctx->priv_data; | |
433 | |||
434 | 82 | ff_mpv_unref_picture(&s->cur_pic); | |
435 | 82 | ff_mpv_unref_picture(&s->last_pic); | |
436 | 82 | ff_mpv_unref_picture(&s->next_pic); | |
437 | |||
438 | 82 | s->mb_x = s->mb_y = 0; | |
439 | |||
440 | 82 | s->pp_time = 0; | |
441 | 82 | } | |
442 | |||
443 | 170482 | void ff_mpv_report_decode_progress(MpegEncContext *s) | |
444 | { | ||
445 |
5/6✓ Branch 0 taken 130728 times.
✓ Branch 1 taken 39754 times.
✓ Branch 2 taken 124145 times.
✓ Branch 3 taken 6583 times.
✓ Branch 4 taken 124145 times.
✗ Branch 5 not taken.
|
170482 | if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) |
446 | 124145 | ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y); | |
447 | 170482 | } | |
448 | |||
449 | |||
450 | 126300 | static inline int hpel_motion_lowres(MpegEncContext *s, | |
451 | uint8_t *dest, const uint8_t *src, | ||
452 | int field_based, int field_select, | ||
453 | int src_x, int src_y, | ||
454 | int width, int height, ptrdiff_t stride, | ||
455 | int h_edge_pos, int v_edge_pos, | ||
456 | int w, int h, const h264_chroma_mc_func *pix_op, | ||
457 | int motion_x, int motion_y) | ||
458 | { | ||
459 | 126300 | const int lowres = s->avctx->lowres; | |
460 | 126300 | const int op_index = lowres; | |
461 | 126300 | const int s_mask = (2 << lowres) - 1; | |
462 | 126300 | int emu = 0; | |
463 | int sx, sy; | ||
464 | |||
465 | av_assert2(op_index <= 3); | ||
466 | |||
467 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 126300 times.
|
126300 | if (s->quarter_sample) { |
468 | ✗ | motion_x /= 2; | |
469 | ✗ | motion_y /= 2; | |
470 | } | ||
471 | |||
472 | 126300 | sx = motion_x & s_mask; | |
473 | 126300 | sy = motion_y & s_mask; | |
474 | 126300 | src_x += motion_x >> lowres + 1; | |
475 | 126300 | src_y += motion_y >> lowres + 1; | |
476 | |||
477 | 126300 | src += src_y * stride + src_x; | |
478 | |||
479 |
1/2✓ Branch 0 taken 126300 times.
✗ Branch 1 not taken.
|
126300 | if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w, 0) || |
480 |
2/2✓ Branch 0 taken 298 times.
✓ Branch 1 taken 126002 times.
|
126300 | (unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) { |
481 | 298 | s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, | |
482 | s->linesize, s->linesize, | ||
483 | 298 | w + 1, (h + 1) << field_based, | |
484 | src_x, src_y * (1 << field_based), | ||
485 | h_edge_pos, v_edge_pos); | ||
486 | 298 | src = s->sc.edge_emu_buffer; | |
487 | 298 | emu = 1; | |
488 | } | ||
489 | |||
490 | 126300 | sx = (sx << 2) >> lowres; | |
491 | 126300 | sy = (sy << 2) >> lowres; | |
492 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 126300 times.
|
126300 | if (field_select) |
493 | ✗ | src += s->linesize; | |
494 | 126300 | pix_op[op_index](dest, src, stride, h, sx, sy); | |
495 | 126300 | return emu; | |
496 | } | ||
497 | |||
498 | /* apply one mpeg motion vector to the three components */ | ||
499 | 24814 | static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, | |
500 | uint8_t *dest_y, | ||
501 | uint8_t *dest_cb, | ||
502 | uint8_t *dest_cr, | ||
503 | int field_based, | ||
504 | int bottom_field, | ||
505 | int field_select, | ||
506 | uint8_t *const *ref_picture, | ||
507 | const h264_chroma_mc_func *pix_op, | ||
508 | int motion_x, int motion_y, | ||
509 | int h, int mb_y) | ||
510 | { | ||
511 | const uint8_t *ptr_y, *ptr_cb, *ptr_cr; | ||
512 | int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy; | ||
513 | ptrdiff_t uvlinesize, linesize; | ||
514 | 24814 | const int lowres = s->avctx->lowres; | |
515 | 24814 | const int op_index = lowres - 1 + s->chroma_x_shift; | |
516 | 24814 | const int block_s = 8 >> lowres; | |
517 | 24814 | const int s_mask = (2 << lowres) - 1; | |
518 | 24814 | const int h_edge_pos = s->h_edge_pos >> lowres; | |
519 | 24814 | const int v_edge_pos = s->v_edge_pos >> lowres; | |
520 |
1/2✓ Branch 0 taken 24814 times.
✗ Branch 1 not taken.
|
24814 | int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; |
521 | |||
522 | av_assert2(op_index <= 3); | ||
523 | |||
524 | 24814 | linesize = s->cur_pic.linesize[0] << field_based; | |
525 | 24814 | uvlinesize = s->cur_pic.linesize[1] << field_based; | |
526 | |||
527 | // FIXME obviously not perfect but qpel will not work in lowres anyway | ||
528 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24814 times.
|
24814 | if (s->quarter_sample) { |
529 | ✗ | motion_x /= 2; | |
530 | ✗ | motion_y /= 2; | |
531 | } | ||
532 | |||
533 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24814 times.
|
24814 | if (field_based) { |
534 | ✗ | motion_y += (bottom_field - field_select)*((1 << lowres)-1); | |
535 | } | ||
536 | |||
537 | 24814 | sx = motion_x & s_mask; | |
538 | 24814 | sy = motion_y & s_mask; | |
539 | 24814 | src_x = s->mb_x * 2 * block_s + (motion_x >> lowres + 1); | |
540 | 24814 | src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1); | |
541 | |||
542 |
1/2✓ Branch 0 taken 24814 times.
✗ Branch 1 not taken.
|
24814 | if (s->out_format == FMT_H263) { |
543 | 24814 | uvsx = ((motion_x >> 1) & s_mask) | (sx & 1); | |
544 | 24814 | uvsy = ((motion_y >> 1) & s_mask) | (sy & 1); | |
545 | 24814 | uvsrc_x = src_x >> 1; | |
546 | 24814 | uvsrc_y = src_y >> 1; | |
547 | ✗ | } else if (s->out_format == FMT_H261) { | |
548 | // even chroma mv's are full pel in H261 | ||
549 | ✗ | mx = motion_x / 4; | |
550 | ✗ | my = motion_y / 4; | |
551 | ✗ | uvsx = (2 * mx) & s_mask; | |
552 | ✗ | uvsy = (2 * my) & s_mask; | |
553 | ✗ | uvsrc_x = s->mb_x * block_s + (mx >> lowres); | |
554 | ✗ | uvsrc_y = mb_y * block_s + (my >> lowres); | |
555 | } else { | ||
556 | ✗ | if (s->chroma_y_shift) { | |
557 | ✗ | mx = motion_x / 2; | |
558 | ✗ | my = motion_y / 2; | |
559 | ✗ | uvsx = mx & s_mask; | |
560 | ✗ | uvsy = my & s_mask; | |
561 | ✗ | uvsrc_x = s->mb_x * block_s + (mx >> lowres + 1); | |
562 | ✗ | uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1); | |
563 | } else { | ||
564 | ✗ | if (s->chroma_x_shift) { | |
565 | //Chroma422 | ||
566 | ✗ | mx = motion_x / 2; | |
567 | ✗ | uvsx = mx & s_mask; | |
568 | ✗ | uvsy = motion_y & s_mask; | |
569 | ✗ | uvsrc_y = src_y; | |
570 | ✗ | uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1)); | |
571 | } else { | ||
572 | //Chroma444 | ||
573 | ✗ | uvsx = motion_x & s_mask; | |
574 | ✗ | uvsy = motion_y & s_mask; | |
575 | ✗ | uvsrc_x = src_x; | |
576 | ✗ | uvsrc_y = src_y; | |
577 | } | ||
578 | } | ||
579 | } | ||
580 | |||
581 | 24814 | ptr_y = ref_picture[0] + src_y * linesize + src_x; | |
582 | 24814 | ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; | |
583 | 24814 | ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; | |
584 | |||
585 |
3/4✓ Branch 0 taken 24814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24712 times.
✓ Branch 3 taken 102 times.
|
24814 | if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 || |
586 |
2/2✓ Branch 0 taken 95 times.
✓ Branch 1 taken 24617 times.
|
24712 | (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - FFMAX(h, hc<<s->chroma_y_shift), 0)) { |
587 | 197 | s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, | |
588 | linesize >> field_based, linesize >> field_based, | ||
589 | 17, 17 + field_based, | ||
590 | src_x, src_y * (1 << field_based), h_edge_pos, | ||
591 | v_edge_pos); | ||
592 | 197 | ptr_y = s->sc.edge_emu_buffer; | |
593 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | ||
594 | 197 | uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; | |
595 | 197 | uint8_t *vbuf =ubuf + 10 * s->uvlinesize; | |
596 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 197 times.
|
197 | if (s->workaround_bugs & FF_BUG_IEDGE) |
597 | ✗ | vbuf -= s->uvlinesize; | |
598 | 197 | s->vdsp.emulated_edge_mc(ubuf, ptr_cb, | |
599 | uvlinesize >> field_based, uvlinesize >> field_based, | ||
600 | 9, 9 + field_based, | ||
601 | uvsrc_x, uvsrc_y * (1 << field_based), | ||
602 | h_edge_pos >> 1, v_edge_pos >> 1); | ||
603 | 197 | s->vdsp.emulated_edge_mc(vbuf, ptr_cr, | |
604 | uvlinesize >> field_based,uvlinesize >> field_based, | ||
605 | 9, 9 + field_based, | ||
606 | uvsrc_x, uvsrc_y * (1 << field_based), | ||
607 | h_edge_pos >> 1, v_edge_pos >> 1); | ||
608 | 197 | ptr_cb = ubuf; | |
609 | 197 | ptr_cr = vbuf; | |
610 | } | ||
611 | } | ||
612 | |||
613 | // FIXME use this for field pix too instead of the obnoxious hack which changes picture.f->data | ||
614 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24814 times.
|
24814 | if (bottom_field) { |
615 | ✗ | dest_y += s->linesize; | |
616 | ✗ | dest_cb += s->uvlinesize; | |
617 | ✗ | dest_cr += s->uvlinesize; | |
618 | } | ||
619 | |||
620 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24814 times.
|
24814 | if (field_select) { |
621 | ✗ | ptr_y += s->linesize; | |
622 | ✗ | ptr_cb += s->uvlinesize; | |
623 | ✗ | ptr_cr += s->uvlinesize; | |
624 | } | ||
625 | |||
626 | 24814 | sx = (sx << 2) >> lowres; | |
627 | 24814 | sy = (sy << 2) >> lowres; | |
628 | 24814 | pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy); | |
629 | |||
630 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | ||
631 | 24814 | uvsx = (uvsx << 2) >> lowres; | |
632 | 24814 | uvsy = (uvsy << 2) >> lowres; | |
633 |
1/2✓ Branch 0 taken 24814 times.
✗ Branch 1 not taken.
|
24814 | if (hc) { |
634 | 24814 | pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy); | |
635 | 24814 | pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy); | |
636 | } | ||
637 | } | ||
638 | // FIXME h261 lowres loop filter | ||
639 | 24814 | } | |
640 | |||
641 | 31575 | static inline void chroma_4mv_motion_lowres(MpegEncContext *s, | |
642 | uint8_t *dest_cb, uint8_t *dest_cr, | ||
643 | uint8_t *const *ref_picture, | ||
644 | const h264_chroma_mc_func * pix_op, | ||
645 | int mx, int my) | ||
646 | { | ||
647 | 31575 | const int lowres = s->avctx->lowres; | |
648 | 31575 | const int op_index = lowres; | |
649 | 31575 | const int block_s = 8 >> lowres; | |
650 | 31575 | const int s_mask = (2 << lowres) - 1; | |
651 | 31575 | const int h_edge_pos = s->h_edge_pos >> lowres + 1; | |
652 | 31575 | const int v_edge_pos = s->v_edge_pos >> lowres + 1; | |
653 | 31575 | int emu = 0, src_x, src_y, sx, sy; | |
654 | ptrdiff_t offset; | ||
655 | const uint8_t *ptr; | ||
656 | |||
657 | av_assert2(op_index <= 3); | ||
658 | |||
659 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 31575 times.
|
31575 | if (s->quarter_sample) { |
660 | ✗ | mx /= 2; | |
661 | ✗ | my /= 2; | |
662 | } | ||
663 | |||
664 | /* In case of 8X8, we construct a single chroma motion vector | ||
665 | with a special rounding */ | ||
666 | 31575 | mx = ff_h263_round_chroma(mx); | |
667 | 31575 | my = ff_h263_round_chroma(my); | |
668 | |||
669 | 31575 | sx = mx & s_mask; | |
670 | 31575 | sy = my & s_mask; | |
671 | 31575 | src_x = s->mb_x * block_s + (mx >> lowres + 1); | |
672 | 31575 | src_y = s->mb_y * block_s + (my >> lowres + 1); | |
673 | |||
674 | 31575 | offset = src_y * s->uvlinesize + src_x; | |
675 | 31575 | ptr = ref_picture[1] + offset; | |
676 |
1/2✓ Branch 0 taken 31575 times.
✗ Branch 1 not taken.
|
31575 | if ((unsigned) src_x > FFMAX(h_edge_pos - (!!sx) - block_s, 0) || |
677 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 31431 times.
|
31575 | (unsigned) src_y > FFMAX(v_edge_pos - (!!sy) - block_s, 0)) { |
678 | 144 | s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr, | |
679 | s->uvlinesize, s->uvlinesize, | ||
680 | 9, 9, | ||
681 | src_x, src_y, h_edge_pos, v_edge_pos); | ||
682 | 144 | ptr = s->sc.edge_emu_buffer; | |
683 | 144 | emu = 1; | |
684 | } | ||
685 | 31575 | sx = (sx << 2) >> lowres; | |
686 | 31575 | sy = (sy << 2) >> lowres; | |
687 | 31575 | pix_op[op_index](dest_cb, ptr, s->uvlinesize, block_s, sx, sy); | |
688 | |||
689 | 31575 | ptr = ref_picture[2] + offset; | |
690 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 31431 times.
|
31575 | if (emu) { |
691 | 144 | s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr, | |
692 | s->uvlinesize, s->uvlinesize, | ||
693 | 9, 9, | ||
694 | src_x, src_y, h_edge_pos, v_edge_pos); | ||
695 | 144 | ptr = s->sc.edge_emu_buffer; | |
696 | } | ||
697 | 31575 | pix_op[op_index](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); | |
698 | 31575 | } | |
699 | |||
700 | /** | ||
701 | * motion compensation of a single macroblock | ||
702 | * @param s context | ||
703 | * @param dest_y luma destination pointer | ||
704 | * @param dest_cb chroma cb/u destination pointer | ||
705 | * @param dest_cr chroma cr/v destination pointer | ||
706 | * @param dir direction (0->forward, 1->backward) | ||
707 | * @param ref_picture array[3] of pointers to the 3 planes of the reference picture | ||
708 | * @param pix_op halfpel motion compensation function (average or put normally) | ||
709 | * the motion vectors are taken from s->mv and the MV type from s->mv_type | ||
710 | */ | ||
711 | 56389 | static inline void MPV_motion_lowres(MpegEncContext *s, | |
712 | uint8_t *dest_y, uint8_t *dest_cb, | ||
713 | uint8_t *dest_cr, | ||
714 | int dir, uint8_t *const *ref_picture, | ||
715 | const h264_chroma_mc_func *pix_op) | ||
716 | { | ||
717 | int mx, my; | ||
718 | int mb_x, mb_y; | ||
719 | 56389 | const int lowres = s->avctx->lowres; | |
720 | 56389 | const int block_s = 8 >>lowres; | |
721 | |||
722 | 56389 | mb_x = s->mb_x; | |
723 | 56389 | mb_y = s->mb_y; | |
724 | |||
725 |
2/6✓ Branch 0 taken 24814 times.
✓ Branch 1 taken 31575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
56389 | switch (s->mv_type) { |
726 | 24814 | case MV_TYPE_16X16: | |
727 | 24814 | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
728 | 0, 0, 0, | ||
729 | ref_picture, pix_op, | ||
730 | s->mv[dir][0][0], s->mv[dir][0][1], | ||
731 | 2 * block_s, mb_y); | ||
732 | 24814 | break; | |
733 | 31575 | case MV_TYPE_8X8: | |
734 | 31575 | mx = 0; | |
735 | 31575 | my = 0; | |
736 |
2/2✓ Branch 0 taken 126300 times.
✓ Branch 1 taken 31575 times.
|
157875 | for (int i = 0; i < 4; i++) { |
737 | 126300 | hpel_motion_lowres(s, dest_y + ((i & 1) + (i >> 1) * | |
738 | 126300 | s->linesize) * block_s, | |
739 | ref_picture[0], 0, 0, | ||
740 | 126300 | (2 * mb_x + (i & 1)) * block_s, | |
741 | 126300 | (2 * mb_y + (i >> 1)) * block_s, | |
742 | s->width, s->height, s->linesize, | ||
743 | 126300 | s->h_edge_pos >> lowres, s->v_edge_pos >> lowres, | |
744 | block_s, block_s, pix_op, | ||
745 | s->mv[dir][i][0], s->mv[dir][i][1]); | ||
746 | |||
747 | 126300 | mx += s->mv[dir][i][0]; | |
748 | 126300 | my += s->mv[dir][i][1]; | |
749 | } | ||
750 | |||
751 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) | ||
752 | 31575 | chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture, | |
753 | pix_op, mx, my); | ||
754 | 31575 | break; | |
755 | ✗ | case MV_TYPE_FIELD: | |
756 | ✗ | if (s->picture_structure == PICT_FRAME) { | |
757 | /* top field */ | ||
758 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
759 | 1, 0, s->field_select[dir][0], | ||
760 | ref_picture, pix_op, | ||
761 | s->mv[dir][0][0], s->mv[dir][0][1], | ||
762 | block_s, mb_y); | ||
763 | /* bottom field */ | ||
764 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
765 | 1, 1, s->field_select[dir][1], | ||
766 | ref_picture, pix_op, | ||
767 | s->mv[dir][1][0], s->mv[dir][1][1], | ||
768 | block_s, mb_y); | ||
769 | } else { | ||
770 | ✗ | if (s->picture_structure != s->field_select[dir][0] + 1 && | |
771 | ✗ | s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { | |
772 | ✗ | ref_picture = s->cur_pic.ptr->f->data; | |
773 | } | ||
774 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
775 | 0, 0, s->field_select[dir][0], | ||
776 | ref_picture, pix_op, | ||
777 | s->mv[dir][0][0], | ||
778 | s->mv[dir][0][1], 2 * block_s, mb_y >> 1); | ||
779 | } | ||
780 | ✗ | break; | |
781 | ✗ | case MV_TYPE_16X8: | |
782 | ✗ | for (int i = 0; i < 2; i++) { | |
783 | uint8_t *const *ref2picture; | ||
784 | |||
785 | ✗ | if (s->picture_structure == s->field_select[dir][i] + 1 || | |
786 | ✗ | s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { | |
787 | ✗ | ref2picture = ref_picture; | |
788 | } else { | ||
789 | ✗ | ref2picture = s->cur_pic.ptr->f->data; | |
790 | } | ||
791 | |||
792 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
793 | 0, 0, s->field_select[dir][i], | ||
794 | ref2picture, pix_op, | ||
795 | ✗ | s->mv[dir][i][0], s->mv[dir][i][1] + | |
796 | ✗ | 2 * block_s * i, block_s, mb_y >> 1); | |
797 | |||
798 | ✗ | dest_y += 2 * block_s * s->linesize; | |
799 | ✗ | dest_cb += (2 * block_s >> s->chroma_y_shift) * s->uvlinesize; | |
800 | ✗ | dest_cr += (2 * block_s >> s->chroma_y_shift) * s->uvlinesize; | |
801 | } | ||
802 | ✗ | break; | |
803 | ✗ | case MV_TYPE_DMV: | |
804 | ✗ | if (s->picture_structure == PICT_FRAME) { | |
805 | ✗ | for (int i = 0; i < 2; i++) { | |
806 | ✗ | for (int j = 0; j < 2; j++) { | |
807 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
808 | 1, j, j ^ i, | ||
809 | ref_picture, pix_op, | ||
810 | ✗ | s->mv[dir][2 * i + j][0], | |
811 | ✗ | s->mv[dir][2 * i + j][1], | |
812 | block_s, mb_y); | ||
813 | } | ||
814 | ✗ | pix_op = s->h264chroma.avg_h264_chroma_pixels_tab; | |
815 | } | ||
816 | } else { | ||
817 | ✗ | for (int i = 0; i < 2; i++) { | |
818 | ✗ | mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | |
819 | ✗ | 0, 0, s->picture_structure != i + 1, | |
820 | ref_picture, pix_op, | ||
821 | ✗ | s->mv[dir][2 * i][0],s->mv[dir][2 * i][1], | |
822 | 2 * block_s, mb_y >> 1); | ||
823 | |||
824 | // after put we make avg of the same block | ||
825 | ✗ | pix_op = s->h264chroma.avg_h264_chroma_pixels_tab; | |
826 | |||
827 | // opposite parity is always in the same | ||
828 | // frame if this is second field | ||
829 | ✗ | if (!s->first_field) { | |
830 | ✗ | ref_picture = s->cur_pic.ptr->f->data; | |
831 | } | ||
832 | } | ||
833 | } | ||
834 | ✗ | break; | |
835 | 56389 | default: | |
836 | av_assert2(0); | ||
837 | } | ||
838 | 56389 | } | |
839 | |||
840 | /** | ||
841 | * find the lowest MB row referenced in the MVs | ||
842 | */ | ||
843 | 60133 | static int lowest_referenced_row(MpegEncContext *s, int dir) | |
844 | { | ||
845 | 60133 | int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample; | |
846 | int off, mvs; | ||
847 | |||
848 |
2/4✓ Branch 0 taken 60133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60133 times.
|
60133 | if (s->picture_structure != PICT_FRAME || s->mcsel) |
849 | ✗ | goto unhandled; | |
850 | |||
851 |
1/4✓ Branch 0 taken 60133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
60133 | switch (s->mv_type) { |
852 | 60133 | case MV_TYPE_16X16: | |
853 | 60133 | mvs = 1; | |
854 | 60133 | break; | |
855 | ✗ | case MV_TYPE_16X8: | |
856 | ✗ | mvs = 2; | |
857 | ✗ | break; | |
858 | ✗ | case MV_TYPE_8X8: | |
859 | ✗ | mvs = 4; | |
860 | ✗ | break; | |
861 | ✗ | default: | |
862 | ✗ | goto unhandled; | |
863 | } | ||
864 | |||
865 |
2/2✓ Branch 0 taken 60133 times.
✓ Branch 1 taken 60133 times.
|
120266 | for (int i = 0; i < mvs; i++) { |
866 | 60133 | int my = s->mv[dir][i][1]; | |
867 | 60133 | my_max = FFMAX(my_max, my); | |
868 | 60133 | my_min = FFMIN(my_min, my); | |
869 | } | ||
870 | |||
871 | 60133 | off = ((FFMAX(-my_min, my_max) << qpel_shift) + 63) >> 6; | |
872 | |||
873 | 60133 | return av_clip(s->mb_y + off, 0, s->mb_height - 1); | |
874 | ✗ | unhandled: | |
875 | ✗ | return s->mb_height - 1; | |
876 | } | ||
877 | |||
878 | /* add block[] to dest[] */ | ||
879 | 23124786 | static inline void add_dct(MpegEncContext *s, | |
880 | int16_t *block, int i, uint8_t *dest, int line_size) | ||
881 | { | ||
882 |
2/2✓ Branch 0 taken 8334107 times.
✓ Branch 1 taken 14790679 times.
|
23124786 | if (s->block_last_index[i] >= 0) { |
883 | 8334107 | s->idsp.idct_add(dest, line_size, block); | |
884 | } | ||
885 | 23124786 | } | |
886 | |||
887 | /* put block[] to dest[] */ | ||
888 | 1756434 | static inline void put_dct(MpegEncContext *s, | |
889 | int16_t *block, int i, uint8_t *dest, int line_size, int qscale) | ||
890 | { | ||
891 | 1756434 | s->dct_unquantize_intra(s, block, i, qscale); | |
892 | 1756434 | s->idsp.idct_put(dest, line_size, block); | |
893 | 1756434 | } | |
894 | |||
895 | 2942796 | static inline void add_dequant_dct(MpegEncContext *s, | |
896 | int16_t *block, int i, uint8_t *dest, int line_size, int qscale) | ||
897 | { | ||
898 |
2/2✓ Branch 0 taken 1108259 times.
✓ Branch 1 taken 1834537 times.
|
2942796 | if (s->block_last_index[i] >= 0) { |
899 | 1108259 | s->dct_unquantize_inter(s, block, i, qscale); | |
900 | |||
901 | 1108259 | s->idsp.idct_add(dest, line_size, block); | |
902 | } | ||
903 | 2942796 | } | |
904 | |||
905 | #define NOT_MPEG12_H261 0 | ||
906 | #define MAY_BE_MPEG12_H261 1 | ||
907 | #define DEFINITELY_MPEG12_H261 2 | ||
908 | |||
909 | /* generic function called after a macroblock has been parsed by the decoder. | ||
910 | |||
911 | Important variables used: | ||
912 | s->mb_intra : true if intra macroblock | ||
913 | s->mv_dir : motion vector direction | ||
914 | s->mv_type : motion vector type | ||
915 | s->mv : motion vector | ||
916 | s->interlaced_dct : true if interlaced dct used (mpeg2) | ||
917 | */ | ||
918 | static av_always_inline | ||
919 | 5145058 | void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], | |
920 | int lowres_flag, int is_mpeg12) | ||
921 | { | ||
922 | #define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12) | ||
923 | 5145058 | uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2]; | |
924 | int dct_linesize, dct_offset; | ||
925 | 5145058 | const int linesize = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics | |
926 | 5145058 | const int uvlinesize = s->cur_pic.linesize[1]; | |
927 |
2/2✓ Branch 0 taken 43500 times.
✓ Branch 1 taken 5101558 times.
|
5145058 | const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8; |
928 | |||
929 | 5145058 | dct_linesize = linesize << s->interlaced_dct; | |
930 |
2/2✓ Branch 0 taken 4961915 times.
✓ Branch 1 taken 183143 times.
|
5145058 | dct_offset = s->interlaced_dct ? linesize : linesize * block_size; |
931 | |||
932 |
2/2✓ Branch 0 taken 4512429 times.
✓ Branch 1 taken 632629 times.
|
5145058 | if (!s->mb_intra) { |
933 | /* motion handling */ | ||
934 |
2/2✓ Branch 0 taken 2130089 times.
✓ Branch 1 taken 2382340 times.
|
4512429 | if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 && |
935 |
2/2✓ Branch 0 taken 60133 times.
✓ Branch 1 taken 2069956 times.
|
2130089 | s->avctx->active_thread_type & FF_THREAD_FRAME) { |
936 |
1/2✓ Branch 0 taken 60133 times.
✗ Branch 1 not taken.
|
60133 | if (s->mv_dir & MV_DIR_FORWARD) { |
937 | 60133 | ff_thread_progress_await(&s->last_pic.ptr->progress, | |
938 | lowest_referenced_row(s, 0)); | ||
939 | } | ||
940 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60133 times.
|
60133 | if (s->mv_dir & MV_DIR_BACKWARD) { |
941 | ✗ | ff_thread_progress_await(&s->next_pic.ptr->progress, | |
942 | lowest_referenced_row(s, 1)); | ||
943 | } | ||
944 | } | ||
945 | |||
946 |
2/2✓ Branch 0 taken 41123 times.
✓ Branch 1 taken 4471306 times.
|
4512429 | if (lowres_flag) { |
947 | 41123 | const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab; | |
948 | |||
949 |
2/2✓ Branch 0 taken 37429 times.
✓ Branch 1 taken 3694 times.
|
41123 | if (s->mv_dir & MV_DIR_FORWARD) { |
950 | 37429 | MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix); | |
951 | 37429 | op_pix = s->h264chroma.avg_h264_chroma_pixels_tab; | |
952 | } | ||
953 |
2/2✓ Branch 0 taken 18960 times.
✓ Branch 1 taken 22163 times.
|
41123 | if (s->mv_dir & MV_DIR_BACKWARD) { |
954 | 18960 | MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix); | |
955 | } | ||
956 | } else { | ||
957 | const op_pixels_func (*op_pix)[4]; | ||
958 | const qpel_mc_func (*op_qpix)[16]; | ||
959 | |||
960 |
5/6✓ Branch 0 taken 2088966 times.
✓ Branch 1 taken 2382340 times.
✓ Branch 2 taken 799665 times.
✓ Branch 3 taken 1289301 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 799665 times.
|
4471306 | if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) { |
961 | 3671641 | op_pix = s->hdsp.put_pixels_tab; | |
962 | 3671641 | op_qpix = s->qdsp.put_qpel_pixels_tab; | |
963 | } else { | ||
964 | 799665 | op_pix = s->hdsp.put_no_rnd_pixels_tab; | |
965 | 799665 | op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab; | |
966 | } | ||
967 |
2/2✓ Branch 0 taken 4163985 times.
✓ Branch 1 taken 307321 times.
|
4471306 | if (s->mv_dir & MV_DIR_FORWARD) { |
968 | 4163985 | ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix); | |
969 | 4163985 | op_pix = s->hdsp.avg_pixels_tab; | |
970 | 4163985 | op_qpix = s->qdsp.avg_qpel_pixels_tab; | |
971 | } | ||
972 |
2/2✓ Branch 0 taken 936071 times.
✓ Branch 1 taken 3535235 times.
|
4471306 | if (s->mv_dir & MV_DIR_BACKWARD) { |
973 | 936071 | ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix); | |
974 | } | ||
975 | } | ||
976 | |||
977 | /* skip dequant / idct if we are really late ;) */ | ||
978 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4512429 times.
|
4512429 | if (s->avctx->skip_idct) { |
979 | ✗ | if ( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) | |
980 | ✗ | ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) | |
981 | ✗ | || s->avctx->skip_idct >= AVDISCARD_ALL) | |
982 | ✗ | return; | |
983 | } | ||
984 | |||
985 | /* add dct residue */ | ||
986 |
7/8✓ Branch 0 taken 41123 times.
✓ Branch 1 taken 4471306 times.
✓ Branch 2 taken 41123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2088966 times.
✓ Branch 5 taken 2382340 times.
✓ Branch 6 taken 1761221 times.
✓ Branch 7 taken 368868 times.
|
4512429 | if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED || |
987 |
4/4✓ Branch 0 taken 1385390 times.
✓ Branch 1 taken 375831 times.
✓ Branch 2 taken 114635 times.
✓ Branch 3 taken 1270755 times.
|
1761221 | (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) { |
988 | 490466 | add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale); | |
989 | 490466 | add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale); | |
990 | 490466 | add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); | |
991 | 490466 | add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); | |
992 | |||
993 | 490466 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | |
994 | av_assert2(s->chroma_y_shift); | ||
995 | 490466 | add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); | |
996 | 490466 | add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); | |
997 | } | ||
998 |
5/6✓ Branch 0 taken 1639623 times.
✓ Branch 1 taken 2382340 times.
✓ Branch 2 taken 1639623 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449474 times.
✓ Branch 5 taken 190149 times.
|
4021963 | } else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) { |
999 | 3831814 | add_dct(s, block[0], 0, dest_y , dct_linesize); | |
1000 | 3831814 | add_dct(s, block[1], 1, dest_y + block_size, dct_linesize); | |
1001 | 3831814 | add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize); | |
1002 | 3831814 | add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize); | |
1003 | |||
1004 | 3831814 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | |
1005 |
2/2✓ Branch 0 taken 3764863 times.
✓ Branch 1 taken 66951 times.
|
3831814 | if (s->chroma_y_shift) {//Chroma420 |
1006 | 3764863 | add_dct(s, block[4], 4, dest_cb, uvlinesize); | |
1007 | 3764863 | add_dct(s, block[5], 5, dest_cr, uvlinesize); | |
1008 | } else { | ||
1009 | //chroma422 | ||
1010 | 66951 | dct_linesize = uvlinesize << s->interlaced_dct; | |
1011 |
2/2✓ Branch 0 taken 65730 times.
✓ Branch 1 taken 1221 times.
|
66951 | dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size; |
1012 | |||
1013 | 66951 | add_dct(s, block[4], 4, dest_cb, dct_linesize); | |
1014 | 66951 | add_dct(s, block[5], 5, dest_cr, dct_linesize); | |
1015 | 66951 | add_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize); | |
1016 | 66951 | add_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize); | |
1017 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 66951 times.
|
66951 | if (!s->chroma_x_shift) {//Chroma444 |
1018 | ✗ | add_dct(s, block[8], 8, dest_cb + block_size, dct_linesize); | |
1019 | ✗ | add_dct(s, block[9], 9, dest_cr + block_size, dct_linesize); | |
1020 | ✗ | add_dct(s, block[10], 10, dest_cb + block_size + dct_offset, dct_linesize); | |
1021 | ✗ | add_dct(s, block[11], 11, dest_cr + block_size + dct_offset, dct_linesize); | |
1022 | } | ||
1023 | } | ||
1024 | } //fi gray | ||
1025 | } else if (CONFIG_WMV2_DECODER) { | ||
1026 | 190149 | ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr); | |
1027 | } | ||
1028 | } else { | ||
1029 | /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode. | ||
1030 | TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */ | ||
1031 |
2/2✓ Branch 0 taken 294089 times.
✓ Branch 1 taken 338540 times.
|
632629 | if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER && |
1032 | /* s->codec_id == AV_CODEC_ID_MPEG4 && */ | ||
1033 |
2/2✓ Branch 0 taken 1350 times.
✓ Branch 1 taken 292739 times.
|
294089 | s->avctx->bits_per_raw_sample > 8) { |
1034 | 1350 | ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size, | |
1035 | uvlinesize, dct_linesize, dct_offset); | ||
1036 |
4/4✓ Branch 0 taken 2377 times.
✓ Branch 1 taken 628902 times.
✓ Branch 2 taken 292739 times.
✓ Branch 3 taken 338540 times.
|
631279 | } else if (!IS_MPEG12_H261(s)) { |
1037 | /* dct only in intra block */ | ||
1038 | 292739 | put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale); | |
1039 | 292739 | put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale); | |
1040 | 292739 | put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); | |
1041 | 292739 | put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); | |
1042 | |||
1043 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | ||
1044 |
1/2✓ Branch 0 taken 292739 times.
✗ Branch 1 not taken.
|
292739 | if (s->chroma_y_shift) { |
1045 | 292739 | put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); | |
1046 | 292739 | put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); | |
1047 | } else { | ||
1048 | ✗ | dct_offset >>= 1; | |
1049 | ✗ | dct_linesize >>= 1; | |
1050 | ✗ | put_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale); | |
1051 | ✗ | put_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale); | |
1052 | ✗ | put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale); | |
1053 | ✗ | put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale); | |
1054 | } | ||
1055 | } | ||
1056 | } else { | ||
1057 | 338540 | s->idsp.idct_put(dest_y, dct_linesize, block[0]); | |
1058 | 338540 | s->idsp.idct_put(dest_y + block_size, dct_linesize, block[1]); | |
1059 | 338540 | s->idsp.idct_put(dest_y + dct_offset, dct_linesize, block[2]); | |
1060 | 338540 | s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]); | |
1061 | |||
1062 | if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { | ||
1063 |
2/2✓ Branch 0 taken 284381 times.
✓ Branch 1 taken 54159 times.
|
338540 | if (s->chroma_y_shift) { |
1064 | 284381 | s->idsp.idct_put(dest_cb, uvlinesize, block[4]); | |
1065 | 284381 | s->idsp.idct_put(dest_cr, uvlinesize, block[5]); | |
1066 | } else { | ||
1067 | 54159 | dct_linesize = uvlinesize << s->interlaced_dct; | |
1068 |
2/2✓ Branch 0 taken 54119 times.
✓ Branch 1 taken 40 times.
|
54159 | dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size; |
1069 | |||
1070 | 54159 | s->idsp.idct_put(dest_cb, dct_linesize, block[4]); | |
1071 | 54159 | s->idsp.idct_put(dest_cr, dct_linesize, block[5]); | |
1072 | 54159 | s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]); | |
1073 | 54159 | s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]); | |
1074 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 54159 times.
|
54159 | if (!s->chroma_x_shift) { //Chroma444 |
1075 | ✗ | s->idsp.idct_put(dest_cb + block_size, dct_linesize, block[8]); | |
1076 | ✗ | s->idsp.idct_put(dest_cr + block_size, dct_linesize, block[9]); | |
1077 | ✗ | s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]); | |
1078 | ✗ | s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]); | |
1079 | } | ||
1080 | } | ||
1081 | } //gray | ||
1082 | } | ||
1083 | } | ||
1084 | } | ||
1085 | |||
1086 | 5145058 | void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]) | |
1087 | { | ||
1088 | 5145058 | const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; | |
1089 | 5145058 | uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; | |
1090 | |||
1091 | 5145058 | s->cur_pic.qscale_table[mb_xy] = s->qscale; | |
1092 | |||
1093 | /* avoid copy if macroblock skipped in last frame too */ | ||
1094 |
2/2✓ Branch 0 taken 387772 times.
✓ Branch 1 taken 4757286 times.
|
5145058 | if (s->mb_skipped) { |
1095 | 387772 | s->mb_skipped = 0; | |
1096 | av_assert2(s->pict_type != AV_PICTURE_TYPE_I); | ||
1097 | 387772 | *mbskip_ptr = 1; | |
1098 |
2/2✓ Branch 0 taken 1130444 times.
✓ Branch 1 taken 3626842 times.
|
4757286 | } else if (!s->cur_pic.reference) { |
1099 | 1130444 | *mbskip_ptr = 1; | |
1100 | } else{ | ||
1101 | 3626842 | *mbskip_ptr = 0; /* not skipped */ | |
1102 | } | ||
1103 | |||
1104 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5145058 times.
|
5145058 | if (s->avctx->debug & FF_DEBUG_DCT_COEFF) { |
1105 | /* print DCT coefficients */ | ||
1106 | ✗ | av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y); | |
1107 | ✗ | for (int i = 0; i < 6; i++) { | |
1108 | ✗ | for (int j = 0; j < 64; j++) { | |
1109 | ✗ | av_log(s->avctx, AV_LOG_DEBUG, "%5d", | |
1110 | ✗ | block[i][s->idsp.idct_permutation[j]]); | |
1111 | } | ||
1112 | ✗ | av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
1113 | } | ||
1114 | } | ||
1115 | |||
1116 | av_assert2((s->out_format <= FMT_H261) == (s->out_format == FMT_H261 || s->out_format == FMT_MPEG1)); | ||
1117 |
2/2✓ Branch 0 taken 5101558 times.
✓ Branch 1 taken 43500 times.
|
5145058 | if (!s->avctx->lowres) { |
1118 | #if !CONFIG_SMALL | ||
1119 |
2/2✓ Branch 0 taken 2720880 times.
✓ Branch 1 taken 2380678 times.
|
5101558 | if (s->out_format <= FMT_H261) |
1120 | 2720880 | mpv_reconstruct_mb_internal(s, block, 0, DEFINITELY_MPEG12_H261); | |
1121 | else | ||
1122 | 2380678 | mpv_reconstruct_mb_internal(s, block, 0, NOT_MPEG12_H261); | |
1123 | #else | ||
1124 | mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12_H261); | ||
1125 | #endif | ||
1126 | } else | ||
1127 | 43500 | mpv_reconstruct_mb_internal(s, block, 1, MAY_BE_MPEG12_H261); | |
1128 | 5145058 | } | |
1129 |