Commit 998c9f15 authored by John Stebbins's avatar John Stebbins

idct: remove call to ff_idctdsp_init from ff_MPV_common_init

One step in untangling the mpegvideo code and fixing some problems in
the order that initialization is being done in h263dec and h261dec.
parent 93f29948
......@@ -309,10 +309,9 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
ff_blockdsp_init(&ctx->bdsp, avctx);
ff_fdctdsp_init(&ctx->m.fdsp, avctx);
ff_idctdsp_init(&ctx->m.idsp, avctx);
ff_mpv_idct_init(&ctx->m);
ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
ff_pixblockdsp_init(&ctx->m.pdsp, avctx);
ff_dct_common_init(&ctx->m);
if (!ctx->m.dct_quantize)
ctx->m.dct_quantize = ff_dct_quantize_c;
......
......@@ -581,10 +581,12 @@ static int h261_decode_frame(AVCodecContext *avctx, void *data,
retry:
init_get_bits(&s->gb, buf, buf_size * 8);
if (!s->context_initialized)
if (!s->context_initialized) {
// we need the IDCT permutaton for reading a custom matrix
ff_mpv_idct_init(s);
if (ff_MPV_common_init(s) < 0)
return -1;
}
ret = h261_decode_picture_header(h);
......
......@@ -113,9 +113,11 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
/* for h263, we allocate the images after having read the header */
if (avctx->codec->id != AV_CODEC_ID_H263 &&
avctx->codec->id != AV_CODEC_ID_MPEG4)
avctx->codec->id != AV_CODEC_ID_MPEG4) {
ff_mpv_idct_init(s);
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
}
ff_h263dsp_init(&s->h263dsp);
ff_qpeldsp_init(&s->qdsp);
......@@ -414,10 +416,12 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ret < 0)
return ret;
if (!s->context_initialized)
if (!s->context_initialized) {
// we need the idct permutaton for reading a custom matrix
ff_mpv_idct_init(s);
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
}
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
......
......@@ -1097,18 +1097,16 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
int i;
/* we need some permutation to store matrices,
* until MPV_common_init() sets the real permutation. */
for (i = 0; i < 64; i++)
s2->idsp.idct_permutation[i] = i;
ff_MPV_decode_defaults(s2);
s->mpeg_enc_ctx.avctx = avctx;
s->mpeg_enc_ctx.flags = avctx->flags;
s->mpeg_enc_ctx.flags2 = avctx->flags2;
/* we need some permutation to store matrices,
* until the decoder sets the real permutation. */
ff_mpv_idct_init(s2);
ff_mpeg12_common_init(&s->mpeg_enc_ctx);
ff_mpeg12_init_vlcs();
......@@ -1313,6 +1311,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
* if DCT permutation is changed. */
memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
ff_mpv_idct_init(s);
if (ff_MPV_common_init(s) < 0)
return -2;
......@@ -2151,6 +2150,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
#endif /* FF_API_XVMC */
avctx->idct_algo = FF_IDCT_SIMPLE;
ff_mpv_idct_init(s);
if (ff_MPV_common_init(s) < 0)
return -1;
s1->mpeg_enc_ctx_allocated = 1;
......
......@@ -375,11 +375,10 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
}
/* init common dct for both encoder and decoder */
av_cold int ff_dct_common_init(MpegEncContext *s)
static av_cold int dct_init(MpegEncContext *s)
{
ff_blockdsp_init(&s->bdsp, s->avctx);
ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
ff_idctdsp_init(&s->idsp, s->avctx);
ff_me_cmp_init(&s->mecc, s->avctx);
ff_mpegvideodsp_init(&s->mdsp);
ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
......@@ -403,6 +402,13 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
if (ARCH_X86)
ff_MPV_common_init_x86(s);
return 0;
}
av_cold void ff_mpv_idct_init(MpegEncContext *s)
{
ff_idctdsp_init(&s->idsp, s->avctx);
/* load & permutate scantables
* note: only wmv uses different ones
*/
......@@ -415,8 +421,6 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
}
ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
return 0;
}
static int frame_size_alloc(MpegEncContext *s, int linesize)
......@@ -910,6 +914,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
s->bitstream_buffer = NULL;
s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
ff_mpv_idct_init(s);
ff_MPV_common_init(s);
}
......@@ -1263,7 +1268,7 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
ff_dct_common_init(s);
dct_init(s);
s->flags = s->avctx->flags;
s->flags2 = s->avctx->flags2;
......
......@@ -720,7 +720,7 @@ 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);
int ff_dct_common_init(MpegEncContext *s);
void ff_mpv_idct_init(MpegEncContext *s);
void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64],
const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow);
......
......@@ -700,6 +700,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
s->alternate_scan);
/* init */
ff_mpv_idct_init(s);
if (ff_MPV_common_init(s) < 0)
return -1;
......
......@@ -498,6 +498,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
ff_mpv_idct_init(s);
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
......
......@@ -1488,6 +1488,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
avctx->has_b_frames = 1;
s->low_delay = 0;
ff_mpv_idct_init(s);
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
......@@ -1524,6 +1525,7 @@ int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
if (avctx->internal->is_copy) {
r->tmp_b_block_base = NULL;
ff_mpv_idct_init(&r->s);
if ((err = ff_MPV_common_init(&r->s)) < 0)
return err;
if ((err = rv34_decoder_alloc(r)) < 0) {
......
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