Commit d66e305b authored by Vittorio Giovara's avatar Vittorio Giovara

er: move relevant fields from Picture to ERPicture

This is done to disentangle ER from mpegvideo. In order to use a
classic Picture, callers can use ff_mpeg_set_erpic() or use a custom function
to set the fields. Please note that buffers need to be allocated before
calling ff_er_frame_end().
parent 1c79b162
This diff is collapsed.
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
#include "thread.h"
///< current MB is the first after a resync marker ///< current MB is the first after a resync marker
#define VP_START 1 #define VP_START 1
...@@ -37,6 +38,18 @@ ...@@ -37,6 +38,18 @@
#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR) #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) #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 { typedef struct ERContext {
AVCodecContext *avctx; AVCodecContext *avctx;
DSPContext *dsp; DSPContext *dsp;
...@@ -55,9 +68,9 @@ typedef struct ERContext { ...@@ -55,9 +68,9 @@ typedef struct ERContext {
uint8_t *mbintra_table; uint8_t *mbintra_table;
int mv[2][4][2]; int mv[2][4][2];
struct Picture *cur_pic; ERPicture cur_pic;
struct Picture *last_pic; ERPicture last_pic;
struct Picture *next_pic; ERPicture next_pic;
uint16_t pp_time; uint16_t pp_time;
uint16_t pb_time; uint16_t pb_time;
......
...@@ -2974,9 +2974,11 @@ static int field_end(H264Context *h, int in_setup) ...@@ -2974,9 +2974,11 @@ static int field_end(H264Context *h, int in_setup)
* causes problems for the first MB line, too. * causes problems for the first MB line, too.
*/ */
if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h)) { if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h)) {
h->er.cur_pic = h->cur_pic_ptr; ff_mpeg_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL; ff_mpeg_set_erpic(&h->er.last_pic,
h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL; h->ref_count[0] ? &h->ref_list[0][0] : NULL);
ff_mpeg_set_erpic(&h->er.next_pic,
h->ref_count[1] ? &h->ref_list[1][0] : NULL);
ff_er_frame_end(&h->er); ff_er_frame_end(&h->er);
} }
emms_c(); emms_c();
......
...@@ -2482,13 +2482,32 @@ void ff_MPV_report_decode_progress(MpegEncContext *s) ...@@ -2482,13 +2482,32 @@ void ff_MPV_report_decode_progress(MpegEncContext *s)
} }
#if CONFIG_ERROR_RESILIENCE #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) void ff_mpeg_er_frame_start(MpegEncContext *s)
{ {
ERContext *er = &s->er; ERContext *er = &s->er;
er->cur_pic = s->current_picture_ptr; ff_mpeg_set_erpic(&er->cur_pic, s->current_picture_ptr);
er->last_pic = s->last_picture_ptr; ff_mpeg_set_erpic(&er->next_pic, s->next_picture_ptr);
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->pp_time = s->pp_time;
er->pb_time = s->pb_time; er->pb_time = s->pb_time;
......
...@@ -799,7 +799,9 @@ void ff_MPV_report_decode_progress(MpegEncContext *s); ...@@ -799,7 +799,9 @@ void ff_MPV_report_decode_progress(MpegEncContext *s);
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
void ff_set_qscale(MpegEncContext * s, int qscale); void ff_set_qscale(MpegEncContext * s, int qscale);
/* Error resilience */
void ff_mpeg_er_frame_start(MpegEncContext *s); 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_common_init(MpegEncContext *s);
void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
......
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