Commit 533bc4c0 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'd66e305b'

* commit 'd66e305b':
  er: move relevant fields from Picture to ERPicture

Conflicts:
	libavcodec/error_resilience.c
	libavcodec/h264.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 3dab9e80 d66e305b
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include "avcodec.h"
#include "dsputil.h"
#include "thread.h"
///< current MB is the first after a resync marker
#define VP_START 1
......@@ -37,6 +38,18 @@
#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END)
typedef struct ERPicture {
AVFrame *f;
ThreadFrame *tf;
// it's the caller responsability to allocate these buffers
int16_t (*motion_val[2])[2];
int8_t *ref_index[2];
uint32_t *mb_type;
int field_picture;
} ERPicture;
typedef struct ERContext {
AVCodecContext *avctx;
DSPContext *dsp;
......@@ -55,9 +68,9 @@ typedef struct ERContext {
uint8_t *mbintra_table;
int mv[2][4][2];
struct Picture *cur_pic;
struct Picture *last_pic;
struct Picture *next_pic;
ERPicture cur_pic;
ERPicture last_pic;
ERPicture next_pic;
uint16_t pp_time;
uint16_t pb_time;
......
......@@ -1990,7 +1990,7 @@ static int h264_frame_start(H264Context *h)
h->cur_pic_ptr = pic;
unref_picture(h, &h->cur_pic);
if (CONFIG_ERROR_RESILIENCE) {
h->er.cur_pic = NULL;
memset(&h->er.cur_pic, 0, sizeof(h->er.cur_pic));
}
if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
......@@ -1998,8 +1998,8 @@ static int h264_frame_start(H264Context *h)
if (CONFIG_ERROR_RESILIENCE) {
ff_er_frame_start(&h->er);
h->er.last_pic =
h->er.next_pic = NULL;
memset(&h->er.last_pic, 0, sizeof(h->er.last_pic));
memset(&h->er.next_pic, 0, sizeof(h->er.next_pic));
}
assert(h->linesize && h->uvlinesize);
......@@ -3049,7 +3049,7 @@ static int field_end(H264Context *h, int in_setup)
* causes problems for the first MB line, too.
*/
if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
h->er.cur_pic = h->cur_pic_ptr;
ff_mpeg_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
ff_er_frame_end(&h->er);
}
if (!in_setup && !h->droppable)
......@@ -4137,8 +4137,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
(h->ref_list[j][i].reference & 3);
}
if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
if (h->ref_count[0]) ff_mpeg_set_erpic(&h->er.last_pic, &h->ref_list[0][0]);
if (h->ref_count[1]) ff_mpeg_set_erpic(&h->er.next_pic, &h->ref_list[1][0]);
h->er.ref_count = h->ref_count[0];
h0->au_pps_id = pps_id;
h->sps.new =
......
......@@ -3195,13 +3195,32 @@ void ff_MPV_report_decode_progress(MpegEncContext *s)
}
#if CONFIG_ERROR_RESILIENCE
void ff_mpeg_set_erpic(ERPicture *dst, Picture *src)
{
int i;
if (!src)
return;
dst->f = &src->f;
dst->tf = &src->tf;
for (i = 0; i < 2; i++) {
dst->motion_val[i] = src->motion_val[i];
dst->ref_index[i] = src->ref_index[i];
}
dst->mb_type = src->mb_type;
dst->field_picture = src->field_picture;
}
void ff_mpeg_er_frame_start(MpegEncContext *s)
{
ERContext *er = &s->er;
er->cur_pic = s->current_picture_ptr;
er->last_pic = s->last_picture_ptr;
er->next_pic = s->next_picture_ptr;
ff_mpeg_set_erpic(&er->cur_pic, s->current_picture_ptr);
ff_mpeg_set_erpic(&er->next_pic, s->next_picture_ptr);
ff_mpeg_set_erpic(&er->last_pic, s->last_picture_ptr);
er->pp_time = s->pp_time;
er->pb_time = s->pb_time;
......
......@@ -830,7 +830,9 @@ void ff_MPV_report_decode_progress(MpegEncContext *s);
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
void ff_set_qscale(MpegEncContext * s, int qscale);
/* Error resilience */
void ff_mpeg_er_frame_start(MpegEncContext *s);
void ff_mpeg_set_erpic(ERPicture *dst, Picture *src);
int ff_dct_common_init(MpegEncContext *s);
int ff_dct_encode_init(MpegEncContext *s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment