Commit cf1e0786 authored by Anton Khirnov's avatar Anton Khirnov

error_resilience: move the MECmpContext initialization into ER code

Currently, it needs to be initialized by the ER caller (which is
currently either a mpegvideo decoder or h264dec). However, since none of
those decoders use MECmpContext for anything except ER, it makes more
sense to handle it purely inside ER.
parent a7e03804
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "avcodec.h" #include "avcodec.h"
#include "error_resilience.h" #include "error_resilience.h"
#include "me_cmp.h"
#include "mpegutils.h" #include "mpegutils.h"
#include "mpegvideo.h" #include "mpegvideo.h"
#include "rectangle.h" #include "rectangle.h"
...@@ -713,11 +714,11 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -713,11 +714,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
} else { } else {
ff_thread_await_progress(s->last_pic.tf, mb_y, 0); ff_thread_await_progress(s->last_pic.tf, mb_y, 0);
} }
is_intra_likely += s->mecc->sad[0](NULL, last_mb_ptr, mb_ptr, is_intra_likely += s->mecc.sad[0](NULL, last_mb_ptr, mb_ptr,
linesize[0], 16); linesize[0], 16);
is_intra_likely -= s->mecc->sad[0](NULL, last_mb_ptr, is_intra_likely -= s->mecc.sad[0](NULL, last_mb_ptr,
last_mb_ptr + linesize[0] * 16, last_mb_ptr + linesize[0] * 16,
linesize[0], 16); linesize[0], 16);
} else { } else {
if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
is_intra_likely++; is_intra_likely++;
...@@ -734,6 +735,11 @@ void ff_er_frame_start(ERContext *s) ...@@ -734,6 +735,11 @@ void ff_er_frame_start(ERContext *s)
if (!s->avctx->error_concealment) if (!s->avctx->error_concealment)
return; return;
if (!s->mecc_inited) {
ff_me_cmp_init(&s->mecc, s->avctx);
s->mecc_inited = 1;
}
memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END, memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END,
s->mb_stride * s->mb_height * sizeof(uint8_t)); s->mb_stride * s->mb_height * sizeof(uint8_t));
s->error_count = 3 * s->mb_num; s->error_count = 3 * s->mb_num;
......
...@@ -52,7 +52,8 @@ typedef struct ERPicture { ...@@ -52,7 +52,8 @@ typedef struct ERPicture {
typedef struct ERContext { typedef struct ERContext {
AVCodecContext *avctx; AVCodecContext *avctx;
MECmpContext *mecc; MECmpContext mecc;
int mecc_inited;
int *mb_index2xy; int *mb_index2xy;
int mb_num; int mb_num;
......
...@@ -490,7 +490,6 @@ int ff_h264_context_init(H264Context *h) ...@@ -490,7 +490,6 @@ int ff_h264_context_init(H264Context *h)
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
/* init ER */ /* init ER */
er->avctx = h->avctx; er->avctx = h->avctx;
er->mecc = &h->mecc;
er->decode_mb = h264_er_decode_mb; er->decode_mb = h264_er_decode_mb;
er->opaque = h; er->opaque = h;
er->quarter_sample = 1; er->quarter_sample = 1;
...@@ -619,8 +618,6 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) ...@@ -619,8 +618,6 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
h->dequant_coeff_pps = -1; h->dequant_coeff_pps = -1;
/* needed so that IDCT permutation is known early */ /* needed so that IDCT permutation is known early */
if (CONFIG_ERROR_RESILIENCE)
ff_me_cmp_init(&h->mecc, h->avctx);
ff_videodsp_init(&h->vdsp, 8); ff_videodsp_init(&h->vdsp, 8);
memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t)); memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
...@@ -1231,8 +1228,6 @@ int ff_h264_set_parameter_from_sps(H264Context *h) ...@@ -1231,8 +1228,6 @@ int ff_h264_set_parameter_from_sps(H264Context *h)
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma); ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma, ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc); h->sps.chroma_format_idc);
if (CONFIG_ERROR_RESILIENCE)
ff_me_cmp_init(&h->mecc, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma); ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else { } else {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "h264dsp.h" #include "h264dsp.h"
#include "h264pred.h" #include "h264pred.h"
#include "h264qpel.h" #include "h264qpel.h"
#include "me_cmp.h"
#include "mpegutils.h" #include "mpegutils.h"
#include "parser.h" #include "parser.h"
#include "qpeldsp.h" #include "qpeldsp.h"
...@@ -302,7 +301,6 @@ typedef struct H264Picture { ...@@ -302,7 +301,6 @@ typedef struct H264Picture {
*/ */
typedef struct H264Context { typedef struct H264Context {
AVCodecContext *avctx; AVCodecContext *avctx;
MECmpContext mecc;
VideoDSPContext vdsp; VideoDSPContext vdsp;
H264DSPContext h264dsp; H264DSPContext h264dsp;
H264ChromaContext h264chroma; H264ChromaContext h264chroma;
......
...@@ -1112,7 +1112,6 @@ static int h264_slice_header_init(H264Context *h, int reinit) ...@@ -1112,7 +1112,6 @@ static int h264_slice_header_init(H264Context *h, int reinit)
if (!c) if (!c)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
c->avctx = h->avctx; c->avctx = h->avctx;
c->mecc = h->mecc;
c->vdsp = h->vdsp; c->vdsp = h->vdsp;
c->h264dsp = h->h264dsp; c->h264dsp = h->h264dsp;
c->h264qpel = h->h264qpel; c->h264qpel = h->h264qpel;
......
...@@ -381,7 +381,6 @@ static av_cold int dct_init(MpegEncContext *s) ...@@ -381,7 +381,6 @@ static av_cold int dct_init(MpegEncContext *s)
{ {
ff_blockdsp_init(&s->bdsp, s->avctx); ff_blockdsp_init(&s->bdsp, s->avctx);
ff_hpeldsp_init(&s->hdsp, s->avctx->flags); ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
ff_me_cmp_init(&s->mecc, s->avctx);
ff_mpegvideodsp_init(&s->mdsp); ff_mpegvideodsp_init(&s->mdsp);
ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample); ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
...@@ -1068,7 +1067,6 @@ static int init_er(MpegEncContext *s) ...@@ -1068,7 +1067,6 @@ static int init_er(MpegEncContext *s)
int i; int i;
er->avctx = s->avctx; er->avctx = s->avctx;
er->mecc = &s->mecc;
er->mb_index2xy = s->mb_index2xy; er->mb_index2xy = s->mb_index2xy;
er->mb_num = s->mb_num; er->mb_num = s->mb_num;
......
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