mirror of
https://github.com/librempeg/librempeg
synced 2024-11-22 00:51:37 +00:00
avcodec/mpegvideo_dec: Set dct_unquantize ptrs only once when possible
Everything except dct_unquantize_intra for MPEG-4 need only be set once. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
64f0b12b07
commit
03517b4743
@ -110,6 +110,9 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
|
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MPEG4:
|
case AV_CODEC_ID_MPEG4:
|
||||||
|
// dct_unquantize_inter is only used with MPEG-2 quantizers,
|
||||||
|
// so we can already set dct_unquantize_inter here once and for all.
|
||||||
|
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_MSMPEG4V1:
|
case AV_CODEC_ID_MSMPEG4V1:
|
||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
@ -523,6 +526,11 @@ retry:
|
|||||||
goto retry;
|
goto retry;
|
||||||
if (s->studio_profile != (s->idsp.idct == NULL))
|
if (s->studio_profile != (s->idsp.idct == NULL))
|
||||||
ff_mpv_idct_init(s);
|
ff_mpv_idct_init(s);
|
||||||
|
if (s->mpeg_quant) {
|
||||||
|
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
|
||||||
|
} else {
|
||||||
|
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* After H.263 & MPEG-4 header decode we have the height, width,
|
/* After H.263 & MPEG-4 header decode we have the height, width,
|
||||||
|
@ -59,6 +59,13 @@ int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
|
|||||||
s->codec_tag = ff_toupper4(avctx->codec_tag);
|
s->codec_tag = ff_toupper4(avctx->codec_tag);
|
||||||
|
|
||||||
ff_mpv_idct_init(s);
|
ff_mpv_idct_init(s);
|
||||||
|
|
||||||
|
// dct_unquantize defaults for H.261 and H.263;
|
||||||
|
// they might change on a per-frame basis for MPEG-4.
|
||||||
|
// Unused by the MPEG-1/2 decoders.
|
||||||
|
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
|
||||||
|
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
|
||||||
|
|
||||||
ff_h264chroma_init(&s->h264chroma, 8); //for lowres
|
ff_h264chroma_init(&s->h264chroma, 8); //for lowres
|
||||||
|
|
||||||
if (s->picture_pool) // VC-1 can call this multiple times
|
if (s->picture_pool) // VC-1 can call this multiple times
|
||||||
@ -393,20 +400,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* set dequantizer, we can't do it during init as
|
|
||||||
* it might change for MPEG-4 and we can't do it in the header
|
|
||||||
* decode as init is not called for MPEG-4 there yet */
|
|
||||||
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
|
||||||
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
|
|
||||||
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
|
|
||||||
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
|
|
||||||
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
|
|
||||||
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
|
|
||||||
} else {
|
|
||||||
s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
|
|
||||||
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->avctx->debug & FF_DEBUG_NOMC)
|
if (s->avctx->debug & FF_DEBUG_NOMC)
|
||||||
color_frame(s->cur_pic.ptr->f, 0x80);
|
color_frame(s->cur_pic.ptr->f, 0x80);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user