3 * Copyright (c) 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * This file is part of FFmpeg.
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.
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.
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
28 #define UNCHECKED_BITSTREAM_READER 1
30 #include "libavutil/cpu.h"
32 #include "error_resilience.h"
35 #include "h263_parser.h"
38 #include "mpeg4video.h"
39 #include "mpeg4video_parser.h"
40 #include "mpegvideo.h"
43 #include "vdpau_compat.h"
46 static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)
48 if (avctx->codec->id == AV_CODEC_ID_MSS2)
49 return AV_PIX_FMT_YUV420P;
51 if (CONFIG_GRAY && (avctx->flags & CODEC_FLAG_GRAY)) {
52 if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)
53 avctx->color_range = AVCOL_RANGE_MPEG;
54 return AV_PIX_FMT_GRAY8;
57 return avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
60 av_cold int ff_h263_decode_init(AVCodecContext *avctx)
62 MpegEncContext *s = avctx->priv_data;
65 s->out_format = FMT_H263;
68 ff_mpv_decode_defaults(s);
69 ff_mpv_decode_init(s, avctx);
71 s->quant_precision = 5;
72 s->decode_mb = ff_h263_decode_mb;
74 s->unrestricted_mv = 1;
76 /* select sub codec */
77 switch (avctx->codec->id) {
78 case AV_CODEC_ID_H263:
79 case AV_CODEC_ID_H263P:
80 s->unrestricted_mv = 0;
81 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
83 case AV_CODEC_ID_MPEG4:
85 case AV_CODEC_ID_MSMPEG4V1:
87 s->msmpeg4_version = 1;
89 case AV_CODEC_ID_MSMPEG4V2:
91 s->msmpeg4_version = 2;
93 case AV_CODEC_ID_MSMPEG4V3:
95 s->msmpeg4_version = 3;
97 case AV_CODEC_ID_WMV1:
99 s->msmpeg4_version = 4;
101 case AV_CODEC_ID_WMV2:
103 s->msmpeg4_version = 5;
105 case AV_CODEC_ID_VC1:
106 case AV_CODEC_ID_WMV3:
107 case AV_CODEC_ID_VC1IMAGE:
108 case AV_CODEC_ID_WMV3IMAGE:
109 case AV_CODEC_ID_MSS2:
111 s->msmpeg4_version = 6;
112 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
114 case AV_CODEC_ID_H263I:
116 case AV_CODEC_ID_FLV1:
120 av_log(avctx, AV_LOG_ERROR, "Unsupported codec %d\n",
122 return AVERROR(ENOSYS);
124 s->codec_id = avctx->codec->id;
126 if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263"))
127 if (avctx->extradata_size == 56 && avctx->extradata[0] == 1)
130 /* for h263, we allocate the images after having read the header */
131 if (avctx->codec->id != AV_CODEC_ID_H263 &&
132 avctx->codec->id != AV_CODEC_ID_H263P &&
133 avctx->codec->id != AV_CODEC_ID_MPEG4) {
134 avctx->pix_fmt = h263_get_format(avctx);
136 if ((ret = ff_mpv_common_init(s)) < 0)
140 ff_h263dsp_init(&s->h263dsp);
141 ff_qpeldsp_init(&s->qdsp);
142 ff_h263_decode_init_vlc();
147 av_cold int ff_h263_decode_end(AVCodecContext *avctx)
149 MpegEncContext *s = avctx->priv_data;
151 ff_mpv_common_end(s);
156 * Return the number of bytes consumed for building the current frame.
158 static int get_consumed_bytes(MpegEncContext *s, int buf_size)
160 int pos = (get_bits_count(&s->gb) + 7) >> 3;
162 if (s->divx_packed || s->avctx->hwaccel) {
163 /* We would have to scan through the whole buf to handle the weird
166 } else if (s->avctx->flags & CODEC_FLAG_TRUNCATED) {
167 pos -= s->parse_context.last_index;
168 // padding is not really read so this might be -1
173 // avoid infinite loops (maybe not needed...)
177 if (pos + 10 > buf_size)
184 static int decode_slice(MpegEncContext *s)
186 const int part_mask = s->partitioned_frame
187 ? (ER_AC_END | ER_AC_ERROR) : 0x7F;
188 const int mb_size = 16 >> s->avctx->lowres;
191 s->last_resync_gb = s->gb;
192 s->first_slice_line = 1;
193 s->resync_mb_x = s->mb_x;
194 s->resync_mb_y = s->mb_y;
196 ff_set_qscale(s, s->qscale);
198 if (s->avctx->hwaccel) {
199 const uint8_t *start = s->gb.buffer + get_bits_count(&s->gb) / 8;
200 ret = s->avctx->hwaccel->decode_slice(s->avctx, start, s->gb.buffer_end - start);
201 // ensure we exit decode loop
202 s->mb_y = s->mb_height;
206 if (s->partitioned_frame) {
207 const int qscale = s->qscale;
209 if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
210 if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0)
213 /* restore variables which were modified */
214 s->first_slice_line = 1;
215 s->mb_x = s->resync_mb_x;
216 s->mb_y = s->resync_mb_y;
217 ff_set_qscale(s, qscale);
220 for (; s->mb_y < s->mb_height; s->mb_y++) {
221 /* per-row end of slice checks */
222 if (s->msmpeg4_version) {
223 if (s->resync_mb_y + s->slice_height == s->mb_y) {
224 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
225 s->mb_x - 1, s->mb_y, ER_MB_END);
231 if (s->msmpeg4_version == 1) {
237 ff_init_block_index(s);
238 for (; s->mb_x < s->mb_width; s->mb_x++) {
241 ff_update_block_index(s);
243 if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y)
244 s->first_slice_line = 0;
248 s->mv_dir = MV_DIR_FORWARD;
249 s->mv_type = MV_TYPE_16X16;
250 ff_dlog(s, "%d %d %06X\n",
251 ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
253 ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y);
254 ret = s->decode_mb(s, s->block);
256 if (s->pict_type != AV_PICTURE_TYPE_B)
257 ff_h263_update_motion_val(s);
260 const int xy = s->mb_x + s->mb_y * s->mb_stride;
261 if (ret == SLICE_END) {
262 ff_mpv_decode_mb(s, s->block);
264 ff_h263_loop_filter(s);
266 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
267 s->mb_x, s->mb_y, ER_MB_END & part_mask);
269 s->padding_bug_score--;
271 if (++s->mb_x >= s->mb_width) {
273 ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
274 ff_mpv_report_decode_progress(s);
278 } else if (ret == SLICE_NOEND) {
279 av_log(s->avctx, AV_LOG_ERROR,
280 "Slice mismatch at MB: %d\n", xy);
281 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
282 s->mb_x + 1, s->mb_y,
283 ER_MB_END & part_mask);
284 return AVERROR_INVALIDDATA;
286 av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
287 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
288 s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
290 if (s->avctx->err_recognition & AV_EF_IGNORE_ERR)
292 return AVERROR_INVALIDDATA;
295 ff_mpv_decode_mb(s, s->block);
297 ff_h263_loop_filter(s);
300 ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
301 ff_mpv_report_decode_progress(s);
306 av_assert1(s->mb_x == 0 && s->mb_y == s->mb_height);
308 if (s->codec_id == AV_CODEC_ID_MPEG4 &&
309 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
310 get_bits_left(&s->gb) >= 48 &&
311 show_bits(&s->gb, 24) == 0x4010 &&
312 !s->data_partitioning)
313 s->padding_bug_score += 32;
315 /* try to detect the padding bug */
316 if (s->codec_id == AV_CODEC_ID_MPEG4 &&
317 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
318 get_bits_left(&s->gb) >= 0 &&
319 get_bits_left(&s->gb) < 137 &&
320 !s->data_partitioning) {
321 const int bits_count = get_bits_count(&s->gb);
322 const int bits_left = s->gb.size_in_bits - bits_count;
324 if (bits_left == 0) {
325 s->padding_bug_score += 16;
326 } else if (bits_left != 1) {
327 int v = show_bits(&s->gb, 8);
328 v |= 0x7F >> (7 - (bits_count & 7));
330 if (v == 0x7F && bits_left <= 8)
331 s->padding_bug_score--;
332 else if (v == 0x7F && ((get_bits_count(&s->gb) + 8) & 8) &&
334 s->padding_bug_score += 4;
336 s->padding_bug_score++;
340 if (s->codec_id == AV_CODEC_ID_H263 &&
341 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
342 get_bits_left(&s->gb) >= 8 &&
343 get_bits_left(&s->gb) < 300 &&
344 s->pict_type == AV_PICTURE_TYPE_I &&
345 show_bits(&s->gb, 8) == 0 &&
346 !s->data_partitioning) {
348 s->padding_bug_score += 32;
351 if (s->codec_id == AV_CODEC_ID_H263 &&
352 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
353 get_bits_left(&s->gb) >= 64 &&
354 AV_RB64(s->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
356 s->padding_bug_score += 32;
359 if (s->workaround_bugs & FF_BUG_AUTODETECT) {
361 (s->padding_bug_score > -2 && !s->data_partitioning))
362 s->workaround_bugs |= FF_BUG_NO_PADDING;
364 s->workaround_bugs &= ~FF_BUG_NO_PADDING;
367 // handle formats which don't have unique end markers
368 if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
369 int left = get_bits_left(&s->gb);
372 /* no markers in M$ crap */
373 if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I)
376 /* buggy padding but the frame should still end approximately at
377 * the bitstream end */
378 if ((s->workaround_bugs & FF_BUG_NO_PADDING) &&
379 (s->avctx->err_recognition & (AV_EF_BUFFER|AV_EF_AGGRESSIVE)))
381 else if ((s->workaround_bugs & FF_BUG_NO_PADDING))
382 max_extra += 256 * 256 * 256 * 64;
384 if (left > max_extra)
385 av_log(s->avctx, AV_LOG_ERROR,
386 "discarding %d junk bits at end, next would be %X\n",
387 left, show_bits(&s->gb, 24));
389 av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
391 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
392 s->mb_x - 1, s->mb_y, ER_MB_END);
397 av_log(s->avctx, AV_LOG_ERROR,
398 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
399 get_bits_left(&s->gb), show_bits(&s->gb, 24), s->padding_bug_score);
401 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
402 ER_MB_END & part_mask);
404 return AVERROR_INVALIDDATA;
407 int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
410 const uint8_t *buf = avpkt->data;
411 int buf_size = avpkt->size;
412 MpegEncContext *s = avctx->priv_data;
415 AVFrame *pict = data;
417 /* no supplementary picture */
419 /* special case for last picture */
420 if (s->low_delay == 0 && s->next_picture_ptr) {
421 if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
423 s->next_picture_ptr = NULL;
431 if (s->avctx->flags & CODEC_FLAG_TRUNCATED) {
434 if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) {
435 next = ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
436 } else if (CONFIG_H263_DECODER && s->codec_id == AV_CODEC_ID_H263) {
437 next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
438 } else if (CONFIG_H263P_DECODER && s->codec_id == AV_CODEC_ID_H263P) {
439 next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
441 av_log(s->avctx, AV_LOG_ERROR,
442 "this codec does not support truncated bitstreams\n");
443 return AVERROR(ENOSYS);
446 if (ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf,
452 if (s->divx_packed && s->bitstream_buffer_size) {
454 for(i=0; i < buf_size-3; i++) {
455 if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) {
456 if (buf[i+3]==0xB0) {
457 av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
458 s->bitstream_buffer_size = 0;
465 if (s->bitstream_buffer_size && (s->divx_packed || buf_size <= MAX_NVOP_SIZE)) // divx 5.01+/xvid frame reorder
466 ret = init_get_bits8(&s->gb, s->bitstream_buffer,
467 s->bitstream_buffer_size);
469 ret = init_get_bits8(&s->gb, buf, buf_size);
471 s->bitstream_buffer_size = 0;
475 if (!s->context_initialized)
476 // we need the idct permutaton for reading a custom matrix
480 if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
481 ret = ff_wmv2_decode_picture_header(s);
482 } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
483 ret = ff_msmpeg4_decode_picture_header(s);
484 } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
485 if (s->avctx->extradata_size && s->picture_number == 0) {
488 if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 )
489 ff_mpeg4_decode_picture_header(avctx->priv_data, &gb);
491 ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb);
492 } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
493 ret = ff_intel_h263_decode_picture_header(s);
494 } else if (CONFIG_FLV_DECODER && s->h263_flv) {
495 ret = ff_flv_decode_picture_header(s);
497 ret = ff_h263_decode_picture_header(s);
500 if (ret < 0 || ret == FRAME_SKIPPED) {
501 if ( s->width != avctx->coded_width
502 || s->height != avctx->coded_height) {
503 av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
504 s->width = avctx->coded_width;
505 s->height= avctx->coded_height;
508 if (ret == FRAME_SKIPPED)
509 return get_consumed_bytes(s, buf_size);
511 /* skip if the header was thrashed */
513 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
517 if (!s->context_initialized) {
518 avctx->pix_fmt = h263_get_format(avctx);
519 if ((ret = ff_mpv_common_init(s)) < 0)
523 if (!s->current_picture_ptr || s->current_picture_ptr->f->data[0]) {
524 int i = ff_find_unused_picture(s->avctx, s->picture, 0);
527 s->current_picture_ptr = &s->picture[i];
530 avctx->has_b_frames = !s->low_delay;
532 if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
533 if (ff_mpeg4_workaround_bugs(avctx) == 1)
537 /* After H263 & mpeg4 header decode we have the height, width,
538 * and other parameters. So then we could init the picture.
539 * FIXME: By the way H263 decoder is evolving it should have
540 * an H263EncContext */
541 if (s->width != avctx->coded_width ||
542 s->height != avctx->coded_height ||
544 /* H.263 could change picture size any time */
545 s->context_reinit = 0;
547 ret = ff_set_dimensions(avctx, s->width, s->height);
551 ff_set_sar(avctx, avctx->sample_aspect_ratio);
553 if ((ret = ff_mpv_common_frame_size_change(s)))
556 if (avctx->pix_fmt != h263_get_format(avctx)) {
557 av_log(avctx, AV_LOG_ERROR, "format change not supported\n");
558 avctx->pix_fmt = AV_PIX_FMT_NONE;
559 return AVERROR_UNKNOWN;
563 if (s->codec_id == AV_CODEC_ID_H263 ||
564 s->codec_id == AV_CODEC_ID_H263P ||
565 s->codec_id == AV_CODEC_ID_H263I)
566 s->gob_index = H263_GOB_HEIGHT(s->height);
568 // for skipping the frame
569 s->current_picture.f->pict_type = s->pict_type;
570 s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
572 /* skip B-frames if we don't have reference frames */
573 if (!s->last_picture_ptr &&
574 (s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
575 return get_consumed_bytes(s, buf_size);
576 if ((avctx->skip_frame >= AVDISCARD_NONREF &&
577 s->pict_type == AV_PICTURE_TYPE_B) ||
578 (avctx->skip_frame >= AVDISCARD_NONKEY &&
579 s->pict_type != AV_PICTURE_TYPE_I) ||
580 avctx->skip_frame >= AVDISCARD_ALL)
581 return get_consumed_bytes(s, buf_size);
583 if (s->next_p_frame_damaged) {
584 if (s->pict_type == AV_PICTURE_TYPE_B)
585 return get_consumed_bytes(s, buf_size);
587 s->next_p_frame_damaged = 0;
590 if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
591 s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
592 s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
594 s->me.qpel_put = s->qdsp.put_no_rnd_qpel_pixels_tab;
595 s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
598 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
601 if (!s->divx_packed && !avctx->hwaccel)
602 ff_thread_finish_setup(avctx);
604 if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
605 ff_vdpau_mpeg4_decode_picture(avctx->priv_data, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
609 if (avctx->hwaccel) {
610 ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer,
611 s->gb.buffer_end - s->gb.buffer);
616 ff_mpeg_er_frame_start(s);
618 /* the second part of the wmv2 header contains the MB skip bits which
619 * are stored in current_picture->mb_type which is not available before
620 * ff_mpv_frame_start() */
621 if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
622 ret = ff_wmv2_decode_secondary_picture_header(s);
629 /* decode each macroblock */
633 slice_ret = decode_slice(s);
634 while (s->mb_y < s->mb_height) {
635 if (s->msmpeg4_version) {
636 if (s->slice_height == 0 || s->mb_x != 0 ||
637 (s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0)
640 int prev_x = s->mb_x, prev_y = s->mb_y;
641 if (ff_h263_resync(s) < 0)
643 if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
644 s->er.error_occurred = 1;
647 if (s->msmpeg4_version < 4 && s->h263_pred)
648 ff_mpeg4_clean_buffers(s);
650 if (decode_slice(s) < 0)
651 slice_ret = AVERROR_INVALIDDATA;
654 if (s->msmpeg4_version && s->msmpeg4_version < 4 &&
655 s->pict_type == AV_PICTURE_TYPE_I)
656 if (!CONFIG_MSMPEG4_DECODER ||
657 ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
658 s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
660 av_assert1(s->bitstream_buffer_size == 0);
662 ff_er_frame_end(&s->er);
664 if (avctx->hwaccel) {
665 ret = avctx->hwaccel->end_frame(avctx);
672 if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4)
673 ff_mpeg4_frame_end(avctx, buf, buf_size);
675 if (!s->divx_packed && avctx->hwaccel)
676 ff_thread_finish_setup(avctx);
678 av_assert1(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
679 av_assert1(s->current_picture.f->pict_type == s->pict_type);
680 if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
681 if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
683 ff_print_debug_info(s, s->current_picture_ptr, pict);
684 ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
685 } else if (s->last_picture_ptr) {
686 if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
688 ff_print_debug_info(s, s->last_picture_ptr, pict);
689 ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
692 if (s->last_picture_ptr || s->low_delay) {
693 if ( pict->format == AV_PIX_FMT_YUV420P
694 && (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
696 av_frame_make_writable(pict);
697 for (p=0; p<3; p++) {
698 int w = FF_CEIL_RSHIFT(pict-> width, !!p);
699 int h = FF_CEIL_RSHIFT(pict->height, !!p);
700 int linesize = pict->linesize[p];
701 for (y=0; y<(h>>1); y++)
704 pict->data[p][x + y*linesize],
705 pict->data[p][x + (h-1-y)*linesize]);
711 if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
714 return get_consumed_bytes(s, buf_size);
717 const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = {
718 #if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL
719 AV_PIX_FMT_VAAPI_VLD,
721 #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL
728 AVCodec ff_h263_decoder = {
730 .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
731 .type = AVMEDIA_TYPE_VIDEO,
732 .id = AV_CODEC_ID_H263,
733 .priv_data_size = sizeof(MpegEncContext),
734 .init = ff_h263_decode_init,
735 .close = ff_h263_decode_end,
736 .decode = ff_h263_decode_frame,
737 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
738 CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
739 .flush = ff_mpeg_flush,
741 .pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
744 AVCodec ff_h263p_decoder = {
746 .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
747 .type = AVMEDIA_TYPE_VIDEO,
748 .id = AV_CODEC_ID_H263P,
749 .priv_data_size = sizeof(MpegEncContext),
750 .init = ff_h263_decode_init,
751 .close = ff_h263_decode_end,
752 .decode = ff_h263_decode_frame,
753 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
754 CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
755 .flush = ff_mpeg_flush,
757 .pix_fmts = ff_h263_hwaccel_pixfmt_list_420,