From patchwork Tue Feb 1 13:06:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34032 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp612454iov; Tue, 1 Feb 2022 05:22:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwA08dXC6yzuXfqjw/mWhkkcNF9z9zCZ6wSxerti9G2GT2Kvii8tQtxZL4TTPhTPe+msUwP X-Received: by 2002:a17:907:3f99:: with SMTP id hr25mr20671891ejc.588.1643721762191; Tue, 01 Feb 2022 05:22:42 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hz3si10390051ejc.575.2022.02.01.05.22.41; Tue, 01 Feb 2022 05:22:42 -0800 (PST) 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=QOajouan; 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 E9DBF68B45A; Tue, 1 Feb 2022 15:09:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074058.outbound.protection.outlook.com [40.92.74.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60FC768B402 for ; Tue, 1 Feb 2022 15:08:54 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rf5QdKJrPHDQ9l7yR2CbY5IF9wvBSx7eXtUetd6ZcmSlqyJbAsLkr5QSosZYKgtQbLuDkN0xEueDxL0c/RZFUlzhxfaPahoiYJyC8zPVbmLl0aKHV5zFSOTAJ7pTmv/IOXSTFJGKp4lHAB2GwB4bKqqIgrb9rH8vGAaqX20zTviIt30iAd/e3CppxCDRATRf7YKMShbXZHuzegrw+TR2PwZFZbF5S48EZKrf51nJYkCxB4YFfy83BihBYT5GnMRCPsXE/kPWqyOJ+IMLPPJDRpEEhdsjQx0yHPFKnxGWNw2rWBj6fLAIULiLpnpsilf3bYY3GTeS1HzM2pQ1zSJavA== 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=lQMwKQKKlmNmvoQdVI4h91heJ/GUpDqTykYWyZsQm0Q=; b=M3WftZubAHkTk2wi8S8vSv0A9xthHYlHsINrtRlQ4GXa+0jBgww1PnfId4We3Yb3x2Awcy3n75/VF0IcOQlSWaMMIyi267j0VlzuW9PggDRnz5RABO70dCIWr4iGcDg5sFSeEsI7/DjfpaoMMZNRFQ1uLOC8RPv289g8n9CpdoiLLbk+cAU6mnNXi/hNGOd4QdbedQoJEwxvtC3Juf9ixoNpxZ/zI8Mclmu6riILwrfsCis+4jQFoh5hU5ZZaA39WE0uU+NEM4U3DAVO5jUKw2fjAZK06T7qnWJ4RYzPGExguZ2x8px/X0xx5xpAxEuc3SqHh0A4SPcYBNGLXYGAWw== 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=lQMwKQKKlmNmvoQdVI4h91heJ/GUpDqTykYWyZsQm0Q=; b=QOajouan3Srv93hWCeW3j/CJ1YT0yaWFqZSQXch6aL5gVIzNnZNyqPRPtjTC6GThF3aeAJPh8ThbKnyCVdi0rwVV75MmK7Qdglc2/zGYyb2CYL0zPVdtXPI46dWf/mLrIhONEPW5vOqtbVDtzxVj8Ok7BKycptylffz2zZsv+RPfzXMpeImORinJaEruEVYAVco/YHxEUKgFGEQhwX7VxnxlBnJdYK+J+myY9iJSRrEgLlYOU3r15KHiiKL4frqZrZK2+DxmlT3E0Ls7nkfGqa9baOB+xgTFPGMIKM8GRC3tIwEbmDsXD447sfl4EXPHyeS5/uh3Y3j5NxBsmYp0GA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM0PR03MB5025.eurprd03.prod.outlook.com (2603:10a6:208:102::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Tue, 1 Feb 2022 13:08:52 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%6]) with mapi id 15.20.4951.011; Tue, 1 Feb 2022 13:08:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:59 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [4iVcarNOoI4Px2lqJcQsLP0VY9ORV2OA] X-ClientProxiedBy: AM6P195CA0092.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220201130706.1420875-61-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 351dc3cf-6de1-4f2c-12f3-08d9e583fe8f X-MS-TrafficTypeDiagnostic: AM0PR03MB5025:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8lGWWcH7ptr+lYxOzG6SE2eYYNCT+LsLDiUxdc1CozFN2anvzCzZsHw2ptaJyGUV6jxF/hokcG7oxTMLQjd/s7U0ke+39YO70opyWdEn/cl//cGNF7NC2ah9bQjuaMjEuVItrXBfkTPcGHGQ8QPGen+VZYXufYQm5Rir+hgoghUV8YHG9R6jgE/dETsyeFudQ3sE+D+CQ7U1xvAY6cJQNkfXL5jG1TF05tEDQg0+AcK38ALiUHJvwUi9kw/+xpeaRaZPczCu05tS2SFq1tOLMYlzBiaBBx1v3cru38Z0ZVfF4vjLq6jSwDdeF336EU2hSjQU8UDiMKtkrF94N5kZS/LqHkI3tI1L6SWeXfVXv+itFWlaVF28YtY8wux+r3xDFq+5aSmjfYUgjaxfw/CXQnL3BHRJ46AxWu6KLX3TlIA5gi1UXPaN7+2n9qnoenUv4HBBZjNJ+f5Och5J0RumXJlW9JoaV7Ws2zcl0LxDqhzwoN9tQkyiL9ajFGYmS/DOfYrBejPNb3JFsYjCdaoxZv1WcSbapTmwwJSMAOCxerA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CDeqQgcRtZGLn6cTRR265b5Z+9sCIozG9oqiLkRZsULngYzoN5TdTFsNSe9KOYYUuyWoEpDAvwG7L3WBolE+Z6Lu2EiXpxDGFm8I+pVpTxOvzqIVBSiYNW4edXHqKHQc28Frzc6u+B1XrzBE4a5jF7jbltBIEioS1VLyVGB6IKbNkR+K3aK5r0QBkSCWc+ecXZydgZu1jynxg7YeF440VLmqjWCp5dQBUwv8xNRijxJvEndGVJsaoPHNuKzp9oTNps04v5r7uunFAPJA0Qr5r1sj2duboRbQGixV9IZ/ZQ+Vgt5wQrvyFfuuiTR4f//V2Q1LL3/qw76yaQGg9526V+yY7sySFF56oOrjc1HBKFkyZH+V0uvvJL70ohf1LymAbk3Nqfa/+zOQnSTigxzQFHOSJWHVd+NDz5PYsf6Idf07a6DuLzQdP+XyFFU+IxUnuMod5NP0ZmrZ8fzL8AA7iHBqIheQOmcY6GE+bRnQ8LFCKSEJqxqC58tUsbFcPZUDmrUyXcAHJA8I5J9UkBhpFbUnbOJB+5vSO6GFL7KKUs9IzyYGftM375HfoCRRQ8cYbu/2WCvZiEw5h9fcaWeCqD99U+92IwmjailU6prFGkNxa3DqYK1ujxhjFWLTDmSpuwhKI5/LyI2wRGIatZipaTYUYHz3QRM2wmE+mXiLkt9qhxGlVVQ+h1q3jA5i2ZxAH6u4sgXrkGaXQTz8eu89W9x7Jm4A2HuTt6UN9wu4LthAJ/MNqiqqcPwSAADhkC96hxeip1LUkF93nl4Xd2mpRyk4Mn1zlUymbmi5q1xTrV9BU4EvXBP9FyQnXSr+t88bW1HMDQxt+oKp/VXsIjAPJYvQVHidpI+OFr7aUvI7DQxuH8ikDs/xU5Dy4yW91UfTIimSbammOUA1yHiw6QV/iAypn8qu8wpobN7XcLsmKqy9wmM6hNk1je0bqJKqw36pwFCyLQotd5vgvyWFZvU6UA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 351dc3cf-6de1-4f2c-12f3-08d9e583fe8f X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 13:08:52.5307 (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: AM0PR03MB5025 Subject: [FFmpeg-devel] [PATCH v2 62/69] avcodec/mpegvideo: Move max_b_frames to MPVMainEncContext 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: nzKTIzVvpKCZ With the exception of VC-1-based decoders no decoder sets this, so move it to MPVMainEncContext and add a replacement field to VC1Context. Signed-off-by: Andreas Rheinhardt --- libavcodec/dxva2_vc1.c | 2 +- libavcodec/mpeg4videoenc.c | 8 ++++---- libavcodec/mpegvideo.h | 1 - libavcodec/mpegvideo_dec.c | 1 - libavcodec/mpegvideo_enc.c | 38 +++++++++++++++++++------------------- libavcodec/mpegvideoenc.h | 1 + libavcodec/mss2.c | 2 +- libavcodec/nvdec_vc1.c | 2 +- libavcodec/ratecontrol.c | 6 +++--- libavcodec/vc1.c | 4 ++-- libavcodec/vc1.h | 1 + libavcodec/vdpau_vc1.c | 2 +- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index 836367ffe8..d901f023df 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -113,7 +113,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, (v->multires << 5) | (v->resync_marker << 4) | (v->rangered << 3) | - (s->max_b_frames ); + (v->max_b_frames ); pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2; pp->bPicDeblocked = ((!pp->bPicBackwardPrediction && v->overlap) << 6) | ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 07c82cc54d..9bc6fb9388 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -637,7 +637,7 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], /* Check if the B-frames can skip it too, as we must skip it * if we skip here why didn't they just compress * the skip-mb bits instead of reusing them ?! */ - if (s->max_b_frames > 0) { + if (m->max_b_frames > 0) { int i; int x, y, offset; uint8_t *p_pic; @@ -649,7 +649,7 @@ void ff_mpeg4_encode_mb(MPVEncContext *s, int16_t block[6][64], p_pic = s->new_picture.f->data[0] + offset; s->mb_skipped = 1; - for (i = 0; i < s->max_b_frames; i++) { + for (i = 0; i < m->max_b_frames; i++) { const Picture *const pic = m->reordered_input_picture[i + 1]; uint8_t *b_pic; int diff; @@ -921,7 +921,7 @@ static void mpeg4_encode_visual_object_header(MPVMainEncContext *m) if (s->avctx->profile != FF_PROFILE_UNKNOWN) { profile_and_level_indication = s->avctx->profile << 4; - } else if (s->max_b_frames || s->quarter_sample) { + } else if (m->max_b_frames || s->quarter_sample) { profile_and_level_indication = 0xF0; // adv simple } else { profile_and_level_indication = 0x00; // simple @@ -965,7 +965,7 @@ static void mpeg4_encode_vol_header(MPVMainEncContext *m, MPVEncContext *const s = &m->common.s; int vo_ver_id, vo_type, aspect_ratio_info; - if (s->max_b_frames || s->quarter_sample) { + if (m->max_b_frames || s->quarter_sample) { vo_ver_id = 5; vo_type = ADV_SIMPLE_VO_TYPE; } else { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index fefcb90188..8632fadae5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -95,7 +95,6 @@ typedef struct MPVContext { enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ int encoding; ///< true if we are encoding (vs decoding) - int max_b_frames; ///< max number of B-frames for encoding int luma_elim_threshold; int chroma_elim_threshold; int strict_std_compliance; ///< strictly follow the std (MPEG-4, ...) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index fd97e6ac1a..57c93de621 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -151,7 +151,6 @@ do {\ (char *) &s1->last_time_base); // B-frame info - s->max_b_frames = s1->max_b_frames; s->low_delay = s1->low_delay; s->droppable = s1->droppable; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4a90799d17..2fbcfd56e1 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -363,9 +363,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) "max b frames must be 0 or positive for mpegvideo based encoders\n"); return AVERROR(EINVAL); } - s->max_b_frames = avctx->max_b_frames; + m->max_b_frames = avctx->max_b_frames; s->codec_id = avctx->codec->id; - if (s->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { + if (m->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); return AVERROR(EINVAL); } @@ -591,7 +591,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) "set strict_std_compliance to 'unofficial' or lower in order to allow it\n"); return AVERROR(EINVAL); } - if (s->max_b_frames != 0) { + if (m->max_b_frames != 0) { av_log(avctx, AV_LOG_ERROR, "B-frames cannot be used with low delay\n"); return AVERROR(EINVAL); @@ -658,12 +658,12 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) case AV_CODEC_ID_MPEG1VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY); - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); break; case AV_CODEC_ID_MPEG2VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(avctx->flags & AV_CODEC_FLAG_LOW_DELAY); - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); s->rtp_mode = 1; break; #if CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER @@ -759,8 +759,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; - s->low_delay = s->max_b_frames ? 0 : 1; - avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); + s->low_delay = m->max_b_frames ? 0 : 1; + avctx->delay = s->low_delay ? 0 : (m->max_b_frames + 1); break; case AV_CODEC_ID_MSMPEG4V2: s->out_format = FMT_H263; @@ -957,7 +957,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return ret; if (m->b_frame_strategy == 2) { - for (i = 0; i < s->max_b_frames + 2; i++) { + for (i = 0; i < m->max_b_frames + 2; i++) { m->tmp_frames[i] = av_frame_alloc(); if (!m->tmp_frames[i]) return AVERROR(ENOMEM); @@ -1073,7 +1073,7 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg) Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; - int encoding_delay = s->max_b_frames ? s->max_b_frames + int encoding_delay = m->max_b_frames ? m->max_b_frames : (s->low_delay ? 0 : 1); int flush_offset = 1; int direct = 1; @@ -1310,7 +1310,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> FF_LAMBDA_SHIFT; - for (i = 0; i < s->max_b_frames + 2; i++) { + for (i = 0; i < m->max_b_frames + 2; i++) { Picture pre_input, *pre_input_ptr = i ? m->input_picture[i - 1] : s->next_picture_ptr; uint8_t *data[4]; @@ -1343,7 +1343,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) } } - for (j = 0; j < s->max_b_frames + 1; j++) { + for (j = 0; j < m->max_b_frames + 1; j++) { AVCodecContext *c; int64_t rd = 0; @@ -1366,7 +1366,7 @@ static int estimate_best_b_count(MPVMainEncContext *m) c->me_sub_cmp = s->avctx->me_sub_cmp; c->pix_fmt = AV_PIX_FMT_YUV420P; c->time_base = s->avctx->time_base; - c->max_b_frames = s->max_b_frames; + c->max_b_frames = m->max_b_frames; ret = avcodec_open2(c, s->avctx->codec, NULL); if (ret < 0) @@ -1384,8 +1384,8 @@ static int estimate_best_b_count(MPVMainEncContext *m) //rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; - for (i = 0; i < s->max_b_frames + 1; i++) { - int is_p = i % (j + 1) == j || i == s->max_b_frames; + for (i = 0; i < m->max_b_frames + 1; i++) { + int is_p = i % (j + 1) == j || i == m->max_b_frames; m->tmp_frames[i + 1]->pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; @@ -1464,7 +1464,7 @@ static int select_input_picture(MPVMainEncContext *m) int b_frames = 0; if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { - for (i = 0; i < s->max_b_frames + 1; i++) { + for (i = 0; i < m->max_b_frames + 1; i++) { int pict_num = m->input_picture[0]->f->display_picture_number + i; if (pict_num >= m->rc_context.num_entries) @@ -1480,11 +1480,11 @@ static int select_input_picture(MPVMainEncContext *m) } if (m->b_frame_strategy == 0) { - b_frames = s->max_b_frames; + b_frames = m->max_b_frames; while (b_frames && !m->input_picture[b_frames]) b_frames--; } else if (m->b_frame_strategy == 1) { - for (i = 1; i < s->max_b_frames + 1; i++) { + for (i = 1; i < m->max_b_frames + 1; i++) { if (m->input_picture[i] && m->input_picture[i]->b_frame_score == 0) { m->input_picture[i]->b_frame_score = @@ -1494,7 +1494,7 @@ static int select_input_picture(MPVMainEncContext *m) s->linesize) + 1; } } - for (i = 0; i < s->max_b_frames + 1; i++) { + for (i = 0; i < m->max_b_frames + 1; i++) { if (!m->input_picture[i] || m->input_picture[i]->b_frame_score - 1 > s->mb_num / m->b_sensitivity) @@ -1521,7 +1521,7 @@ static int select_input_picture(MPVMainEncContext *m) b_frames = i; } if (m->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B && - b_frames == s->max_b_frames) { + b_frames == m->max_b_frames) { av_log(s->avctx, AV_LOG_ERROR, "warning, too many B-frames in a row\n"); } diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 91d41f86e8..ef9b92112c 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -99,6 +99,7 @@ typedef struct MPVMainEncContext { /* temporary frames used by b_frame_strategy == 2 */ AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2]; + int max_b_frames; ///< max number of B-frames int b_frame_strategy; int b_sensitivity; int brd_scale; diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 66ce266b51..f650a84e8d 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -783,7 +783,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx) v->resync_marker = 0; v->rangered = 0; - v->s.s.max_b_frames = avctx->max_b_frames = 0; + v->max_b_frames = avctx->max_b_frames = 0; v->quantizer_mode = 0; v->finterpflag = 0; diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c index afec5c1f7c..e8cae4d724 100644 --- a/libavcodec/nvdec_vc1.c +++ b/libavcodec/nvdec_vc1.c @@ -80,7 +80,7 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u .multires = v->multires, .syncmarker = v->resync_marker, .rangered = v->rangered, - .maxbframes = s->max_b_frames, + .maxbframes = v->max_b_frames, .panscan_flag = v->panscanflag, .refdist_flag = v->refdist_flag, diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index bdf5c82aa1..980f8c59f2 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -557,7 +557,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); - i += s->max_b_frames; + i += m->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); @@ -578,7 +578,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) /* read stats */ p = s->avctx->stats_in; - for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { + for (i = 0; i < rcc->num_entries - m->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; @@ -636,7 +636,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *m) if (i % ((m->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; - else if (i % (s->max_b_frames + 1)) + else if (i % (m->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index d9061b1f74..13a211e916 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -359,7 +359,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo "RANGERED should be set to 0 in Simple Profile\n"); } - s->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common + v->max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common v->quantizer_mode = get_bits(gb, 2); //common v->finterpflag = get_bits1(gb); //common @@ -441,7 +441,7 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) av_log(s->avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n"); return -1; } - s->max_b_frames = s->avctx->max_b_frames = 7; + v->max_b_frames = s->avctx->max_b_frames = 7; if (get_bits1(gb)) { //Display Info - decoding is not affected by it int w, h, ar = 0; av_log(s->avctx, AV_LOG_DEBUG, "Display extended info:\n"); diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index f203b28694..6aa1a32352 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -222,6 +222,7 @@ typedef struct VC1Context{ int dquant; ///< How qscale varies with MBs, 2 bits (not in Simple) int vstransform; ///< variable-size [48]x[48] transform type + info int overlap; ///< overlapped transforms in use + int max_b_frames; int quantizer_mode; ///< 2 bits, quantizer mode used for sequence, see QUANT_* int finterpflag; ///< INTERPFRM present //@} diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c index f13b62f723..b91b158511 100644 --- a/libavcodec/vdpau_vc1.c +++ b/libavcodec/vdpau_vc1.c @@ -90,7 +90,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx, info->multires = v->multires; info->syncmarker = v->resync_marker; info->rangered = v->rangered | (v->rangeredfrm << 1); - info->maxbframes = v->s.s.max_b_frames; + info->maxbframes = v->max_b_frames; info->deblockEnable = v->postprocflag & 1; info->pquant = v->pq;