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_internal.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 return AV_PIX_FMT_GRAY8;
54 return avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
57 av_cold int ff_h263_decode_init(AVCodecContext *avctx)
59 MpegEncContext *s = avctx->priv_data;
62 s->out_format = FMT_H263;
65 ff_mpv_decode_defaults(s);
66 ff_mpv_decode_init(s, avctx);
68 s->quant_precision = 5;
69 s->decode_mb = ff_h263_decode_mb;
71 s->unrestricted_mv = 1;
73 /* select sub codec */
74 switch (avctx->codec->id) {
75 case AV_CODEC_ID_H263:
76 case AV_CODEC_ID_H263P:
77 s->unrestricted_mv = 0;
78 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
80 case AV_CODEC_ID_MPEG4:
82 case AV_CODEC_ID_MSMPEG4V1:
84 s->msmpeg4_version = 1;
86 case AV_CODEC_ID_MSMPEG4V2:
88 s->msmpeg4_version = 2;
90 case AV_CODEC_ID_MSMPEG4V3:
92 s->msmpeg4_version = 3;
94 case AV_CODEC_ID_WMV1:
96 s->msmpeg4_version = 4;
98 case AV_CODEC_ID_WMV2:
100 s->msmpeg4_version = 5;
102 case AV_CODEC_ID_VC1:
103 case AV_CODEC_ID_WMV3:
104 case AV_CODEC_ID_VC1IMAGE:
105 case AV_CODEC_ID_WMV3IMAGE:
106 case AV_CODEC_ID_MSS2:
108 s->msmpeg4_version = 6;
109 avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
111 case AV_CODEC_ID_H263I:
113 case AV_CODEC_ID_FLV1:
117 av_log(avctx, AV_LOG_ERROR, "Unsupported codec %d\n",
119 return AVERROR(ENOSYS);
121 s->codec_id = avctx->codec->id;
123 if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263"))
124 if (avctx->extradata_size == 56 && avctx->extradata[0] == 1)
127 /* for h263, we allocate the images after having read the header */
128 if (avctx->codec->id != AV_CODEC_ID_H263 &&
129 avctx->codec->id != AV_CODEC_ID_H263P &&
130 avctx->codec->id != AV_CODEC_ID_MPEG4) {
131 avctx->pix_fmt = h263_get_format(avctx);
133 if ((ret = ff_mpv_common_init(s)) < 0)
137 ff_h263dsp_init(&s->h263dsp);
138 ff_qpeldsp_init(&s->qdsp);
139 ff_h263_decode_init_vlc();
144 av_cold int ff_h263_decode_end(AVCodecContext *avctx)
146 MpegEncContext *s = avctx->priv_data;
148 ff_mpv_common_end(s);
153 * Return the number of bytes consumed for building the current frame.
155 static int get_consumed_bytes(MpegEncContext *s, int buf_size)
157 int pos = (get_bits_count(&s->gb) + 7) >> 3;
159 if (s->divx_packed || s->avctx->hwaccel) {
160 /* We would have to scan through the whole buf to handle the weird
163 } else if (s->flags & CODEC_FLAG_TRUNCATED) {
164 pos -= s->parse_context.last_index;
165 // padding is not really read so this might be -1
170 // avoid infinite loops (maybe not needed...)
174 if (pos + 10 > buf_size)
181 static int decode_slice(MpegEncContext *s)
183 const int part_mask = s->partitioned_frame
184 ? (ER_AC_END | ER_AC_ERROR) : 0x7F;
185 const int mb_size = 16 >> s->avctx->lowres;
188 s->last_resync_gb = s->gb;
189 s->first_slice_line = 1;
190 s->resync_mb_x = s->mb_x;
191 s->resync_mb_y = s->mb_y;
193 ff_set_qscale(s, s->qscale);
195 if (s->avctx->hwaccel) {
196 const uint8_t *start = s->gb.buffer + get_bits_count(&s->gb) / 8;
197 ret = s->avctx->hwaccel->decode_slice(s->avctx, start, s->gb.buffer_end - start);
198 // ensure we exit decode loop
199 s->mb_y = s->mb_height;
203 if (s->partitioned_frame) {
204 const int qscale = s->qscale;
206 if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
207 if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0)
210 /* restore variables which were modified */
211 s->first_slice_line = 1;
212 s->mb_x = s->resync_mb_x;
213 s->mb_y = s->resync_mb_y;
214 ff_set_qscale(s, qscale);
217 for (; s->mb_y < s->mb_height; s->mb_y++) {
218 /* per-row end of slice checks */
219 if (s->msmpeg4_version) {
220 if (s->resync_mb_y + s->slice_height == s->mb_y) {
221 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
222 s->mb_x - 1, s->mb_y, ER_MB_END);
228 if (s->msmpeg4_version == 1) {
234 ff_init_block_index(s);
235 for (; s->mb_x < s->mb_width; s->mb_x++) {
238 ff_update_block_index(s);
240 if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y)
241 s->first_slice_line = 0;
245 s->mv_dir = MV_DIR_FORWARD;
246 s->mv_type = MV_TYPE_16X16;
247 ff_dlog(s, "%d %d %06X\n",
248 ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
250 ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y);
251 ret = s->decode_mb(s, s->block);
253 if (s->pict_type != AV_PICTURE_TYPE_B)
254 ff_h263_update_motion_val(s);
257 const int xy = s->mb_x + s->mb_y * s->mb_stride;
258 if (ret == SLICE_END) {
259 ff_mpv_decode_mb(s, s->block);
261 ff_h263_loop_filter(s);
263 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
264 s->mb_x, s->mb_y, ER_MB_END & part_mask);
266 s->padding_bug_score--;
268 if (++s->mb_x >= s->mb_width) {
270 ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
271 ff_mpv_report_decode_progress(s);
275 } else if (ret == SLICE_NOEND) {
276 av_log(s->avctx, AV_LOG_ERROR,
277 "Slice mismatch at MB: %d\n", xy);
278 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
279 s->mb_x + 1, s->mb_y,
280 ER_MB_END & part_mask);
281 return AVERROR_INVALIDDATA;
283 av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
284 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
285 s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
287 if (s->err_recognition & AV_EF_IGNORE_ERR)
289 return AVERROR_INVALIDDATA;
292 ff_mpv_decode_mb(s, s->block);
294 ff_h263_loop_filter(s);
297 ff_mpeg_draw_horiz_band(s, s->mb_y * mb_size, mb_size);
298 ff_mpv_report_decode_progress(s);
303 av_assert1(s->mb_x == 0 && s->mb_y == s->mb_height);
305 if (s->codec_id == AV_CODEC_ID_MPEG4 &&
306 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
307 get_bits_left(&s->gb) >= 48 &&
308 show_bits(&s->gb, 24) == 0x4010 &&
309 !s->data_partitioning)
310 s->padding_bug_score += 32;
312 /* try to detect the padding bug */
313 if (s->codec_id == AV_CODEC_ID_MPEG4 &&
314 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
315 get_bits_left(&s->gb) >= 0 &&
316 get_bits_left(&s->gb) < 137 &&
317 !s->data_partitioning) {
318 const int bits_count = get_bits_count(&s->gb);
319 const int bits_left = s->gb.size_in_bits - bits_count;
321 if (bits_left == 0) {
322 s->padding_bug_score += 16;
323 } else if (bits_left != 1) {
324 int v = show_bits(&s->gb, 8);
325 v |= 0x7F >> (7 - (bits_count & 7));
327 if (v == 0x7F && bits_left <= 8)
328 s->padding_bug_score--;
329 else if (v == 0x7F && ((get_bits_count(&s->gb) + 8) & 8) &&
331 s->padding_bug_score += 4;
333 s->padding_bug_score++;
337 if (s->codec_id == AV_CODEC_ID_H263 &&
338 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
339 get_bits_left(&s->gb) >= 8 &&
340 get_bits_left(&s->gb) < 300 &&
341 s->pict_type == AV_PICTURE_TYPE_I &&
342 show_bits(&s->gb, 8) == 0 &&
343 !s->data_partitioning) {
345 s->padding_bug_score += 32;
348 if (s->codec_id == AV_CODEC_ID_H263 &&
349 (s->workaround_bugs & FF_BUG_AUTODETECT) &&
350 get_bits_left(&s->gb) >= 64 &&
351 AV_RB64(s->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
353 s->padding_bug_score += 32;
356 if (s->workaround_bugs & FF_BUG_AUTODETECT) {
358 (s->padding_bug_score > -2 && !s->data_partitioning))
359 s->workaround_bugs |= FF_BUG_NO_PADDING;
361 s->workaround_bugs &= ~FF_BUG_NO_PADDING;
364 // handle formats which don't have unique end markers
365 if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
366 int left = get_bits_left(&s->gb);
369 /* no markers in M$ crap */
370 if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I)
373 /* buggy padding but the frame should still end approximately at
374 * the bitstream end */
375 if ((s->workaround_bugs & FF_BUG_NO_PADDING) &&
376 (s->err_recognition & (AV_EF_BUFFER|AV_EF_AGGRESSIVE)))
378 else if ((s->workaround_bugs & FF_BUG_NO_PADDING))
379 max_extra += 256 * 256 * 256 * 64;
381 if (left > max_extra)
382 av_log(s->avctx, AV_LOG_ERROR,
383 "discarding %d junk bits at end, next would be %X\n",
384 left, show_bits(&s->gb, 24));
386 av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
388 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
389 s->mb_x - 1, s->mb_y, ER_MB_END);
394 av_log(s->avctx, AV_LOG_ERROR,
395 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
396 get_bits_left(&s->gb), show_bits(&s->gb, 24), s->padding_bug_score);
398 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
399 ER_MB_END & part_mask);
401 return AVERROR_INVALIDDATA;
404 int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
407 const uint8_t *buf = avpkt->data;
408 int buf_size = avpkt->size;
409 MpegEncContext *s = avctx->priv_data;
412 AVFrame *pict = data;
414 s->flags = avctx->flags;
415 s->flags2 = avctx->flags2;
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->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, 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,