comparison h264.c @ 9417:8d228c29a338 libavcodec

Factorize field_end() out.
author michael
date Sun, 12 Apr 2009 20:21:23 +0000
parents d863de897b41
children 95f37e7d10cd
comparison
equal deleted inserted replaced
9416:d863de897b41 9417:8d228c29a338
3612 h->field_scan8x8_q0 = h->field_scan8x8; 3612 h->field_scan8x8_q0 = h->field_scan8x8;
3613 h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc; 3613 h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc;
3614 } 3614 }
3615 } 3615 }
3616 3616
3617 static void field_end(H264Context *h){
3618 MpegEncContext * const s = &h->s;
3619 AVCodecContext * const avctx= s->avctx;
3620 s->mb_y= 0;
3621
3622 s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
3623 s->current_picture_ptr->pict_type= s->pict_type;
3624
3625 if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
3626 ff_vdpau_h264_set_reference_frames(s);
3627
3628 if(!s->dropable) {
3629 execute_ref_pic_marking(h, h->mmco, h->mmco_index);
3630 h->prev_poc_msb= h->poc_msb;
3631 h->prev_poc_lsb= h->poc_lsb;
3632 }
3633 h->prev_frame_num_offset= h->frame_num_offset;
3634 h->prev_frame_num= h->frame_num;
3635
3636 if (avctx->hwaccel) {
3637 if (avctx->hwaccel->end_frame(avctx) < 0)
3638 av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
3639 }
3640
3641 if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
3642 ff_vdpau_h264_picture_complete(s);
3643
3644 /*
3645 * FIXME: Error handling code does not seem to support interlaced
3646 * when slices span multiple rows
3647 * The ff_er_add_slice calls don't work right for bottom
3648 * fields; they cause massive erroneous error concealing
3649 * Error marking covers both fields (top and bottom).
3650 * This causes a mismatched s->error_count
3651 * and a bad error table. Further, the error count goes to
3652 * INT_MAX when called for bottom field, because mb_y is
3653 * past end by one (callers fault) and resync_mb_y != 0
3654 * causes problems for the first MB line, too.
3655 */
3656 if (!FIELD_PICTURE)
3657 ff_er_frame_end(s);
3658
3659 MPV_frame_end(s);
3660 }
3661
3617 /** 3662 /**
3618 * Replicates H264 "master" context to thread contexts. 3663 * Replicates H264 "master" context to thread contexts.
3619 */ 3664 */
3620 static void clone_slice(H264Context *dst, H264Context *src) 3665 static void clone_slice(H264Context *dst, H264Context *src)
3621 { 3666 {
7717 if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){ 7762 if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){
7718 Picture *out = s->current_picture_ptr; 7763 Picture *out = s->current_picture_ptr;
7719 Picture *cur = s->current_picture_ptr; 7764 Picture *cur = s->current_picture_ptr;
7720 int i, pics, cross_idr, out_of_order, out_idx; 7765 int i, pics, cross_idr, out_of_order, out_idx;
7721 7766
7722 s->mb_y= 0; 7767 field_end(h);
7723
7724 s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
7725 s->current_picture_ptr->pict_type= s->pict_type;
7726
7727 if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
7728 ff_vdpau_h264_set_reference_frames(s);
7729
7730 if(!s->dropable) {
7731 execute_ref_pic_marking(h, h->mmco, h->mmco_index);
7732 h->prev_poc_msb= h->poc_msb;
7733 h->prev_poc_lsb= h->poc_lsb;
7734 }
7735 h->prev_frame_num_offset= h->frame_num_offset;
7736 h->prev_frame_num= h->frame_num;
7737
7738 if (avctx->hwaccel) {
7739 if (avctx->hwaccel->end_frame(avctx) < 0)
7740 av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
7741 }
7742
7743 if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
7744 ff_vdpau_h264_picture_complete(s);
7745
7746 /*
7747 * FIXME: Error handling code does not seem to support interlaced
7748 * when slices span multiple rows
7749 * The ff_er_add_slice calls don't work right for bottom
7750 * fields; they cause massive erroneous error concealing
7751 * Error marking covers both fields (top and bottom).
7752 * This causes a mismatched s->error_count
7753 * and a bad error table. Further, the error count goes to
7754 * INT_MAX when called for bottom field, because mb_y is
7755 * past end by one (callers fault) and resync_mb_y != 0
7756 * causes problems for the first MB line, too.
7757 */
7758 if (!FIELD_PICTURE)
7759 ff_er_frame_end(s);
7760
7761 MPV_frame_end(s);
7762 7768
7763 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { 7769 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) {
7764 /* Wait for second field. */ 7770 /* Wait for second field. */
7765 *data_size = 0; 7771 *data_size = 0;
7766 7772