Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * H.263 decoder | ||
3 | * Copyright (c) 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 | /** | ||
24 | * @file | ||
25 | * H.263 decoder. | ||
26 | */ | ||
27 | |||
28 | #define UNCHECKED_BITSTREAM_READER 1 | ||
29 | |||
30 | #include "config_components.h" | ||
31 | |||
32 | #include "avcodec.h" | ||
33 | #include "codec_internal.h" | ||
34 | #include "decode.h" | ||
35 | #include "error_resilience.h" | ||
36 | #include "flvdec.h" | ||
37 | #include "h263.h" | ||
38 | #include "h263dec.h" | ||
39 | #include "hwaccel_internal.h" | ||
40 | #include "hwconfig.h" | ||
41 | #include "mpeg_er.h" | ||
42 | #include "mpeg4video.h" | ||
43 | #include "mpeg4videodec.h" | ||
44 | #include "mpeg4videodefs.h" | ||
45 | #include "mpegvideo.h" | ||
46 | #include "mpegvideodec.h" | ||
47 | #include "msmpeg4dec.h" | ||
48 | #include "thread.h" | ||
49 | #include "wmv2dec.h" | ||
50 | |||
51 | static const enum AVPixelFormat h263_hwaccel_pixfmt_list_420[] = { | ||
52 | #if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL | ||
53 | AV_PIX_FMT_VAAPI, | ||
54 | #endif | ||
55 | #if CONFIG_MPEG4_NVDEC_HWACCEL | ||
56 | AV_PIX_FMT_CUDA, | ||
57 | #endif | ||
58 | #if CONFIG_MPEG4_VDPAU_HWACCEL | ||
59 | AV_PIX_FMT_VDPAU, | ||
60 | #endif | ||
61 | #if CONFIG_H263_VIDEOTOOLBOX_HWACCEL || CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL | ||
62 | AV_PIX_FMT_VIDEOTOOLBOX, | ||
63 | #endif | ||
64 | AV_PIX_FMT_YUV420P, | ||
65 | AV_PIX_FMT_NONE | ||
66 | }; | ||
67 | |||
68 | 296 | static enum AVPixelFormat h263_get_format(AVCodecContext *avctx) | |
69 | { | ||
70 | /* MPEG-4 Studio Profile only, not supported by hardware */ | ||
71 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 294 times.
|
296 | if (avctx->bits_per_raw_sample > 8) { |
72 | av_assert1(((MpegEncContext *)avctx->priv_data)->studio_profile); | ||
73 | 2 | return avctx->pix_fmt; | |
74 | } | ||
75 | |||
76 | if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) { | ||
77 | if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED) | ||
78 | avctx->color_range = AVCOL_RANGE_MPEG; | ||
79 | return AV_PIX_FMT_GRAY8; | ||
80 | } | ||
81 | |||
82 |
2/2✓ Branch 0 taken 274 times.
✓ Branch 1 taken 20 times.
|
294 | if (avctx->codec_id == AV_CODEC_ID_H263 || |
83 |
1/2✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
|
274 | avctx->codec_id == AV_CODEC_ID_H263P || |
84 |
2/2✓ Branch 0 taken 197 times.
✓ Branch 1 taken 77 times.
|
274 | avctx->codec_id == AV_CODEC_ID_MPEG4) |
85 | 217 | return avctx->pix_fmt = ff_get_format(avctx, h263_hwaccel_pixfmt_list_420); | |
86 | |||
87 | 77 | return AV_PIX_FMT_YUV420P; | |
88 | } | ||
89 | |||
90 | 264 | av_cold int ff_h263_decode_init(AVCodecContext *avctx) | |
91 | { | ||
92 | 264 | MpegEncContext *s = avctx->priv_data; | |
93 | int ret; | ||
94 | |||
95 | 264 | s->out_format = FMT_H263; | |
96 | |||
97 | // set defaults | ||
98 | 264 | ff_mpv_decode_init(s, avctx); | |
99 | |||
100 | 264 | s->quant_precision = 5; | |
101 | 264 | s->decode_mb = ff_h263_decode_mb; | |
102 | 264 | s->low_delay = 1; | |
103 | |||
104 | /* select sub codec */ | ||
105 |
8/10✓ Branch 0 taken 20 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
|
264 | switch (avctx->codec->id) { |
106 | 20 | case AV_CODEC_ID_H263: | |
107 | case AV_CODEC_ID_H263P: | ||
108 | 20 | avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; | |
109 | 20 | break; | |
110 | 179 | case AV_CODEC_ID_MPEG4: | |
111 | 179 | break; | |
112 | 2 | case AV_CODEC_ID_MSMPEG4V1: | |
113 | 2 | s->h263_pred = 1; | |
114 | 2 | s->msmpeg4_version = 1; | |
115 | 2 | break; | |
116 | 9 | case AV_CODEC_ID_MSMPEG4V2: | |
117 | 9 | s->h263_pred = 1; | |
118 | 9 | s->msmpeg4_version = 2; | |
119 | 9 | break; | |
120 | 13 | case AV_CODEC_ID_MSMPEG4V3: | |
121 | 13 | s->h263_pred = 1; | |
122 | 13 | s->msmpeg4_version = 3; | |
123 | 13 | break; | |
124 | 9 | case AV_CODEC_ID_WMV1: | |
125 | 9 | s->h263_pred = 1; | |
126 | 9 | s->msmpeg4_version = 4; | |
127 | 9 | break; | |
128 | 12 | case AV_CODEC_ID_WMV2: | |
129 | 12 | s->h263_pred = 1; | |
130 | 12 | s->msmpeg4_version = 5; | |
131 | 12 | break; | |
132 | ✗ | case AV_CODEC_ID_H263I: | |
133 | ✗ | break; | |
134 | 20 | case AV_CODEC_ID_FLV1: | |
135 | 20 | s->h263_flv = 1; | |
136 | 20 | break; | |
137 | ✗ | default: | |
138 | ✗ | av_log(avctx, AV_LOG_ERROR, "Unsupported codec %d\n", | |
139 | ✗ | avctx->codec->id); | |
140 | ✗ | return AVERROR(ENOSYS); | |
141 | } | ||
142 | |||
143 |
2/4✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264 times.
|
264 | if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263")) |
144 | ✗ | if (avctx->extradata_size == 56 && avctx->extradata[0] == 1) | |
145 | ✗ | s->ehc_mode = 1; | |
146 | |||
147 | /* for H.263, we allocate the images after having read the header */ | ||
148 |
2/2✓ Branch 0 taken 244 times.
✓ Branch 1 taken 20 times.
|
264 | if (avctx->codec->id != AV_CODEC_ID_H263 && |
149 |
1/2✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
|
244 | avctx->codec->id != AV_CODEC_ID_H263P && |
150 |
2/2✓ Branch 0 taken 65 times.
✓ Branch 1 taken 179 times.
|
244 | avctx->codec->id != AV_CODEC_ID_MPEG4) { |
151 | 65 | avctx->pix_fmt = h263_get_format(avctx); | |
152 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
|
65 | if ((ret = ff_mpv_common_init(s)) < 0) |
153 | ✗ | return ret; | |
154 | } | ||
155 | |||
156 | 264 | ff_h263dsp_init(&s->h263dsp); | |
157 | 264 | ff_h263_decode_init_vlc(); | |
158 | |||
159 | 264 | return 0; | |
160 | } | ||
161 | |||
162 | 264 | av_cold int ff_h263_decode_end(AVCodecContext *avctx) | |
163 | { | ||
164 | 264 | MpegEncContext *s = avctx->priv_data; | |
165 | |||
166 | 264 | ff_mpv_common_end(s); | |
167 | 264 | return 0; | |
168 | } | ||
169 | |||
170 | /** | ||
171 | * Return the number of bytes consumed for building the current frame. | ||
172 | */ | ||
173 | 5634 | static int get_consumed_bytes(MpegEncContext *s, int buf_size) | |
174 | { | ||
175 | 5634 | int pos = (get_bits_count(&s->gb) + 7) >> 3; | |
176 | |||
177 |
3/4✓ Branch 0 taken 5617 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5617 times.
|
5634 | if (s->divx_packed || s->avctx->hwaccel) { |
178 | /* We would have to scan through the whole buf to handle the weird | ||
179 | * reordering ... */ | ||
180 | 17 | return buf_size; | |
181 | } else { | ||
182 | // avoid infinite loops (maybe not needed...) | ||
183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5617 times.
|
5617 | if (pos == 0) |
184 | ✗ | pos = 1; | |
185 | // oops ;) | ||
186 |
2/2✓ Branch 0 taken 5452 times.
✓ Branch 1 taken 165 times.
|
5617 | if (pos + 10 > buf_size) |
187 | 5452 | pos = buf_size; | |
188 | |||
189 | 5617 | return pos; | |
190 | } | ||
191 | } | ||
192 | |||
193 | 11944 | static int decode_slice(MpegEncContext *s) | |
194 | { | ||
195 | 23888 | const int part_mask = s->partitioned_frame | |
196 |
2/2✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 10216 times.
|
11944 | ? (ER_AC_END | ER_AC_ERROR) : 0x7F; |
197 | 11944 | const int mb_size = 16 >> s->avctx->lowres; | |
198 | int ret; | ||
199 | |||
200 | 11944 | s->last_resync_gb = s->gb; | |
201 | 11944 | s->first_slice_line = 1; | |
202 | 11944 | s->resync_mb_x = s->mb_x; | |
203 | 11944 | s->resync_mb_y = s->mb_y; | |
204 | |||
205 | 11944 | ff_set_qscale(s, s->qscale); | |
206 | |||
207 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 11914 times.
|
11944 | if (s->studio_profile) { |
208 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
|
30 | if ((ret = ff_mpeg4_decode_studio_slice_header(s->avctx->priv_data)) < 0) |
209 | ✗ | return ret; | |
210 | } | ||
211 | |||
212 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11944 times.
|
11944 | if (s->avctx->hwaccel) { |
213 | ✗ | const uint8_t *start = s->gb.buffer + get_bits_count(&s->gb) / 8; | |
214 | ✗ | ret = FF_HW_CALL(s->avctx, decode_slice, start, s->gb.buffer_end - start); | |
215 | // ensure we exit decode loop | ||
216 | ✗ | s->mb_y = s->mb_height; | |
217 | ✗ | return ret; | |
218 | } | ||
219 | |||
220 |
2/2✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 10216 times.
|
11944 | if (s->partitioned_frame) { |
221 | 1728 | const int qscale = s->qscale; | |
222 | |||
223 |
1/2✓ Branch 0 taken 1728 times.
✗ Branch 1 not taken.
|
1728 | if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) |
224 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1728 times.
|
1728 | if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0) |
225 | ✗ | return ret; | |
226 | |||
227 | /* restore variables which were modified */ | ||
228 | 1728 | s->first_slice_line = 1; | |
229 | 1728 | s->mb_x = s->resync_mb_x; | |
230 | 1728 | s->mb_y = s->resync_mb_y; | |
231 | 1728 | ff_set_qscale(s, qscale); | |
232 | } | ||
233 | |||
234 |
2/2✓ Branch 0 taken 93735 times.
✓ Branch 1 taken 1346 times.
|
95081 | for (; s->mb_y < s->mb_height; s->mb_y++) { |
235 | /* per-row end of slice checks */ | ||
236 |
2/2✓ Branch 0 taken 19665 times.
✓ Branch 1 taken 74070 times.
|
93735 | if (s->msmpeg4_version) { |
237 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19665 times.
|
19665 | if (s->resync_mb_y + s->slice_height == s->mb_y) { |
238 | ✗ | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, | |
239 | ✗ | s->mb_x - 1, s->mb_y, ER_MB_END); | |
240 | |||
241 | ✗ | return 0; | |
242 | } | ||
243 | } | ||
244 | |||
245 |
2/2✓ Branch 0 taken 750 times.
✓ Branch 1 taken 92985 times.
|
93735 | if (s->msmpeg4_version == 1) { |
246 | 750 | s->last_dc[0] = | |
247 | 750 | s->last_dc[1] = | |
248 | 750 | s->last_dc[2] = 128; | |
249 | } | ||
250 | |||
251 | 93735 | ff_init_block_index(s); | |
252 |
2/2✓ Branch 0 taken 2191508 times.
✓ Branch 1 taken 83137 times.
|
2274645 | for (; s->mb_x < s->mb_width; s->mb_x++) { |
253 | int ret; | ||
254 | |||
255 | 2191508 | ff_update_block_index(s, s->avctx->bits_per_raw_sample, | |
256 | 2191508 | s->avctx->lowres, s->chroma_x_shift); | |
257 | |||
258 |
4/4✓ Branch 0 taken 92918 times.
✓ Branch 1 taken 2098590 times.
✓ Branch 2 taken 7345 times.
✓ Branch 3 taken 85573 times.
|
2191508 | if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y) |
259 | 7345 | s->first_slice_line = 0; | |
260 | |||
261 | /* DCT & quantize */ | ||
262 | |||
263 | 2191508 | s->mv_dir = MV_DIR_FORWARD; | |
264 | 2191508 | s->mv_type = MV_TYPE_16X16; | |
265 | ff_dlog(s, "%d %06X\n", | ||
266 | get_bits_count(&s->gb), show_bits(&s->gb, 24)); | ||
267 | |||
268 | ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y); | ||
269 | 2191508 | ret = s->decode_mb(s, s->block); | |
270 | |||
271 |
2/2✓ Branch 0 taken 1944784 times.
✓ Branch 1 taken 246724 times.
|
2191508 | if (s->pict_type != AV_PICTURE_TYPE_B) |
272 | 1944784 | ff_h263_update_motion_val(s); | |
273 | |||
274 |
2/2✓ Branch 0 taken 10598 times.
✓ Branch 1 taken 2180910 times.
|
2191508 | if (ret < 0) { |
275 | 10598 | const int xy = s->mb_x + s->mb_y * s->mb_stride; | |
276 |
1/2✓ Branch 0 taken 10598 times.
✗ Branch 1 not taken.
|
10598 | if (ret == SLICE_END) { |
277 | 10598 | ff_mpv_reconstruct_mb(s, s->block); | |
278 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10598 times.
|
10598 | if (s->loop_filter) |
279 | ✗ | ff_h263_loop_filter(s); | |
280 | |||
281 | 10598 | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, | |
282 | s->mb_x, s->mb_y, ER_MB_END & part_mask); | ||
283 | |||
284 | 10598 | s->padding_bug_score--; | |
285 | |||
286 |
2/2✓ Branch 0 taken 7645 times.
✓ Branch 1 taken 2953 times.
|
10598 | if (++s->mb_x >= s->mb_width) { |
287 | 7645 | s->mb_x = 0; | |
288 | 7645 | ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size); | |
289 | 7645 | ff_mpv_report_decode_progress(s); | |
290 | 7645 | s->mb_y++; | |
291 | } | ||
292 | 10598 | return 0; | |
293 | ✗ | } else if (ret == SLICE_NOEND) { | |
294 | ✗ | av_log(s->avctx, AV_LOG_ERROR, | |
295 | "Slice mismatch at MB: %d\n", xy); | ||
296 | ✗ | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, | |
297 | ✗ | s->mb_x + 1, s->mb_y, | |
298 | ER_MB_END & part_mask); | ||
299 | ✗ | return AVERROR_INVALIDDATA; | |
300 | } | ||
301 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy); | |
302 | ✗ | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, | |
303 | s->mb_x, s->mb_y, ER_MB_ERROR & part_mask); | ||
304 | |||
305 | ✗ | if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0) | |
306 | ✗ | continue; | |
307 | ✗ | return AVERROR_INVALIDDATA; | |
308 | } | ||
309 | |||
310 | 2180910 | ff_mpv_reconstruct_mb(s, s->block); | |
311 |
2/2✓ Branch 0 taken 141300 times.
✓ Branch 1 taken 2039610 times.
|
2180910 | if (s->loop_filter) |
312 | 141300 | ff_h263_loop_filter(s); | |
313 | } | ||
314 | |||
315 | 83137 | ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size); | |
316 | 83137 | ff_mpv_report_decode_progress(s); | |
317 | |||
318 | 83137 | s->mb_x = 0; | |
319 | } | ||
320 | |||
321 | av_assert1(s->mb_x == 0 && s->mb_y == s->mb_height); | ||
322 | |||
323 | // Detect incorrect padding with wrong stuffing codes used by NEC N-02B | ||
324 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | if (s->codec_id == AV_CODEC_ID_MPEG4 && |
325 | ✗ | (s->workaround_bugs & FF_BUG_AUTODETECT) && | |
326 | ✗ | get_bits_left(&s->gb) >= 48 && | |
327 | ✗ | show_bits(&s->gb, 24) == 0x4010 && | |
328 | ✗ | !s->data_partitioning) | |
329 | ✗ | s->padding_bug_score += 32; | |
330 | |||
331 | /* try to detect the padding bug */ | ||
332 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | if (s->codec_id == AV_CODEC_ID_MPEG4 && |
333 | ✗ | (s->workaround_bugs & FF_BUG_AUTODETECT) && | |
334 | ✗ | get_bits_left(&s->gb) >= 0 && | |
335 | ✗ | get_bits_left(&s->gb) < 137 && | |
336 | ✗ | !s->data_partitioning) { | |
337 | ✗ | const int bits_count = get_bits_count(&s->gb); | |
338 | ✗ | const int bits_left = s->gb.size_in_bits - bits_count; | |
339 | |||
340 | ✗ | if (bits_left == 0) { | |
341 | ✗ | s->padding_bug_score += 16; | |
342 | ✗ | } else if (bits_left != 1) { | |
343 | ✗ | int v = show_bits(&s->gb, 8); | |
344 | ✗ | v |= 0x7F >> (7 - (bits_count & 7)); | |
345 | |||
346 | ✗ | if (v == 0x7F && bits_left <= 8) | |
347 | ✗ | s->padding_bug_score--; | |
348 | ✗ | else if (v == 0x7F && ((get_bits_count(&s->gb) + 8) & 8) && | |
349 | bits_left <= 16) | ||
350 | ✗ | s->padding_bug_score += 4; | |
351 | else | ||
352 | ✗ | s->padding_bug_score++; | |
353 | } | ||
354 | } | ||
355 | |||
356 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | if (s->codec_id == AV_CODEC_ID_H263 && |
357 | ✗ | (s->workaround_bugs & FF_BUG_AUTODETECT) && | |
358 | ✗ | get_bits_left(&s->gb) >= 8 && | |
359 | ✗ | get_bits_left(&s->gb) < 300 && | |
360 | ✗ | s->pict_type == AV_PICTURE_TYPE_I && | |
361 | ✗ | show_bits(&s->gb, 8) == 0 && | |
362 | ✗ | !s->data_partitioning) { | |
363 | |||
364 | ✗ | s->padding_bug_score += 32; | |
365 | } | ||
366 | |||
367 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | if (s->codec_id == AV_CODEC_ID_H263 && |
368 | ✗ | (s->workaround_bugs & FF_BUG_AUTODETECT) && | |
369 | ✗ | get_bits_left(&s->gb) >= 64 && | |
370 | ✗ | AV_RB64(s->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) { | |
371 | |||
372 | ✗ | s->padding_bug_score += 32; | |
373 | } | ||
374 | |||
375 |
1/2✓ Branch 0 taken 1346 times.
✗ Branch 1 not taken.
|
1346 | if (s->workaround_bugs & FF_BUG_AUTODETECT) { |
376 | 1346 | if ( | |
377 |
2/4✓ Branch 0 taken 1346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1346 times.
✗ Branch 3 not taken.
|
1346 | (s->padding_bug_score > -2 && !s->data_partitioning)) |
378 | 1346 | s->workaround_bugs |= FF_BUG_NO_PADDING; | |
379 | else | ||
380 | ✗ | s->workaround_bugs &= ~FF_BUG_NO_PADDING; | |
381 | } | ||
382 | |||
383 | // handle formats which don't have unique end markers | ||
384 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1346 | if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly |
385 | 1346 | int left = get_bits_left(&s->gb); | |
386 | 1346 | int max_extra = 7; | |
387 | |||
388 | /* no markers in M$ crap */ | ||
389 |
3/4✓ Branch 0 taken 1346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 1256 times.
|
1346 | if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I) |
390 | 90 | max_extra += 17; | |
391 | |||
392 | /* buggy padding but the frame should still end approximately at | ||
393 | * the bitstream end */ | ||
394 |
1/2✓ Branch 0 taken 1346 times.
✗ Branch 1 not taken.
|
1346 | if ((s->workaround_bugs & FF_BUG_NO_PADDING) && |
395 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | (s->avctx->err_recognition & (AV_EF_BUFFER|AV_EF_AGGRESSIVE))) |
396 | ✗ | max_extra += 48; | |
397 |
1/2✓ Branch 0 taken 1346 times.
✗ Branch 1 not taken.
|
1346 | else if ((s->workaround_bugs & FF_BUG_NO_PADDING)) |
398 | 1346 | max_extra += 256 * 256 * 256 * 64; | |
399 | |||
400 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | if (left > max_extra) |
401 | ✗ | av_log(s->avctx, AV_LOG_ERROR, | |
402 | "discarding %d junk bits at end, next would be %X\n", | ||
403 | left, show_bits(&s->gb, 24)); | ||
404 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1346 times.
|
1346 | else if (left < 0) |
405 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left); | |
406 | else | ||
407 | 1346 | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, | |
408 | 1346 | s->mb_x - 1, s->mb_y, ER_MB_END); | |
409 | |||
410 | 1346 | return 0; | |
411 | } | ||
412 | |||
413 | ✗ | av_log(s->avctx, AV_LOG_ERROR, | |
414 | "slice end not reached but screenspace end (%d left %06X, score= %d)\n", | ||
415 | get_bits_left(&s->gb), show_bits(&s->gb, 24), s->padding_bug_score); | ||
416 | |||
417 | ✗ | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, | |
418 | ER_MB_END & part_mask); | ||
419 | |||
420 | ✗ | return AVERROR_INVALIDDATA; | |
421 | } | ||
422 | |||
423 | 5742 | int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, | |
424 | int *got_frame, AVPacket *avpkt) | ||
425 | { | ||
426 | 5742 | const uint8_t *buf = avpkt->data; | |
427 | 5742 | int buf_size = avpkt->size; | |
428 | 5742 | MpegEncContext *s = avctx->priv_data; | |
429 | int ret; | ||
430 | 5742 | int slice_ret = 0; | |
431 | |||
432 | /* no supplementary picture */ | ||
433 |
2/2✓ Branch 0 taken 5634 times.
✓ Branch 1 taken 108 times.
|
5742 | if (buf_size == 0) { |
434 | /* special case for last picture */ | ||
435 |
4/4✓ Branch 0 taken 46 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 23 times.
|
108 | if (s->low_delay == 0 && s->next_picture_ptr) { |
436 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
|
23 | if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0) |
437 | ✗ | return ret; | |
438 | 23 | s->next_picture_ptr = NULL; | |
439 | |||
440 | 23 | *got_frame = 1; | |
441 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
85 | } else if (s->skipped_last_frame && s->current_picture_ptr) { |
442 | /* Output the last picture we decoded again if the stream ended with | ||
443 | * an NVOP */ | ||
444 | ✗ | if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) | |
445 | ✗ | return ret; | |
446 | /* Copy props from the last input packet. Otherwise, props from the last | ||
447 | * returned picture would be reused */ | ||
448 | ✗ | if ((ret = ff_decode_frame_props(avctx, pict)) < 0) | |
449 | ✗ | return ret; | |
450 | ✗ | s->current_picture_ptr = NULL; | |
451 | |||
452 | ✗ | *got_frame = 1; | |
453 | } | ||
454 | |||
455 | 108 | return 0; | |
456 | } | ||
457 | |||
458 | 5634 | retry: | |
459 |
4/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5620 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 11 times.
|
5638 | if (s->divx_packed && s->bitstream_buffer_size) { |
460 | int i; | ||
461 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | for(i=0; i < buf_size-3; i++) { |
462 |
3/6✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) { |
463 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if (buf[i+3]==0xB0) { |
464 | ✗ | av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n"); | |
465 | ✗ | s->bitstream_buffer_size = 0; | |
466 | } | ||
467 | 7 | break; | |
468 | } | ||
469 | } | ||
470 | } | ||
471 | |||
472 |
3/6✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5631 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
5638 | if (s->bitstream_buffer_size && (s->divx_packed || buf_size <= MAX_NVOP_SIZE)) // divx 5.01+/xvid frame reorder |
473 | 7 | ret = init_get_bits8(&s->gb, s->bitstream_buffer, | |
474 | s->bitstream_buffer_size); | ||
475 | else | ||
476 | 5631 | ret = init_get_bits8(&s->gb, buf, buf_size); | |
477 | |||
478 | 5638 | s->bitstream_buffer_size = 0; | |
479 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5638 times.
|
5638 | if (ret < 0) |
480 | ✗ | return ret; | |
481 | |||
482 | /* let's go :-) */ | ||
483 |
2/2✓ Branch 0 taken 674 times.
✓ Branch 1 taken 4964 times.
|
5638 | if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { |
484 | 674 | ret = ff_wmv2_decode_picture_header(s); | |
485 |
2/2✓ Branch 0 taken 675 times.
✓ Branch 1 taken 4289 times.
|
4964 | } else if (CONFIG_MSMPEG4DEC && s->msmpeg4_version) { |
486 | 675 | ret = ff_msmpeg4_decode_picture_header(s); | |
487 |
2/2✓ Branch 0 taken 3513 times.
✓ Branch 1 taken 776 times.
|
4289 | } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { |
488 | 3513 | ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0); | |
489 | 3513 | s->skipped_last_frame = (ret == FRAME_SKIPPED); | |
490 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 776 times.
|
776 | } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) { |
491 | ✗ | ret = ff_intel_h263_decode_picture_header(s); | |
492 |
2/2✓ Branch 0 taken 315 times.
✓ Branch 1 taken 461 times.
|
776 | } else if (CONFIG_FLV_DECODER && s->h263_flv) { |
493 | 315 | ret = ff_flv_decode_picture_header(s); | |
494 | } else { | ||
495 | 461 | ret = ff_h263_decode_picture_header(s); | |
496 | } | ||
497 | |||
498 |
2/4✓ Branch 0 taken 5638 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5638 times.
|
5638 | if (ret < 0 || ret == FRAME_SKIPPED) { |
499 | ✗ | if ( s->width != avctx->coded_width | |
500 | ✗ | || s->height != avctx->coded_height) { | |
501 | ✗ | av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n"); | |
502 | ✗ | s->width = avctx->coded_width; | |
503 | ✗ | s->height= avctx->coded_height; | |
504 | } | ||
505 | } | ||
506 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5638 times.
|
5638 | if (ret == FRAME_SKIPPED) |
507 | ✗ | return get_consumed_bytes(s, buf_size); | |
508 | |||
509 | /* skip if the header was thrashed */ | ||
510 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5638 times.
|
5638 | if (ret < 0) { |
511 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); | |
512 | ✗ | return ret; | |
513 | } | ||
514 | |||
515 |
2/2✓ Branch 0 taken 189 times.
✓ Branch 1 taken 5449 times.
|
5638 | if (!s->context_initialized) { |
516 | 189 | avctx->pix_fmt = h263_get_format(avctx); | |
517 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
|
189 | if ((ret = ff_mpv_common_init(s)) < 0) |
518 | ✗ | return ret; | |
519 | } | ||
520 | |||
521 | 5638 | avctx->has_b_frames = !s->low_delay; | |
522 | |||
523 |
2/2✓ Branch 0 taken 3513 times.
✓ Branch 1 taken 2125 times.
|
5638 | if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { |
524 |
3/4✓ Branch 0 taken 2814 times.
✓ Branch 1 taken 699 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2814 times.
|
3513 | if (s->pict_type != AV_PICTURE_TYPE_B && s->mb_num/2 > get_bits_left(&s->gb)) |
525 | ✗ | return AVERROR_INVALIDDATA; | |
526 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3509 times.
|
3513 | if (ff_mpeg4_workaround_bugs(avctx) == 1) |
527 | 4 | goto retry; | |
528 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3508 times.
|
3509 | if (s->studio_profile != (s->idsp.idct == NULL)) |
529 | 1 | ff_mpv_idct_init(s); | |
530 | } | ||
531 | |||
532 | /* After H.263 & MPEG-4 header decode we have the height, width, | ||
533 | * and other parameters. So then we could init the picture. | ||
534 | * FIXME: By the way H.263 decoder is evolving it should have | ||
535 | * an H263EncContext */ | ||
536 |
2/2✓ Branch 0 taken 5593 times.
✓ Branch 1 taken 41 times.
|
5634 | if (s->width != avctx->coded_width || |
537 |
1/2✓ Branch 0 taken 5593 times.
✗ Branch 1 not taken.
|
5593 | s->height != avctx->coded_height || |
538 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5592 times.
|
5593 | s->context_reinit) { |
539 | /* H.263 could change picture size any time */ | ||
540 | 42 | s->context_reinit = 0; | |
541 | |||
542 | 42 | ret = ff_set_dimensions(avctx, s->width, s->height); | |
543 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
|
42 | if (ret < 0) |
544 | ✗ | return ret; | |
545 | |||
546 | 42 | ff_set_sar(avctx, avctx->sample_aspect_ratio); | |
547 | |||
548 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
|
42 | if ((ret = ff_mpv_common_frame_size_change(s))) |
549 | ✗ | return ret; | |
550 | |||
551 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
|
42 | if (avctx->pix_fmt != h263_get_format(avctx)) { |
552 | ✗ | av_log(avctx, AV_LOG_ERROR, "format change not supported\n"); | |
553 | ✗ | avctx->pix_fmt = AV_PIX_FMT_NONE; | |
554 | ✗ | return AVERROR_UNKNOWN; | |
555 | } | ||
556 | } | ||
557 | |||
558 |
2/2✓ Branch 0 taken 5173 times.
✓ Branch 1 taken 461 times.
|
5634 | if (s->codec_id == AV_CODEC_ID_H263 || |
559 |
1/2✓ Branch 0 taken 5173 times.
✗ Branch 1 not taken.
|
5173 | s->codec_id == AV_CODEC_ID_H263P || |
560 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
|
5173 | s->codec_id == AV_CODEC_ID_H263I) |
561 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
461 | s->gob_index = H263_GOB_HEIGHT(s->height); |
562 | |||
563 | /* skip B-frames if we don't have reference frames */ | ||
564 |
2/2✓ Branch 0 taken 365 times.
✓ Branch 1 taken 5269 times.
|
5634 | if (!s->last_picture_ptr && |
565 |
2/4✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 365 times.
|
365 | (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) |
566 | ✗ | return get_consumed_bytes(s, buf_size); | |
567 |
2/2✓ Branch 0 taken 170 times.
✓ Branch 1 taken 5464 times.
|
5634 | if ((avctx->skip_frame >= AVDISCARD_NONREF && |
568 |
1/2✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
|
170 | s->pict_type == AV_PICTURE_TYPE_B) || |
569 |
2/2✓ Branch 0 taken 170 times.
✓ Branch 1 taken 5464 times.
|
5634 | (avctx->skip_frame >= AVDISCARD_NONKEY && |
570 |
2/2✓ Branch 0 taken 123 times.
✓ Branch 1 taken 47 times.
|
170 | s->pict_type != AV_PICTURE_TYPE_I) || |
571 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 5467 times.
|
5587 | avctx->skip_frame >= AVDISCARD_ALL) |
572 | 167 | return get_consumed_bytes(s, buf_size); | |
573 | |||
574 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5467 times.
|
5467 | if ((ret = ff_mpv_frame_start(s, avctx)) < 0) |
575 | ✗ | return ret; | |
576 | |||
577 |
3/4✓ Branch 0 taken 5452 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5452 times.
✗ Branch 3 not taken.
|
5467 | if (!s->divx_packed && !avctx->hwaccel) |
578 | 5452 | ff_thread_finish_setup(avctx); | |
579 | |||
580 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5467 times.
|
5467 | if (avctx->hwaccel) { |
581 | ✗ | ret = FF_HW_CALL(avctx, start_frame, | |
582 | s->gb.buffer, s->gb.buffer_end - s->gb.buffer); | ||
583 | ✗ | if (ret < 0 ) | |
584 | ✗ | return ret; | |
585 | } | ||
586 | |||
587 | 5467 | ff_mpeg_er_frame_start(s); | |
588 | |||
589 | /* the second part of the wmv2 header contains the MB skip bits which | ||
590 | * are stored in current_picture->mb_type which is not available before | ||
591 | * ff_mpv_frame_start() */ | ||
592 |
2/2✓ Branch 0 taken 674 times.
✓ Branch 1 taken 4793 times.
|
5467 | if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { |
593 | 674 | ret = ff_wmv2_decode_secondary_picture_header(s); | |
594 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 674 times.
|
674 | if (ret < 0) |
595 | ✗ | return ret; | |
596 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 671 times.
|
674 | if (ret == 1) |
597 | 3 | goto frame_end; | |
598 | } | ||
599 | |||
600 | /* decode each macroblock */ | ||
601 | 5464 | s->mb_x = 0; | |
602 | 5464 | s->mb_y = 0; | |
603 | |||
604 | 5464 | slice_ret = decode_slice(s); | |
605 |
2/2✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 5464 times.
|
11944 | while (s->mb_y < s->mb_height) { |
606 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6480 times.
|
6480 | if (s->msmpeg4_version) { |
607 | ✗ | if (s->slice_height == 0 || s->mb_x != 0 || slice_ret < 0 || | |
608 | ✗ | (s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0) | |
609 | break; | ||
610 | } else { | ||
611 | 6480 | int prev_x = s->mb_x, prev_y = s->mb_y; | |
612 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6480 times.
|
6480 | if (ff_h263_resync(s) < 0) |
613 | ✗ | break; | |
614 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6451 times.
|
6480 | if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x) |
615 | 29 | s->er.error_occurred = 1; | |
616 | } | ||
617 | |||
618 |
3/4✓ Branch 0 taken 6480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 2544 times.
|
6480 | if (s->msmpeg4_version < 4 && s->h263_pred) |
619 | 3936 | ff_mpeg4_clean_buffers(s); | |
620 | |||
621 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6480 times.
|
6480 | if (decode_slice(s) < 0) |
622 | ✗ | slice_ret = AVERROR_INVALIDDATA; | |
623 | } | ||
624 | |||
625 |
4/4✓ Branch 0 taken 4118 times.
✓ Branch 1 taken 1346 times.
✓ Branch 2 taken 871 times.
✓ Branch 3 taken 475 times.
|
5464 | if (s->msmpeg4_version && s->msmpeg4_version < 4 && |
626 |
2/2✓ Branch 0 taken 431 times.
✓ Branch 1 taken 44 times.
|
475 | s->pict_type == AV_PICTURE_TYPE_I) |
627 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 | if (!CONFIG_MSMPEG4DEC || |
628 | 44 | ff_msmpeg4_decode_ext_header(s, buf_size) < 0) | |
629 | ✗ | s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR; | |
630 | |||
631 | av_assert1(s->bitstream_buffer_size == 0); | ||
632 | 5464 | frame_end: | |
633 |
2/2✓ Branch 0 taken 5466 times.
✓ Branch 1 taken 1 times.
|
5467 | if (!s->studio_profile) |
634 | 5466 | ff_er_frame_end(&s->er, NULL); | |
635 | |||
636 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5467 times.
|
5467 | if (avctx->hwaccel) { |
637 | ✗ | ret = FF_HW_SIMPLE_CALL(avctx, end_frame); | |
638 | ✗ | if (ret < 0) | |
639 | ✗ | return ret; | |
640 | } | ||
641 | |||
642 | 5467 | ff_mpv_frame_end(s); | |
643 | |||
644 |
2/2✓ Branch 0 taken 3365 times.
✓ Branch 1 taken 2102 times.
|
5467 | if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) |
645 | 3365 | ff_mpeg4_frame_end(avctx, buf, buf_size); | |
646 | |||
647 |
3/4✓ Branch 0 taken 5452 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5452 times.
|
5467 | if (!s->divx_packed && avctx->hwaccel) |
648 | ✗ | ff_thread_finish_setup(avctx); | |
649 | |||
650 | av_assert1(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type); | ||
651 | av_assert1(s->current_picture.f->pict_type == s->pict_type); | ||
652 |
4/4✓ Branch 0 taken 4768 times.
✓ Branch 1 taken 699 times.
✓ Branch 2 taken 4363 times.
✓ Branch 3 taken 405 times.
|
5467 | if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { |
653 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5062 times.
|
5062 | if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) |
654 | ✗ | return ret; | |
655 | 5062 | ff_print_debug_info(s, s->current_picture_ptr, pict); | |
656 | 5062 | ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | |
657 |
2/2✓ Branch 0 taken 378 times.
✓ Branch 1 taken 27 times.
|
405 | } else if (s->last_picture_ptr) { |
658 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
|
378 | if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) |
659 | ✗ | return ret; | |
660 | 378 | ff_print_debug_info(s, s->last_picture_ptr, pict); | |
661 | 378 | ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_MPV_QSCALE_TYPE_MPEG1); | |
662 | } | ||
663 | |||
664 |
4/4✓ Branch 0 taken 117 times.
✓ Branch 1 taken 5350 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 27 times.
|
5467 | if (s->last_picture_ptr || s->low_delay) { |
665 |
2/2✓ Branch 0 taken 5439 times.
✓ Branch 1 taken 1 times.
|
5440 | if ( pict->format == AV_PIX_FMT_YUV420P |
666 |
2/4✓ Branch 0 taken 5439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5439 times.
|
5439 | && (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) { |
667 | ✗ | for (int p = 0; p < 3; p++) { | |
668 | ✗ | int h = AV_CEIL_RSHIFT(pict->height, !!p); | |
669 | |||
670 | ✗ | pict->data[p] += (h - 1) * pict->linesize[p]; | |
671 | ✗ | pict->linesize[p] *= -1; | |
672 | } | ||
673 | } | ||
674 | 5440 | *got_frame = 1; | |
675 | } | ||
676 | |||
677 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5467 | if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) |
678 | ✗ | return slice_ret; | |
679 | else | ||
680 | 5467 | return get_consumed_bytes(s, buf_size); | |
681 | } | ||
682 | |||
683 | static const AVCodecHWConfigInternal *const h263_hw_config_list[] = { | ||
684 | #if CONFIG_H263_VAAPI_HWACCEL | ||
685 | HWACCEL_VAAPI(h263), | ||
686 | #endif | ||
687 | #if CONFIG_MPEG4_NVDEC_HWACCEL | ||
688 | HWACCEL_NVDEC(mpeg4), | ||
689 | #endif | ||
690 | #if CONFIG_MPEG4_VDPAU_HWACCEL | ||
691 | HWACCEL_VDPAU(mpeg4), | ||
692 | #endif | ||
693 | #if CONFIG_H263_VIDEOTOOLBOX_HWACCEL | ||
694 | HWACCEL_VIDEOTOOLBOX(h263), | ||
695 | #endif | ||
696 | NULL | ||
697 | }; | ||
698 | |||
699 | const FFCodec ff_h263_decoder = { | ||
700 | .p.name = "h263", | ||
701 | CODEC_LONG_NAME("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), | ||
702 | .p.type = AVMEDIA_TYPE_VIDEO, | ||
703 | .p.id = AV_CODEC_ID_H263, | ||
704 | .priv_data_size = sizeof(MpegEncContext), | ||
705 | .init = ff_h263_decode_init, | ||
706 | .close = ff_h263_decode_end, | ||
707 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), | ||
708 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | | ||
709 | AV_CODEC_CAP_DELAY, | ||
710 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, | ||
711 | .flush = ff_mpeg_flush, | ||
712 | .p.max_lowres = 3, | ||
713 | .hw_configs = h263_hw_config_list, | ||
714 | }; | ||
715 | |||
716 | const FFCodec ff_h263p_decoder = { | ||
717 | .p.name = "h263p", | ||
718 | CODEC_LONG_NAME("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), | ||
719 | .p.type = AVMEDIA_TYPE_VIDEO, | ||
720 | .p.id = AV_CODEC_ID_H263P, | ||
721 | .priv_data_size = sizeof(MpegEncContext), | ||
722 | .init = ff_h263_decode_init, | ||
723 | .close = ff_h263_decode_end, | ||
724 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), | ||
725 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | | ||
726 | AV_CODEC_CAP_DELAY, | ||
727 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, | ||
728 | .flush = ff_mpeg_flush, | ||
729 | .p.max_lowres = 3, | ||
730 | .hw_configs = h263_hw_config_list, | ||
731 | }; | ||
732 |