From patchwork Mon Apr 29 21:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48414 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp2273305pzb; Mon, 29 Apr 2024 14:21:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVj8zgGOGThUIAuu/xGaQglOOX88qd35IbSnwit7D/hgNMpBFyZzgE7c/un+ZagBMW/M5ZBH5OibENOuyWBaL+6iQxxCGH72QFDkA== X-Google-Smtp-Source: AGHT+IH1HVuXz66Z1sd8h2/9S6UvmC7yJrT0wEsime3Itod007/SRPb1tjAMUsupfFjaD1KYawnx X-Received: by 2002:a17:906:3c51:b0:a58:c571:1146 with SMTP id i17-20020a1709063c5100b00a58c5711146mr6485249ejg.7.1714425697369; Mon, 29 Apr 2024 14:21:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g16-20020a1709061c9000b00a51c828f471si14260304ejh.1027.2024.04.29.14.21.37; Mon, 29 Apr 2024 14:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=svMelqGb; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A000E68D675; Tue, 30 Apr 2024 00:19:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2076.outbound.protection.outlook.com [40.92.91.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0D1368D66D for ; Tue, 30 Apr 2024 00:19:22 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bOE5ResYlMXyxVsRKi5ucrB9pYwPK3fGCmQjoCCDuBFdsDaCvomnL9VuUKQKk0lpRCcgy4NhhiiemuUOphT8yMXo8KVLRSRytISJSlUbXUqQnlsbmnod4b162fadSrP+InGAzZGx/4EWtO9CiSQf98KxS/qeIXYYbe++fkd+7kSY0hrBS+FucuzMU4Kj3wMCI2yvkhftO3xOKMQULAZ4+BShD9D6kazgCrdied20b1M1wg7TxTSXRkA8UiM3RFxJZjaUpxA31XM5YQzLhQdMiF6e1pC8DMv/S7+KFpBULj84ksE6wnnk9AMo5cw28tQYyC53ehEIZs07dFQRQ0M9Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AJD93wCfRe3bNlgV3Gjtm/3DIkwhzVPuksnhmxlo+yU=; b=BH7ImjfOm5wfS+OHyQdNTXJ69joDWTeMW9HSFDfXG+U1atMGiG9eT2BljxwVJ8MHkPinLc1vEryv4EHgI3uEJmIwAO7z6Nt1WpbVkyBIY8AFYxOVtrDQWE0N75RcZoZZwC/Ce9pA7Sh/2CtF76vhs+PYf36HKanDTcrK+LLJE0obyaZkL7J8nSslQdp7PXMtmI3SdrRA7wTCyP80juuS4UnYYE/lNveecIBDTajhvNHZPKeOhpdP1+6OcpPGAxFFfoYNXABwBEcfqrhczGvx1GESbvbuPemuRa4sRTKx5OIDYd8xKNyHLJ7W80W8dB2c4Roqwk+lgcbzXoqL4mHvFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AJD93wCfRe3bNlgV3Gjtm/3DIkwhzVPuksnhmxlo+yU=; b=svMelqGbAN54pxcVNyBhmEKQyqdK1zhUf0VStb/5vB/xsEDepWa8kkFF/HXOssYQ3ZzvFrc9fT7QvqjGDkb/2PHdsTxFH1Ji3mWxMaUmjW/3SAk+hMLB+VRu8RsNKteu9ZIq5loXY/rA0dG1sLusN9jm+YTLCcx8QoNfiPUl0NivxM6FImHOZhh6fTRtamhNJGGtiCdGU6XyPVUWmOIEKPm+YL2jXSfJAfOYP7IfMAlIXt1KniYsH8tdAvKRKLjzvSSRUKSRNrS5kOngqJ0Xc1JRoX2afvmUA6Vb2MXDkVwhm7GDsHqG0NiUuMgy90M4UGE3OYcbsOIwSgEtR7CoEQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0616.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 21:19:20 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 21:19:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Apr 2024 23:14:37 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [LvIbm+NeXUGnqR2wCwu6W9xk0uR4YmGpC7DnWIz5AM8=] X-ClientProxiedBy: ZR0P278CA0199.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:6a::21) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240429211438.3274834-42-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0616:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e026ebf-844e-4c7b-5a88-08dc689208a7 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: vvhPelMG9UNBWwcLD0qvJrna++BhtwL4d09gItDVo0dLz3vsv0Hx1YewZEsJ9vBCFcIBmjZTbEHPsMK3m2x69Bip4Vm9bUSv/T/ZOcIegqtLpX1+mfXRIxlEC090kP7y2bS4idgIh5Jzk+pnOvuBxPZCHtXqLDxx8pyTgZjxPAIgpHo7KVhJkLDyi9iCGh9sEnQau3QfW0Qzmj4o5KFoGk/Lhn9Z0DuXrYcjY/lwNjvb0WWcLMln+pvgv6q7PM4yCWWJa6t1/k4DJ857EiQfWap3E9wSBF0zbh5osaq8ZXCrfx3IM9fAL5VUZATYR74e+CaG3gqNQS5h+K8NvR2bzEvuwOC+I928f+PE199CS0Qv7ijkUOETz7vovwbrxgmyxqJ4oAWeMmF7FuwlocRKiYJxqJrNT96JVsxqLLextrteYpbrFwPNKg3Y3uy/ltR1EQ8be4V3AwiEE2fgH4ZNPXW2Go9w/GP+FO1OD4dQmv93qdhMJFfhddrZz7IqCZ8O2QJWPPKn03rV3JV8XBGvEY0pg17ipyZw9zgUMPGtmR4LVqHpb/pi3EqwshA7IAtUM9gon2kTngPybwVIfXnuCWDGcQ2+bf2d7Aldd9cboaA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I/GZ+nJLDMdeG7J6RR30h5Egv0lBqaUZUGZfh568YsEu5Qbkj406GDTTy3KreVywICgrI5RlLj4oBOmgez9NFbYEG3M3o7/5Tp5bU2C0sgPZnJ4HMam3pIfBp4xcd6T9xQeRSST/mj1wrmA+fdBp4QV5VwQG9ZR4Ujl8THRa2T+tqfkDlopN+4iUz0L4tfL883OyyxjMYnW4txmYlJuWUA/uA293Wo1E/aRAH93emEittuMsCqEY/2QCKaHRe37ZrGqunvnWWdJ52pj9seGlcoCPZZ25NcC+SrlXQc12OzJcE4NtISe0SCy9L9EMXkWxZojnVafJwyvoMCA6AJoetf9oLHdIs7fPDwB7wj9bbtoNlIqb/b8QzKOFWCAffnYARebdZP3de4jC5pwu/7TgpuFGAg81psFG6c7A0PUKRJ3X/pvdcRM59xOXbH63hvE2Wa7bXSUcQCXgWgF43POBBzUbj4LHpv8MhlATeSPn5hm7sTw57qrGqfcY+5KmXuiblxBE7Xc/+DyNRn+/vWPbvtLLNa8/RnYbUsEthThmDqL2f3zxigWVNeLy+6iMSiGNKZ8btJosWRsr1yfVNQLSGWP5TKsrCLck73L/DLc/mejMe0vlkYGUhLlHIXtncI0pqIRacOAhFIjlzpfJ1VgAQ7R6j51ZJGbrCYSYiLMeec5LaKJ62RDKpSM/qu3sczSBFr1OOgxbBITlROyVNvFInv3X5hkTO5s17FVzIHsPT/7AjxT6QSsZco6XmFBUBrtq6tQrMHUEYeZFWbxVLERFh6pYFDWa7J8BFzW9SWi0PhNSourczwaI35n9eWiYOnkntzP2dq9oFp0hY6oT9QOgYZBJo+9AvEtZ8nH6y4okPfBoqDXoHuCLy5cQDEtpbhGKK+mkpNx93VaB7q1pa2FNNURH/GY7Fu2isOm3oWlTofbb2OYdNT6TrmmhCYF3S8xVlaP0J3IZYGjcqc90wuHGwLbeQRMTmxGSND6G++Y6jZV7e9Z9ysk/P8EO7shr8frV+0p2PTTxkHJoMpXXf/ilXaoPs8SSzNYYfquJX3ipph4owq6UQtOae67/fF9X0Tu6EwvrzeB6W5Zg0BuRIStALSciwbP+25pVzco64hR87W/qxqkMXQ/u3om0aOT9VV04o43wUHJdWEzCtcwB9AdhsJ6XLjoD7C3PYDgYKUp8wG+0ArMEqjAzD+Few8ej/TF3gLPsMao/m9vCvniC8WqZTvih1TsI8E3vrMRbYMnb5Gpc+EXu81LEuYqkJJd6kTMA4REPHBZq2wnSHavf+eWluQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e026ebf-844e-4c7b-5a88-08dc689208a7 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 21:19:20.1952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0616 Subject: [FFmpeg-devel] [PATCH 56/57] avcodec/mpegvideo: Use enum for msmpeg4_version X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SnTHYA2apCAV Improves readability. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 34 ++++++------ libavcodec/motion_est.c | 8 +-- libavcodec/mpegvideo.c | 6 +-- libavcodec/mpegvideo.h | 10 +++- libavcodec/mpegvideo_enc.c | 28 ++++++---- libavcodec/mpv_reconstruct_mb_template.c | 2 +- libavcodec/msmpeg4.c | 17 +++--- libavcodec/msmpeg4dec.c | 68 ++++++++++++------------ libavcodec/msmpeg4enc.c | 37 ++++++------- libavcodec/vc1dec.c | 2 +- 10 files changed, 114 insertions(+), 98 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index b9762be9c9..eee7978452 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -113,23 +113,23 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) break; case AV_CODEC_ID_MSMPEG4V1: s->h263_pred = 1; - s->msmpeg4_version = 1; + s->msmpeg4_version = MSMP4_V1; break; case AV_CODEC_ID_MSMPEG4V2: s->h263_pred = 1; - s->msmpeg4_version = 2; + s->msmpeg4_version = MSMP4_V2; break; case AV_CODEC_ID_MSMPEG4V3: s->h263_pred = 1; - s->msmpeg4_version = 3; + s->msmpeg4_version = MSMP4_V3; break; case AV_CODEC_ID_WMV1: s->h263_pred = 1; - s->msmpeg4_version = 4; + s->msmpeg4_version = MSMP4_WMV1; break; case AV_CODEC_ID_WMV2: s->h263_pred = 1; - s->msmpeg4_version = 5; + s->msmpeg4_version = MSMP4_WMV2; break; case AV_CODEC_ID_H263I: break; @@ -227,7 +227,7 @@ static int decode_slice(MpegEncContext *s) for (; s->mb_y < s->mb_height; s->mb_y++) { /* per-row end of slice checks */ - if (s->msmpeg4_version) { + if (s->msmpeg4_version != MSMP4_UNUSED) { if (s->resync_mb_y + s->slice_height == s->mb_y) { ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1, s->mb_y, ER_MB_END); @@ -236,7 +236,7 @@ static int decode_slice(MpegEncContext *s) } } - if (s->msmpeg4_version == 1) { + if (s->msmpeg4_version == MSMP4_V1) { s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128; @@ -375,12 +375,12 @@ static int decode_slice(MpegEncContext *s) } // handle formats which don't have unique end markers - if (s->msmpeg4_version || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly + if (s->msmpeg4_version != MSMP4_UNUSED || (s->workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly int left = get_bits_left(&s->gb); int max_extra = 7; /* no markers in M$ crap */ - if (s->msmpeg4_version && s->pict_type == AV_PICTURE_TYPE_I) + if (s->msmpeg4_version != MSMP4_UNUSED && s->pict_type == AV_PICTURE_TYPE_I) max_extra += 17; /* buggy padding but the frame should still end approximately at @@ -474,10 +474,12 @@ retry: return ret; /* let's go :-) */ - if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { + if (CONFIG_WMV2_DECODER && s->msmpeg4_version == MSMP4_WMV2) { ret = ff_wmv2_decode_picture_header(s); - } else if (CONFIG_MSMPEG4DEC && s->msmpeg4_version) { +#if CONFIG_MSMPEG4DEC + } else if (s->msmpeg4_version != MSMP4_UNUSED) { ret = ff_msmpeg4_decode_picture_header(s); +#endif } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0); s->skipped_last_frame = (ret == FRAME_SKIPPED); @@ -583,13 +585,15 @@ retry: /* the second part of the wmv2 header contains the MB skip bits which * are stored in current_picture->mb_type which is not available before * ff_mpv_frame_start() */ - if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) { +#if CONFIG_WMV2_DECODER + if (s->msmpeg4_version == MSMP4_WMV2) { ret = ff_wmv2_decode_secondary_picture_header(s); if (ret < 0) return ret; if (ret == 1) goto frame_end; } +#endif /* decode each macroblock */ s->mb_x = 0; @@ -597,7 +601,7 @@ retry: slice_ret = decode_slice(s); while (s->mb_y < s->mb_height) { - if (s->msmpeg4_version) { + if (s->msmpeg4_version != MSMP4_UNUSED) { if (s->slice_height == 0 || s->mb_x != 0 || slice_ret < 0 || (s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0) break; @@ -609,14 +613,14 @@ retry: s->er.error_occurred = 1; } - if (s->msmpeg4_version < 4 && s->h263_pred) + if (s->msmpeg4_version < MSMP4_WMV1 && s->h263_pred) ff_mpeg4_clean_buffers(s); if (decode_slice(s) < 0) slice_ret = AVERROR_INVALIDDATA; } - if (s->msmpeg4_version && s->msmpeg4_version < 4 && + if (s->msmpeg4_version != MSMP4_UNUSED && s->msmpeg4_version < MSMP4_WMV1 && s->pict_type == AV_PICTURE_TYPE_I) if (!CONFIG_MSMPEG4DEC || ff_msmpeg4_decode_ext_header(s, buf_size) < 0) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 892e2a3d08..cab66bff0c 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1608,7 +1608,7 @@ int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type int best_fcode=-1; int best_score=-10000000; - if(s->msmpeg4_version) + if (s->msmpeg4_version != MSMP4_UNUSED) range= FFMIN(range, 16); else if(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) range= FFMIN(range, 256); @@ -1659,9 +1659,9 @@ void ff_fix_long_p_mvs(MpegEncContext * s, int type) int y, range; av_assert0(s->pict_type==AV_PICTURE_TYPE_P); - range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code); + range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version != MSMP4_UNUSED) ? 8 : 16) << f_code); - av_assert0(range <= 16 || !s->msmpeg4_version); + av_assert0(range <= 16 || s->msmpeg4_version == MSMP4_UNUSED); av_assert0(range <=256 || !(s->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL)); if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range; @@ -1708,7 +1708,7 @@ void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_ int y, h_range, v_range; // RAL: 8 in MPEG-1, 16 in MPEG-4 - int range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code); + int range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version != MSMP4_UNUSED) ? 8 : 16) << f_code); if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 3cb8d06914..ec0f2d5bed 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -381,7 +381,7 @@ static int init_duplicate_context(MpegEncContext *s) s->block = s->blocks[0]; if (s->out_format == FMT_H263) { - int mb_height = s->msmpeg4_version == 6 /* VC-1 like */ ? + int mb_height = s->msmpeg4_version == MSMP4_VC1 ? FFALIGN(s->mb_height, 2) : s->mb_height; int y_size = s->b8_stride * (2 * mb_height + 1); int c_size = s->mb_stride * (mb_height + 1); @@ -535,7 +535,7 @@ int ff_mpv_init_context_frame(MpegEncContext *s) /* VC-1 can change from being progressive to interlaced on a per-frame * basis. We therefore allocate certain buffers so big that they work * in both instances. */ - mb_height = s->msmpeg4_version == 6 /* VC-1 like*/ ? + mb_height = s->msmpeg4_version == MSMP4_VC1 ? FFALIGN(s->mb_height, 2) : s->mb_height; s->mb_width = (s->width + 15) / 16; @@ -592,7 +592,7 @@ int ff_mpv_init_context_frame(MpegEncContext *s) } } - if (s->msmpeg4_version >= 3) { + if (s->msmpeg4_version >= MSMP4_V3) { s->coded_block_base = av_mallocz(y_size); if (!s->coded_block_base) return AVERROR(ENOMEM); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 43d28a269a..70b9a55450 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -419,7 +419,15 @@ typedef struct MpegEncContext { int slice_height; ///< in macroblocks int first_slice_line; ///< used in MPEG-4 too to handle resync markers int flipflop_rounding; - int msmpeg4_version; ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8 + enum { + MSMP4_UNUSED, + MSMP4_V1, + MSMP4_V2, + MSMP4_V3, + MSMP4_WMV1, + MSMP4_WMV2, + MSMP4_VC1, ///< for VC1 (image), WMV3 (image) and MSS2. + } msmpeg4_version; int per_mb_rl_table; int esc3_level_length; int esc3_run_length; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ddd68f2da8..a59b414d88 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -754,7 +754,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->msmpeg4_version = 2; + s->msmpeg4_version = MSMP4_V2; avctx->delay = 0; s->low_delay = 1; break; @@ -762,7 +762,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->msmpeg4_version = 3; + s->msmpeg4_version = MSMP4_V3; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; @@ -771,7 +771,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->msmpeg4_version = 4; + s->msmpeg4_version = MSMP4_WMV1; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; @@ -780,7 +780,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->msmpeg4_version = 5; + s->msmpeg4_version = MSMP4_WMV2; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; @@ -916,8 +916,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) { ff_h263_encode_init(s); - if (CONFIG_MSMPEG4ENC && s->msmpeg4_version) +#if CONFIG_MSMPEG4ENC + if (s->msmpeg4_version != MSMP4_UNUSED) ff_msmpeg4_encode_init(s); +#endif } /* init q matrix */ @@ -3459,9 +3461,12 @@ static int encode_thread(AVCodecContext *c, void *arg){ } } +#if CONFIG_MSMPEG4ENC //not beautiful here but we must write it before flushing so it has to be here - if (CONFIG_MSMPEG4ENC && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I) + if (s->msmpeg4_version != MSMP4_UNUSED && s->msmpeg4_version < MSMP4_WMV1 && + s->pict_type == AV_PICTURE_TYPE_I) ff_msmpeg4_encode_ext_header(s); +#endif write_slice_end(s); @@ -3565,7 +3570,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt) /* we need to initialize some time vars before we can encode B-frames */ // RAL: Condition added for MPEG1VIDEO - if (s->out_format == FMT_MPEG1 || (s->h263_pred && !s->msmpeg4_version)) + if (s->out_format == FMT_MPEG1 || (s->h263_pred && s->msmpeg4_version == MSMP4_UNUSED)) set_frame_distances(s); if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4) ff_set_mpeg4_time(s); @@ -3575,8 +3580,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt) // s->lambda= s->cur_pic.ptr->quality; //FIXME qscale / ... stuff for ME rate distortion if(s->pict_type==AV_PICTURE_TYPE_I){ - if(s->msmpeg4_version >= 3) s->no_rounding=1; - else s->no_rounding=0; + s->no_rounding = s->msmpeg4_version >= MSMP4_V3; }else if(s->pict_type!=AV_PICTURE_TYPE_B){ if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4) s->no_rounding ^= 1; @@ -3658,7 +3662,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt) s->pict_type= AV_PICTURE_TYPE_I; for(i=0; imb_stride*s->mb_height; i++) s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; - if(s->msmpeg4_version >= 3) + if (s->msmpeg4_version >= MSMP4_V3) s->no_rounding=1; ff_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n", s->mb_var_sum, s->mc_mb_var_sum); @@ -3802,8 +3806,10 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt) case FMT_H263: if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2) ff_wmv2_encode_picture_header(s); - else if (CONFIG_MSMPEG4ENC && s->msmpeg4_version) +#if CONFIG_MSMPEG4ENC + else if (s->msmpeg4_version != MSMP4_UNUSED) ff_msmpeg4_encode_picture_header(s); +#endif else if (CONFIG_MPEG4_ENCODER && s->h263_pred) { ret = ff_mpeg4_encode_picture_header(s); if (ret < 0) diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c index 502e66faea..edabf2a8b4 100644 --- a/libavcodec/mpv_reconstruct_mb_template.c +++ b/libavcodec/mpv_reconstruct_mb_template.c @@ -173,7 +173,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], } /* add dct residue */ - if (!(IS_MPEG12(s) || s->msmpeg4_version || + if (!(IS_MPEG12(s) || s->msmpeg4_version != MSMP4_UNUSED || (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) #endif /* !IS_ENCODER */ { diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index f7ebb8ba89..50fd581a83 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -120,12 +120,12 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s) static AVOnce init_static_once = AV_ONCE_INIT; switch(s->msmpeg4_version){ - case 1: - case 2: + case MSMP4_V1: + case MSMP4_V2: s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; break; - case 3: + case MSMP4_V3: if(s->workaround_bugs){ s->y_dc_scale_table= ff_old_ff_y_dc_scale_table; s->c_dc_scale_table= ff_wmv1_c_dc_scale_table; @@ -134,14 +134,14 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s) s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table; } break; - case 4: - case 5: + case MSMP4_WMV1: + case MSMP4_WMV2: s->y_dc_scale_table= ff_wmv1_y_dc_scale_table; s->c_dc_scale_table= ff_wmv1_c_dc_scale_table; break; } - if(s->msmpeg4_version>=4){ + if (s->msmpeg4_version >= MSMP4_WMV1) { ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]); ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_wmv1_scantable[0]); ff_permute_scantable(s->permutated_intra_h_scantable, ff_wmv1_scantable[2], @@ -218,9 +218,8 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, b = dc_val[ - 1 - wrap]; c = dc_val[ - wrap]; - if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){ + if (s->first_slice_line && !(n & 2) && s->msmpeg4_version < MSMP4_WMV1) b=c=1024; - } /* XXX: the following solution consumes divisions, but it does not necessitate to modify mpegvideo.c. The problem comes from the @@ -259,7 +258,7 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, #endif /* XXX: WARNING: they did not choose the same test as MPEG-4. This is very important ! */ - if(s->msmpeg4_version>3){ + if (s->msmpeg4_version > MSMP4_V3) { if(s->inter_intra_pred){ uint8_t *dest; int wrap; diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index 4143c46c15..209e1fe1b2 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -125,7 +125,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) } } - if(s->msmpeg4_version==2) + if (s->msmpeg4_version == MSMP4_V2) code = get_vlc2(&s->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1); else code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); @@ -139,7 +139,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) cbp = code & 0x3; } else { s->mb_intra = 1; - if(s->msmpeg4_version==2) + if (s->msmpeg4_version == MSMP4_V2) cbp = get_vlc2(&s->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1); else cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2); @@ -159,7 +159,8 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) } cbp|= cbpy<<2; - if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C; + if (s->msmpeg4_version == MSMP4_V1 || (cbp&3) != 3) + cbp ^= 0x3C; ff_h263_pred_motion(s, 0, 0, &mx, &my); mx= msmpeg4v2_decode_motion(s, mx, 1); @@ -172,7 +173,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16; } else { int v; - if(s->msmpeg4_version==2){ + if (s->msmpeg4_version == MSMP4_V2) { s->ac_pred = get_bits1(&s->gb); v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (v < 0) { @@ -366,16 +367,16 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) ff_msmpeg4_common_init(s); - switch(s->msmpeg4_version){ - case 1: - case 2: + switch (s->msmpeg4_version) { + case MSMP4_V1: + case MSMP4_V2: s->decode_mb= msmpeg4v12_decode_mb; break; - case 3: - case 4: + case MSMP4_V3: + case MSMP4_WMV1: s->decode_mb= msmpeg4v34_decode_mb; break; - case 5: + case MSMP4_WMV2: break; } @@ -398,7 +399,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16)) return AVERROR_INVALIDDATA; - if(s->msmpeg4_version==1){ + if (s->msmpeg4_version == MSMP4_V1) { int start_code = get_bits_long(&s->gb, 32); if(start_code!=0x00000100){ av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n"); @@ -422,7 +423,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) if (s->pict_type == AV_PICTURE_TYPE_I) { code = get_bits(&s->gb, 5); - if(s->msmpeg4_version==1){ + if (s->msmpeg4_version == MSMP4_V1) { if(code==0 || code>s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code); return -1; @@ -440,20 +441,20 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) } switch(s->msmpeg4_version){ - case 1: - case 2: + case MSMP4_V1: + case MSMP4_V2: s->rl_chroma_table_index = 2; s->rl_table_index = 2; s->dc_table_index = 0; //not used break; - case 3: + case MSMP4_V3: s->rl_chroma_table_index = decode012(&s->gb); s->rl_table_index = decode012(&s->gb); s->dc_table_index = get_bits1(&s->gb); break; - case 4: + case MSMP4_WMV1: ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8); if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb); @@ -479,9 +480,9 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) s->slice_height); } else { switch(s->msmpeg4_version){ - case 1: - case 2: - if(s->msmpeg4_version==1) + case MSMP4_V1: + case MSMP4_V2: + if (s->msmpeg4_version == MSMP4_V1) s->use_skip_mb_code = 1; else s->use_skip_mb_code = get_bits1(&s->gb); @@ -490,7 +491,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) s->dc_table_index = 0; //not used s->mv_table_index = 0; break; - case 3: + case MSMP4_V3: s->use_skip_mb_code = get_bits1(&s->gb); s->rl_table_index = decode012(&s->gb); s->rl_chroma_table_index = s->rl_table_index; @@ -499,7 +500,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) s->mv_table_index = get_bits1(&s->gb); break; - case 4: + case MSMP4_WMV1: s->use_skip_mb_code = get_bits1(&s->gb); if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb); @@ -545,13 +546,13 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s) int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) { int left= buf_size*8 - get_bits_count(&s->gb); - int length= s->msmpeg4_version>=3 ? 17 : 16; + int length = s->msmpeg4_version >= MSMP4_V3 ? 17 : 16; /* the alt_bitstream reader could read over the end so we need to check it */ if(left>=length && leftgb, 5); /* fps */ s->bit_rate= get_bits(&s->gb, 11)*1024; - if(s->msmpeg4_version>=3) + if (s->msmpeg4_version >= MSMP4_V3) s->flipflop_rounding= get_bits1(&s->gb); else s->flipflop_rounding= 0; @@ -559,7 +560,7 @@ int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) else if(leftflipflop_rounding= 0; - if(s->msmpeg4_version != 2) + if (s->msmpeg4_version != MSMP4_V2) av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left); } else @@ -574,7 +575,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr) { int level, pred; - if(s->msmpeg4_version<=2){ + if (s->msmpeg4_version <= MSMP4_V2) { if (n < 4) { level = get_vlc2(&s->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3); } else { @@ -600,7 +601,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr) } } - if(s->msmpeg4_version==1){ + if (s->msmpeg4_version == MSMP4_V1) { int32_t *dc_val; pred = msmpeg4v1_pred_dc(s, n, &dc_val); level += pred; @@ -658,7 +659,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, } block[0] = level; - run_diff = s->msmpeg4_version >= 4; + run_diff = s->msmpeg4_version >= MSMP4_WMV1; i = 0; if (!coded) { goto not_coded; @@ -678,7 +679,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, i = -1; rl = &ff_rl_table[3 + s->rl_table_index]; - if(s->msmpeg4_version==2) + if (s->msmpeg4_version == MSMP4_V2) run_diff = 0; else run_diff = 1; @@ -700,12 +701,13 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, int cache; cache= GET_CACHE(re, &s->gb); /* escape */ - if (s->msmpeg4_version==1 || (cache&0x80000000)==0) { - if (s->msmpeg4_version==1 || (cache&0x40000000)==0) { + if (s->msmpeg4_version == MSMP4_V1 || (cache&0x80000000)==0) { + if (s->msmpeg4_version == MSMP4_V1 || (cache&0x40000000)==0) { /* third escape */ - if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2); + if (s->msmpeg4_version != MSMP4_V1) + LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); - if(s->msmpeg4_version<=3){ + if (s->msmpeg4_version <= MSMP4_V3) { last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6); level= SHOW_SBITS(re, &s->gb, 8); @@ -804,7 +806,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, i = 63; /* XXX: not optimal */ } } - if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize + if (s->msmpeg4_version >= MSMP4_WMV1 && i > 0) i=63; //FIXME/XXX optimize s->block_last_index[n] = i; return 0; diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 282b3e958b..a19d516947 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -141,7 +141,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) static AVOnce init_static_once = AV_ONCE_INIT; ff_msmpeg4_common_init(s); - if (s->msmpeg4_version >= 4) { + if (s->msmpeg4_version >= MSMP4_WMV1) { s->min_qcoeff = -255; s->max_qcoeff = 255; } @@ -226,7 +226,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s) put_bits(&s->pb, 2, s->pict_type - 1); put_bits(&s->pb, 5, s->qscale); - if(s->msmpeg4_version<=2){ + if (s->msmpeg4_version <= MSMP4_V2) { s->rl_table_index = 2; s->rl_chroma_table_index = 2; } @@ -235,7 +235,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s) s->mv_table_index = 1; /* only if P-frame */ s->use_skip_mb_code = 1; /* only if P-frame */ s->per_mb_rl_table = 0; - if(s->msmpeg4_version==4) + if (s->msmpeg4_version == MSMP4_WMV1) s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P); ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height); @@ -244,13 +244,13 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s) s->slice_height= s->mb_height/1; put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height); - if(s->msmpeg4_version==4){ + if (s->msmpeg4_version == MSMP4_WMV1) { ff_msmpeg4_encode_ext_header(s); if(s->bit_rate>MBAC_BITRATE) put_bits(&s->pb, 1, s->per_mb_rl_table); } - if(s->msmpeg4_version>2){ + if (s->msmpeg4_version > MSMP4_V2) { if(!s->per_mb_rl_table){ ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index); ff_msmpeg4_code012(&s->pb, s->rl_table_index); @@ -261,10 +261,10 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s) } else { put_bits(&s->pb, 1, s->use_skip_mb_code); - if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE) + if (s->msmpeg4_version == MSMP4_WMV1 && s->bit_rate > MBAC_BITRATE) put_bits(&s->pb, 1, s->per_mb_rl_table); - if(s->msmpeg4_version>2){ + if (s->msmpeg4_version > MSMP4_V2) { if(!s->per_mb_rl_table) ff_msmpeg4_code012(&s->pb, s->rl_table_index); @@ -298,7 +298,7 @@ FF_ENABLE_DEPRECATION_WARNINGS put_bits(&s->pb, 11, FFMIN(s->bit_rate / 1024, 2047)); - if (s->msmpeg4_version >= 3) + if (s->msmpeg4_version >= MSMP4_V3) put_bits(&s->pb, 1, s->flipflop_rounding); else av_assert0(!s->flipflop_rounding); @@ -340,7 +340,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, void ff_msmpeg4_handle_slices(MpegEncContext *s){ if (s->mb_x == 0) { if (s->slice_height && (s->mb_y % s->slice_height) == 0) { - if(s->msmpeg4_version < 4){ + if (s->msmpeg4_version < MSMP4_WMV1) { ff_mpeg4_clean_buffers(s); } s->first_slice_line = 1; @@ -411,7 +411,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext * s, if (s->use_skip_mb_code) put_bits(&s->pb, 1, 0); /* mb coded */ - if(s->msmpeg4_version<=2){ + if (s->msmpeg4_version <= MSMP4_V2) { put_bits(&s->pb, ff_v2_mb_type[cbp&3][1], ff_v2_mb_type[cbp&3][0]); @@ -453,7 +453,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext * s, int val = (s->block_last_index[i] >= 1); cbp |= val << (5 - i); } - if(s->msmpeg4_version<=2){ + if (s->msmpeg4_version <= MSMP4_V2) { if (s->pict_type == AV_PICTURE_TYPE_I) { put_bits(&s->pb, ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]); @@ -525,7 +525,7 @@ static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr /* do the prediction */ level -= pred; - if(s->msmpeg4_version<=2){ + if (s->msmpeg4_version <= MSMP4_V2) { if (n < 4) { put_bits(&s->pb, ff_v2_dc_lum_table[level + 256][1], @@ -576,20 +576,17 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) } else { rl = &ff_rl_table[3 + s->rl_chroma_table_index]; } - run_diff = s->msmpeg4_version>=4; + run_diff = s->msmpeg4_version >= MSMP4_WMV1; scantable= s->intra_scantable.permutated; } else { i = 0; rl = &ff_rl_table[3 + s->rl_table_index]; - if(s->msmpeg4_version<=2) - run_diff = 0; - else - run_diff = 1; + run_diff = s->msmpeg4_version > MSMP4_V2; scantable= s->inter_scantable.permutated; } /* recalculate block_last_index for M$ wmv1 */ - if (s->msmpeg4_version >= 4 && s->block_last_index[n] > 0) { + if (s->msmpeg4_version >= MSMP4_WMV1 && s->block_last_index[n] > 0) { for(last_index=63; last_index>=0; last_index--){ if(block[scantable[last_index]]) break; } @@ -635,7 +632,7 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) if (run1 < 0) goto esc3; code = get_rl_index(rl, last, run1+1, level); - if (s->msmpeg4_version == 4 && code == rl->n) + if (s->msmpeg4_version == MSMP4_WMV1 && code == rl->n) goto esc3; code = get_rl_index(rl, last, run1, level); if (code == rl->n) { @@ -643,7 +640,7 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) /* third escape */ put_bits(&s->pb, 1, 0); put_bits(&s->pb, 1, last); - if(s->msmpeg4_version>=4){ + if (s->msmpeg4_version >= MSMP4_WMV1) { if(s->esc3_level_length==0){ s->esc3_level_length=8; s->esc3_run_length= 6; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 0fac163c4f..906109e4a3 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -610,7 +610,7 @@ av_cold void ff_vc1_init_common(VC1Context *v) s->out_format = FMT_H263; s->h263_pred = 1; - s->msmpeg4_version = 6; + s->msmpeg4_version = MSMP4_VC1; ff_vc1dsp_init(&v->vc1dsp);