You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/mpegvideo_dec: Simplify check for unquantizing inter blocks
Just ensure that dct_unquantize_inter is set iff it is used and check for the function pointer instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -110,7 +110,8 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
|
|||||||
ff_mpv_unquantize_init(&unquant_dsp_ctx,
|
ff_mpv_unquantize_init(&unquant_dsp_ctx,
|
||||||
avctx->flags & AV_CODEC_FLAG_BITEXACT, 0);
|
avctx->flags & AV_CODEC_FLAG_BITEXACT, 0);
|
||||||
// dct_unquantize defaults for H.263;
|
// dct_unquantize defaults for H.263;
|
||||||
// they might change on a per-frame basis for MPEG-4.
|
// they might change on a per-frame basis for MPEG-4;
|
||||||
|
// dct_unquantize_inter will be unset for MSMPEG4 codecs later.
|
||||||
s->dct_unquantize_intra = unquant_dsp_ctx.dct_unquantize_h263_intra;
|
s->dct_unquantize_intra = unquant_dsp_ctx.dct_unquantize_h263_intra;
|
||||||
s->dct_unquantize_inter = unquant_dsp_ctx.dct_unquantize_h263_inter;
|
s->dct_unquantize_inter = unquant_dsp_ctx.dct_unquantize_h263_inter;
|
||||||
|
|
||||||
|
@ -3417,6 +3417,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
|
|||||||
|
|
||||||
s->dct_unquantize_intra = s->mpeg_quant ? ctx->dct_unquantize_mpeg2_intra
|
s->dct_unquantize_intra = s->mpeg_quant ? ctx->dct_unquantize_mpeg2_intra
|
||||||
: ctx->dct_unquantize_h263_intra;
|
: ctx->dct_unquantize_h263_intra;
|
||||||
|
// The following tells ff_mpv_reconstruct_mb() to unquantize iff mpeg_quant
|
||||||
|
s->dct_unquantize_inter = s->mpeg_quant ? ctx->dct_unquantize_mpeg2_inter : NULL;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
/* detect buggy encoders which don't set the low_delay flag
|
/* detect buggy encoders which don't set the low_delay flag
|
||||||
@ -3961,8 +3963,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
ctx->dct_unquantize_h263_intra = unquant_dsp_ctx.dct_unquantize_h263_intra;
|
ctx->dct_unquantize_h263_intra = unquant_dsp_ctx.dct_unquantize_h263_intra;
|
||||||
ctx->dct_unquantize_mpeg2_intra = unquant_dsp_ctx.dct_unquantize_mpeg2_intra;
|
ctx->dct_unquantize_mpeg2_intra = unquant_dsp_ctx.dct_unquantize_mpeg2_intra;
|
||||||
// dct_unquantize_inter is only used with MPEG-2 quantizers,
|
// dct_unquantize_inter is only used with MPEG-2 quantizers,
|
||||||
// so we can already set dct_unquantize_inter here once and for all.
|
// so that is all we keep.
|
||||||
s->dct_unquantize_inter = unquant_dsp_ctx.dct_unquantize_mpeg2_inter;
|
ctx->dct_unquantize_mpeg2_inter = unquant_dsp_ctx.dct_unquantize_mpeg2_inter;
|
||||||
|
|
||||||
s->y_dc_scale_table = ff_mpeg4_y_dc_scale_table;
|
s->y_dc_scale_table = ff_mpeg4_y_dc_scale_table;
|
||||||
s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table;
|
s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table;
|
||||||
|
@ -91,6 +91,8 @@ typedef struct Mpeg4DecContext {
|
|||||||
|
|
||||||
Mpeg4VideoDSPContext mdsp;
|
Mpeg4VideoDSPContext mdsp;
|
||||||
|
|
||||||
|
void (*dct_unquantize_mpeg2_inter)(MpegEncContext *s,
|
||||||
|
int16_t *block, int n, int qscale);
|
||||||
void (*dct_unquantize_mpeg2_intra)(MpegEncContext *s,
|
void (*dct_unquantize_mpeg2_intra)(MpegEncContext *s,
|
||||||
int16_t *block, int n, int qscale);
|
int16_t *block, int n, int qscale);
|
||||||
void (*dct_unquantize_h263_intra)(MpegEncContext *s,
|
void (*dct_unquantize_h263_intra)(MpegEncContext *s,
|
||||||
|
@ -960,11 +960,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add dct residue */
|
/* add dct residue */
|
||||||
if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
|
if (is_mpeg12 != DEFINITELY_MPEG12_H261 && s->dct_unquantize_inter) {
|
||||||
(s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) {
|
|
||||||
// H.263, H.263+, H.263I, FLV, RV10, RV20 and MPEG-4 with MPEG-2 quantization
|
// H.263, H.263+, H.263I, FLV, RV10, RV20 and MPEG-4 with MPEG-2 quantization
|
||||||
// Also RV30, RV40 when performing error resilience, but
|
|
||||||
// all blocks are skipped in this case.
|
|
||||||
add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
|
add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
|
||||||
add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
|
add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
|
||||||
add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
|
add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
|
||||||
@ -978,7 +975,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
|
|||||||
} else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
|
} else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
|
||||||
// H.261, MPEG-1, MPEG-2, MPEG-4 with H.263 quantization,
|
// H.261, MPEG-1, MPEG-2, MPEG-4 with H.263 quantization,
|
||||||
// MSMP4V1-3 and WMV1.
|
// MSMP4V1-3 and WMV1.
|
||||||
// Also the VC-1 family when performing error resilience
|
// Also RV30, RV40 and the VC-1 family when performing error resilience,
|
||||||
|
// but all blocks are skipped in this case.
|
||||||
add_dct(s, block[0], 0, dest_y , dct_linesize);
|
add_dct(s, block[0], 0, dest_y , dct_linesize);
|
||||||
add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
|
add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
|
||||||
add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
|
add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
|
||||||
|
@ -366,6 +366,9 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
|
|||||||
if (ff_h263_decode_init(avctx) < 0)
|
if (ff_h263_decode_init(avctx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
// We unquantize inter blocks as we parse them.
|
||||||
|
s->dct_unquantize_inter = NULL;
|
||||||
|
|
||||||
ff_msmpeg4_common_init(s);
|
ff_msmpeg4_common_init(s);
|
||||||
|
|
||||||
switch (s->msmpeg4_version) {
|
switch (s->msmpeg4_version) {
|
||||||
|
Reference in New Issue
Block a user