diff options
Diffstat (limited to 'libavcodec/h264_picture.c')
-rw-r--r-- | libavcodec/h264_picture.c | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index 24ba79d..e833835 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -2,20 +2,20 @@ * H.26L/H.264/AVC/JVT/14496-10/... decoder * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -69,8 +69,8 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) av_assert0(!dst->f->buf[0]); av_assert0(src->f->buf[0]); + av_assert0(src->tf.f == src->f); - src->tf.f = src->f; dst->tf.f = dst->f; ret = ff_thread_ref_frame(&dst->tf, &src->tf); if (ret < 0) @@ -78,24 +78,30 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf); dst->mb_type_buf = av_buffer_ref(src->mb_type_buf); - if (!dst->qscale_table_buf || !dst->mb_type_buf) + if (!dst->qscale_table_buf || !dst->mb_type_buf) { + ret = AVERROR(ENOMEM); goto fail; + } dst->qscale_table = src->qscale_table; dst->mb_type = src->mb_type; for (i = 0; i < 2; i++) { dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]); dst->ref_index_buf[i] = av_buffer_ref(src->ref_index_buf[i]); - if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i]) + if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i]) { + ret = AVERROR(ENOMEM); goto fail; + } dst->motion_val[i] = src->motion_val[i]; dst->ref_index[i] = src->ref_index[i]; } if (src->hwaccel_picture_private) { dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) + if (!dst->hwaccel_priv_buf) { + ret = AVERROR(ENOMEM); goto fail; + } dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; } @@ -108,12 +114,13 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) dst->poc = src->poc; dst->frame_num = src->frame_num; dst->mmco_reset = src->mmco_reset; - dst->pic_id = src->pic_id; dst->long_ref = src->long_ref; dst->mbaff = src->mbaff; dst->field_picture = src->field_picture; dst->reference = src->reference; dst->recovered = src->recovered; + dst->invalid_gap = src->invalid_gap; + dst->sei_recovery_frame_cnt = src->sei_recovery_frame_cnt; return 0; fail: @@ -121,11 +128,13 @@ fail: return ret; } -#if CONFIG_ERROR_RESILIENCE -static void h264_set_erpic(ERPicture *dst, H264Picture *src) +void ff_h264_set_erpic(ERPicture *dst, H264Picture *src) { +#if CONFIG_ERROR_RESILIENCE int i; + memset(dst, 0, sizeof(*dst)); + if (!src) return; @@ -139,8 +148,8 @@ static void h264_set_erpic(ERPicture *dst, H264Picture *src) dst->mb_type = src->mb_type; dst->field_picture = src->field_picture; -} #endif /* CONFIG_ERROR_RESILIENCE */ +} int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) { @@ -148,10 +157,6 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) int err = 0; h->mb_y = 0; - if (!in_setup && !h->droppable) - ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, - h->picture_structure == PICT_BOTTOM_FIELD); - if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) { if (!h->droppable) { err = ff_h264_execute_ref_pic_marking(h); @@ -163,38 +168,18 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) } if (avctx->hwaccel) { - if (avctx->hwaccel->end_frame(avctx) < 0) + err = avctx->hwaccel->end_frame(avctx); + if (err < 0) av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n"); } -#if CONFIG_ERROR_RESILIENCE - /* - * FIXME: Error handling code does not seem to support interlaced - * when slices span multiple rows - * The ff_er_add_slice calls don't work right for bottom - * fields; they cause massive erroneous error concealing - * Error marking covers both fields (top and bottom). - * This causes a mismatched s->error_count - * and a bad error table. Further, the error count goes to - * INT_MAX when called for bottom field, because mb_y is - * past end by one (callers fault) and resync_mb_y != 0 - * causes problems for the first MB line, too. - */ - if (!FIELD_PICTURE(h) && h->enable_er) { - h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr); - h264_set_erpic(&sl->er.last_pic, - sl->ref_count[0] ? sl->ref_list[0][0].parent : NULL); - h264_set_erpic(&sl->er.next_pic, - sl->ref_count[1] ? sl->ref_list[1][0].parent : NULL); - ff_er_frame_end(&sl->er); - } -#endif /* CONFIG_ERROR_RESILIENCE */ - + if (!in_setup && !h->droppable) + ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, + h->picture_structure == PICT_BOTTOM_FIELD); emms_c(); h->current_slice = 0; - h->field_started = 0; return err; } |