From patchwork Mon Apr 29 21:14:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48381 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp2270912pzb; Mon, 29 Apr 2024 14:16:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVPy1xCtCUYnXAOMpucm/T1DrWT+U1n332uE4FcL3jKsSREk+4kfy1LQlZpr099fGFD+lvBXiD1AMfn2L47LmVIF9Yoluh8RA+kZQ== X-Google-Smtp-Source: AGHT+IHAFZwIq/CA2hMMTwILkBMvwjDib/U1GxHRARAxSR2pf6UXL6Jlf1Zep7zx8MbQk0KV9LIs X-Received: by 2002:a17:906:ff42:b0:a55:aebd:17d5 with SMTP id zo2-20020a170906ff4200b00a55aebd17d5mr538398ejb.2.1714425372525; Mon, 29 Apr 2024 14:16:12 -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 b21-20020a170906151500b00a52177aee34si14973406ejd.239.2024.04.29.14.16.11; Mon, 29 Apr 2024 14:16:12 -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=Ys2mBIzP; 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 A7B4768D536; Tue, 30 Apr 2024 00:15:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2043.outbound.protection.outlook.com [40.92.50.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 325F868D54C for ; Tue, 30 Apr 2024 00:15:41 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8HdoxhHVMIJj+dF0WctkG7+DZgcStd17TmzqZ1I5g1pt4FBxXWxgoI9SmhrTgkred4GVnt6CTuRrkiFZumVgGUKheD1sj43se9F8GV433l480ZahmQK7rXujgh1nz1W8G+64PWJAQ/mj3HJTwHfYSFym1jENxFqpAwiq90R7cmVoGuYZcUE926ZUNGWG0LS1D5jZSZTwDjxGc0+HYtmIcp9lva/0GdSUv9J0zw1z1llIoyrZalbe4ojONkJtx7ndLgYabZ3lJTicibV2Mfd3f1IGiAx5HZsxP5Yuu7IE0ibAgZCnr1UP5jrBrmQblrhsLC09qiItwgjJ/fvIcyL7Q== 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=4UghFU0Buzhhg4o2I5cxUvfENHYwquBRmDSphYo3iBE=; b=ULRv8L8tcGjZRFGlGaJwCYrrGXRVERJSDtJGnvuyYQUEc92Fk/Su4PVRBpoLc9+1Rlees/fIBn5UUWuwM9yOntze6SNLCRFSgokMDTUqtvmskOvp/v2/pFQmmMoTZbSNSTdWMHabHpcwaWGO/Joa6SpHuWcBsu3Gq/CtyD2jMmdXVCQ8Ud74zHbsUV2Wy0QoYvkqmhPSaUK4IlYUUGLsmdPNyjISCw+UClzx6vHa/5ut7/uMs4nn+rzS90zeWInY0DwFAiUdA9ESwK490lfasW+OdMUgKMu5inMAZIwX7YPdoPIKNedBwOzxyAs5PvY3IqCcluDsdL/YjO2HEmh6jA== 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=4UghFU0Buzhhg4o2I5cxUvfENHYwquBRmDSphYo3iBE=; b=Ys2mBIzPVWdjdaSxKeBCKmguDY+QBoGMlZB6ihzaPWi6Iby1W/LnRUeVNCho92dK4un/13nxRPp4fI7TFBqqM+B2+Smv3TRCmwOqg+wEbeqFIbYHJuChQzSoWdrsnGTnt4qsN4tu1Qd5PVPNsEpHmT779dYimO12b/+yNDzmWQux9U/6DdNw+twYWMSis6BxAIk5xUCc5CHfdUbtB8n47gzNLeP16AxiJlz0iB652pocqzA1D6xAiWsm72guH/LLAxUR/H5EbeFaQ6wqvnyq5CJ5EGYMhRppfvnXRxn7G6rLrmRY0WYzIT+CJyvlcpjMIXq0hzrXFXGhrwlU/1RthQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0372.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17f::19) 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:15:40 +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:15:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Apr 2024 23:14:03 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [zkXTYPGuY1nFbgPsfH/CaWVCiMYi/++ho8+iglj/Pt8=] 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-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0372:EE_ X-MS-Office365-Filtering-Correlation-Id: 033c7339-1bca-4801-7ce8-08dc689185a7 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: RoprHiHDsWZ1KglPSzIhz3z1tNrI7dTc9AYgoupADT2lVLXJNaiv+jM9QR+K00hufFJzvMQMDUAUTGvLzNYqtyDzVlqEIdSl/RBdoiDQeyQlMS+69X8167smzBQ7wMA7tjHAH4PnF1jJyW/S60Y69ThXH1mJlvnwkuvacETV1RtBCi6ghhqZkjg1pqt3uAPK4RNSTVR7b7bqGwg/x0TwwtKGtXu859evNR54fpQn88yu5Kh5KmKdx8aY95Z2PFNDMly9X3jroyN2PsDKdvsUEYJrYN8a039g23SmbUTgD/WqJMbz5hFkrPppep6XeyB8/juVi/blZ2a5WrUgifBGEA0Ou6dny9RM9dupr+L8Ajohx3RQtoNO/Mw5ZIvWxMQ6SkgOnlUg9Gz85cvyL2HJiANsYR2tA9kWx3oIZQUvTNDS2aQMFv2WMZJIhY7D7my6gZfVOvxskJL44YKwE1QT+rArBxfPM7UfwkKrHoJGsHbwx2RVCGQqRUgIaEPJg7QeGOmG/JZ6yswi6xDB/B0/sSO+VJ+UcUuf2yRNH9A6irqlrHb8pmpSVfoldJP0hH94Ozy3yCB154hdwqKy0RtOdMKDsnhX7F9gH2Dd3l/mtu9mYLcDjlItzBYSbkq7fXxD X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: djQkarL3MZPfq0v3taGvA5GHzkeuYgB9O1jSRr2IwxFToeDGhTjUz4De872aJRPE3V97DZH0SHnwVGu5yDR9P3xTtgflhGS2+OV7VbNPatPa7esAFNXi0fFQcJEAQebJa3qvsQir83TCDl5I39Nesd4y8IVuB0m2eZzcYhzauusumJKlIMj8dpaHV6QqRGRRFWZ67lqOEOhPKOuFnijWc7b5XEpiy11cpwaM/fT2Ul2R6iPbocUBgX7zMbFRRPZs18vz/OT8scPb2V6n2CW6t/bw8WE7hQM31nykPZyfwrOpdRi+uzpq+4tfCBxfLzIawXx1kopfILdK4Ym8IgVc2iViF3+U4NcamSmhOM5/jinly+JgpC/mRIFnVmZvgll20L5lnhtVy7pHz4MRifAY2/dAB+a7P3n+4L7nVFAtSfOJWbFBfY6CKJBbN8gNwTMs7xK8WrES7e6T0ixRkW85zQP/iKT/4r5rdYRg5vr2Ys8mYk1MzmlhENAR2x62oZtGhy1j6+/wwscz86KEjaIMr5Fg2x3x8tDU8DRafgy16C+9xhoQEXcFQGx5DplqFWZ7KOjTnuSXzvGY/kgET5MGXs1848vcCZxXr9bTPqxYOcd5ivR1BRyPFj7Zp076cngp28GhYojtXiCkXl+FkgM4u6F3j/lU2efaLhO7E1/xXQDVVGV2DpaUhBoN1mjUo5bLnRFp8c4YlI+8JMAtD1+ZOmHaxo7XFjP0Uxxjwlee9G6gQnK/uGhx9VL6ty20ymO2zOOHQN0P0DsX5WAma3J0L3xVu5yo9yyiRl2KCw+IxRXeke9jEy+YmIgvrXfoGc1bbI3SsasYreiWYBd2rXJTKP8pvF+ewo9lH7x1UTn+1g5g4HkozR9YYYDP3W2R3YidMifyiJORNZqZkRC0tUHNuzOCkZxybfqsnKbW6ara84TvZibuRmQRMoeAD1J87QrhQ9sZxFBy1yEpKGFG3avgOFD2eXBJ1Sd6powueRdVsVpIZS977aOrybId7/KXq1QMq7KGVGkkQR7a1hQm+/h73dMTV6w77H+q3yAjKFwS6oXbxN82lbj1jvV5122PbRBQGomxMa3qc6RmDGzMOEhwy/KOD9J8W0nHMy5fO8KYC0gGu+nXCkrSI/kujtwmfCCUB40LEVRaYA6Nr+d7JqV1555/oZwJh/u2QUkEv5pv/JApQLgCT3lCtZMYUi5dB+QzINN2MSh5CNjppuvek4ckaiIYeq2FPHi14bRaOu7BT/bh9OGDE0aONRrDzYIQ5Ml2vyiNsdSO2+ZSKLEA+9QP5g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 033c7339-1bca-4801-7ce8-08dc689185a7 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:15:40.3857 (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: PR3P250MB0372 Subject: [FFmpeg-devel] [PATCH 22/57] avcodec/mpegpicture: Cache AVFrame.data and linesize values 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: YxMpr5sLO5HG This avoids an indirection and is in preparation for removing the AVFrame from MpegEncContext.(cur|last|next)_pic altogether. Signed-off-by: Andreas Rheinhardt --- libavcodec/motion_est.c | 16 +++---- libavcodec/mpeg12dec.c | 14 +++--- libavcodec/mpeg_er.c | 6 +-- libavcodec/mpegpicture.c | 14 ++++++ libavcodec/mpegpicture.h | 4 ++ libavcodec/mpegvideo.c | 10 ++-- libavcodec/mpegvideo_dec.c | 4 +- libavcodec/mpegvideo_enc.c | 16 +++---- libavcodec/mpegvideo_motion.c | 4 +- libavcodec/mpv_reconstruct_mb_template.c | 12 ++--- libavcodec/msmpeg4.c | 4 +- libavcodec/mss2.c | 4 +- libavcodec/svq1enc.c | 6 +-- libavcodec/vc1_block.c | 8 ++-- libavcodec/vc1_mc.c | 60 ++++++++++++------------ libavcodec/vc1dec.c | 28 +++++------ 16 files changed, 114 insertions(+), 96 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 07148e16ec..892e2a3d08 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -703,11 +703,11 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize; if(s->no_rounding){ - s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_pic.f->data[1] + offset, s->uvlinesize, 8); - s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_pic.f->data[2] + offset, s->uvlinesize, 8); + s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_pic.data[1] + offset, s->uvlinesize, 8); + s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8); }else{ - s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_pic.f->data[1] + offset, s->uvlinesize, 8); - s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_pic.f->data[2] + offset, s->uvlinesize, 8); + s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_pic.data[1] + offset, s->uvlinesize, 8); + s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8); } dmin_sum += s->mecc.mb_cmp[1](s, s->new_pic->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8); @@ -899,7 +899,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, const int shift= 1+s->quarter_sample; int mb_type=0; - init_ref(c, s->new_pic->data, s->last_pic.f->data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_pic->data, s->last_pic.data, NULL, 16*mb_x, 16*mb_y, 0); av_assert0(s->quarter_sample==0 || s->quarter_sample==1); av_assert0(s->linesize == c->stride); @@ -1070,7 +1070,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int P[10][2]; const int shift= 1+s->quarter_sample; const int xy= mb_x + mb_y*s->mb_stride; - init_ref(c, s->new_pic->data, s->last_pic.f->data, NULL, 16*mb_x, 16*mb_y, 0); + init_ref(c, s->new_pic->data, s->last_pic.data, NULL, 16*mb_x, 16*mb_y, 0); av_assert0(s->quarter_sample==0 || s->quarter_sample==1); @@ -1499,8 +1499,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, int fmin, bmin, dmin, fbmin, bimin, fimin; int type=0; const int xy = mb_y*s->mb_stride + mb_x; - init_ref(c, s->new_pic->data, s->last_pic.f->data, - s->next_pic.f->data, 16 * mb_x, 16 * mb_y, 2); + init_ref(c, s->new_pic->data, s->last_pic.data, + s->next_pic.data, 16 * mb_x, 16 * mb_y, 2); get_limits(s, 16*mb_x, 16*mb_y); diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 4aba5651a6..c04d351e0c 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1297,12 +1297,12 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) for (int i = 0; i < 3; i++) { if (s->picture_structure == PICT_BOTTOM_FIELD) { - s->cur_pic.f->data[i] = FF_PTR_ADD(s->cur_pic.f->data[i], - s->cur_pic.f->linesize[i]); + s->cur_pic.data[i] = FF_PTR_ADD(s->cur_pic.data[i], + s->cur_pic.linesize[i]); } - s->cur_pic.f->linesize[i] *= 2; - s->last_pic.f->linesize[i] *= 2; - s->next_pic.f->linesize[i] *= 2; + s->cur_pic.linesize[i] *= 2; + s->last_pic.linesize[i] *= 2; + s->next_pic.linesize[i] *= 2; } } @@ -1377,9 +1377,9 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) return ret; for (int i = 0; i < 3; i++) { - s->cur_pic.f->data[i] = s->cur_pic_ptr->f->data[i]; + s->cur_pic.data[i] = s->cur_pic_ptr->f->data[i]; if (s->picture_structure == PICT_BOTTOM_FIELD) - s->cur_pic.f->data[i] += + s->cur_pic.data[i] += s->cur_pic_ptr->f->linesize[i]; } } diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c index bc838b05ba..8d8b2aea92 100644 --- a/libavcodec/mpeg_er.c +++ b/libavcodec/mpeg_er.c @@ -84,13 +84,13 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, if (!s->chroma_y_shift) s->bdsp.clear_blocks(s->block[6]); - s->dest[0] = s->cur_pic.f->data[0] + + s->dest[0] = s->cur_pic.data[0] + s->mb_y * 16 * s->linesize + s->mb_x * 16; - s->dest[1] = s->cur_pic.f->data[1] + + s->dest[1] = s->cur_pic.data[1] + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); - s->dest[2] = s->cur_pic.f->data[2] + + s->dest[2] = s->cur_pic.data[2] + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index ad6157f0c1..bca0e6de01 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -173,6 +173,11 @@ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, *linesize = pic->f->linesize[0]; *uvlinesize = pic->f->linesize[1]; + for (int i = 0; i < MPV_MAX_PLANES; i++) { + pic->data[i] = pic->f->data[i]; + pic->linesize[i] = pic->f->linesize[i]; + } + ret = alloc_picture_tables(pools, pic, mb_height); if (ret < 0) goto fail; @@ -205,7 +210,11 @@ void ff_mpeg_unref_picture(Picture *pic) free_picture_tables(pic); + memset(pic->data, 0, sizeof(pic->data)); + memset(pic->linesize, 0, sizeof(pic->linesize)); + pic->dummy = 0; + pic->field_picture = 0; pic->b_frame_score = 0; pic->reference = 0; @@ -247,6 +256,11 @@ int ff_mpeg_ref_picture(Picture *dst, Picture *src) if (ret < 0) goto fail; + for (int i = 0; i < MPV_MAX_PLANES; i++) { + dst->data[i] = src->data[i]; + dst->linesize[i] = src->linesize[i]; + } + update_picture_tables(dst, src); ff_refstruct_replace(&dst->hwaccel_picture_private, diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 8e3c119acc..814f71213e 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -21,6 +21,7 @@ #ifndef AVCODEC_MPEGPICTURE_H #define AVCODEC_MPEGPICTURE_H +#include #include #include "avcodec.h" @@ -57,6 +58,9 @@ typedef struct Picture { struct AVFrame *f; ThreadFrame tf; + uint8_t *data[MPV_MAX_PLANES]; + ptrdiff_t linesize[MPV_MAX_PLANES]; + int8_t *qscale_table_base; int8_t *qscale_table; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index cfc0dc8663..34f412a6b7 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -878,8 +878,8 @@ void ff_clean_intra_table_entries(MpegEncContext *s) } void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename - const int linesize = s->cur_pic.f->linesize[0]; //not s->linesize as this would be wrong for field pics - const int uvlinesize = s->cur_pic.f->linesize[1]; + const int linesize = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics + const int uvlinesize = s->cur_pic.linesize[1]; const int width_of_mb = (4 + (s->avctx->bits_per_raw_sample > 8)) - s->avctx->lowres; const int height_of_mb = 4 - s->avctx->lowres; @@ -891,9 +891,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1; //block_index is not used by mpeg2, so it is not affected by chroma_format - s->dest[0] = s->cur_pic.f->data[0] + (int)((s->mb_x - 1U) << width_of_mb); - s->dest[1] = s->cur_pic.f->data[1] + (int)((s->mb_x - 1U) << (width_of_mb - s->chroma_x_shift)); - s->dest[2] = s->cur_pic.f->data[2] + (int)((s->mb_x - 1U) << (width_of_mb - s->chroma_x_shift)); + s->dest[0] = s->cur_pic.data[0] + (int)((s->mb_x - 1U) << width_of_mb); + s->dest[1] = s->cur_pic.data[1] + (int)((s->mb_x - 1U) << (width_of_mb - s->chroma_x_shift)); + s->dest[2] = s->cur_pic.data[2] + (int)((s->mb_x - 1U) << (width_of_mb - s->chroma_x_shift)); if (s->picture_structure == PICT_FRAME) { s->dest[0] += s->mb_y * linesize << height_of_mb; diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 9b04d6a351..570a422b6f 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -613,8 +613,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, const int h_edge_pos = s->h_edge_pos >> lowres; const int v_edge_pos = s->v_edge_pos >> lowres; int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; - linesize = s->cur_pic.f->linesize[0] << field_based; - uvlinesize = s->cur_pic.f->linesize[1] << field_based; + linesize = s->cur_pic.linesize[0] << field_based; + uvlinesize = s->cur_pic.linesize[1] << field_based; // FIXME obviously not perfect but qpel will not work in lowres anyway if (s->quarter_sample) { diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 47e97999af..372e96cb39 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1655,20 +1655,20 @@ static void frame_end(MpegEncContext *s) !s->intra_only) { int hshift = s->chroma_x_shift; int vshift = s->chroma_y_shift; - s->mpvencdsp.draw_edges(s->cur_pic.f->data[0], - s->cur_pic.f->linesize[0], + s->mpvencdsp.draw_edges(s->cur_pic.data[0], + s->cur_pic.linesize[0], s->h_edge_pos, s->v_edge_pos, EDGE_WIDTH, EDGE_WIDTH, EDGE_TOP | EDGE_BOTTOM); - s->mpvencdsp.draw_edges(s->cur_pic.f->data[1], - s->cur_pic.f->linesize[1], + s->mpvencdsp.draw_edges(s->cur_pic.data[1], + s->cur_pic.linesize[1], s->h_edge_pos >> hshift, s->v_edge_pos >> vshift, EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, EDGE_TOP | EDGE_BOTTOM); - s->mpvencdsp.draw_edges(s->cur_pic.f->data[2], - s->cur_pic.f->linesize[2], + s->mpvencdsp.draw_edges(s->cur_pic.data[2], + s->cur_pic.linesize[2], s->h_edge_pos >> hshift, s->v_edge_pos >> vshift, EDGE_WIDTH >> hshift, @@ -2268,14 +2268,14 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, if (s->mv_dir & MV_DIR_FORWARD) { ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, - s->last_pic.f->data, + s->last_pic.data, op_pix, op_qpix); op_pix = s->hdsp.avg_pixels_tab; op_qpix = s->qdsp.avg_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, - s->next_pic.f->data, + s->next_pic.data, op_pix, op_qpix); } diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index 3824832f9d..9c1872aa1b 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -93,8 +93,8 @@ void mpeg_motion_internal(MpegEncContext *s, ptrdiff_t uvlinesize, linesize; v_edge_pos = s->v_edge_pos >> field_based; - linesize = s->cur_pic.f->linesize[0] << field_based; - uvlinesize = s->cur_pic.f->linesize[1] << field_based; + linesize = s->cur_pic.linesize[0] << field_based; + uvlinesize = s->cur_pic.linesize[1] << field_based; block_y_half = (field_based | is_16x8); dxy = ((motion_y & 1) << 1) | (motion_x & 1); diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c index febada041a..70dab76f73 100644 --- a/libavcodec/mpv_reconstruct_mb_template.c +++ b/libavcodec/mpv_reconstruct_mb_template.c @@ -82,8 +82,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], { uint8_t *dest_y, *dest_cb, *dest_cr; int dct_linesize, dct_offset; - const int linesize = s->cur_pic.f->linesize[0]; //not s->linesize as this would be wrong for field pics - const int uvlinesize = s->cur_pic.f->linesize[1]; + const int linesize = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics + const int uvlinesize = s->cur_pic.linesize[1]; const int readable = IS_ENCODER || lowres_flag || s->pict_type != AV_PICTURE_TYPE_B; const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8; @@ -137,11 +137,11 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab; if (s->mv_dir & MV_DIR_FORWARD) { - MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.f->data, op_pix); + MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix); op_pix = s->h264chroma.avg_h264_chroma_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { - MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.f->data, op_pix); + MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix); } } else { op_pixels_func (*op_pix)[4]; @@ -155,12 +155,12 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_FORWARD) { - ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.f->data, op_pix, op_qpix); + ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix); op_pix = s->hdsp.avg_pixels_tab; op_qpix = s->qdsp.avg_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { - ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.f->data, op_pix, op_qpix); + ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix); } } diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index 323f083f8f..f7ebb8ba89 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -282,10 +282,10 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int bs = 8 >> s->avctx->lowres; if(n<4){ wrap= s->linesize; - dest = s->cur_pic.f->data[0] + (((n >> 1) + 2*s->mb_y) * bs* wrap ) + ((n & 1) + 2*s->mb_x) * bs; + dest = s->cur_pic.data[0] + (((n >> 1) + 2*s->mb_y) * bs* wrap ) + ((n & 1) + 2*s->mb_x) * bs; }else{ wrap= s->uvlinesize; - dest = s->cur_pic.f->data[n - 3] + (s->mb_y * bs * wrap) + s->mb_x * bs; + dest = s->cur_pic.data[n - 3] + (s->mb_y * bs * wrap) + s->mb_x * bs; } if(s->mb_x==0) a= (1024 + (scale>>1))/scale; else a= get_dc(dest-bs, wrap, scale*8>>(2*s->avctx->lowres), bs); diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 6a4b5aeb59..5d52744529 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -382,7 +382,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, MSS12Context *c = &ctx->c; VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; - AVFrame *f; + Picture *f; int ret; ff_mpeg_flush(avctx); @@ -431,7 +431,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, ff_mpv_frame_end(s); - f = s->cur_pic.f; + f = &s->cur_pic; if (v->respic == 3) { ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h); diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 52140494bb..c75ab1800a 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -328,11 +328,11 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, s->m.avctx = s->avctx; s->m.cur_pic_ptr = &s->m.cur_pic; s->m.last_pic_ptr = &s->m.last_pic; - s->m.last_pic.f->data[0] = ref_plane; + s->m.last_pic.data[0] = ref_plane; s->m.linesize = - s->m.last_pic.f->linesize[0] = + s->m.last_pic.linesize[0] = s->m.new_pic->linesize[0] = - s->m.cur_pic.f->linesize[0] = stride; + s->m.cur_pic.linesize[0] = stride; s->m.width = width; s->m.height = height; s->m.mb_width = block_width; diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 6b5b1d0566..9cb9fd27bf 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -2948,7 +2948,7 @@ static void vc1_decode_skip_blocks(VC1Context *v) { MpegEncContext *s = &v->s; - if (!v->s.last_pic.f->data[0]) + if (!v->s.last_pic.data[0]) return; ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END); @@ -2957,9 +2957,9 @@ static void vc1_decode_skip_blocks(VC1Context *v) s->mb_x = 0; init_block_index(v); update_block_index(s); - memcpy(s->dest[0], s->last_pic.f->data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); - memcpy(s->dest[1], s->last_pic.f->data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); - memcpy(s->dest[2], s->last_pic.f->data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); + memcpy(s->dest[0], s->last_pic.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); + memcpy(s->dest[1], s->last_pic.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); + memcpy(s->dest[2], s->last_pic.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); s->first_slice_line = 0; } } diff --git a/libavcodec/vc1_mc.c b/libavcodec/vc1_mc.c index e24328569d..b60a48b38f 100644 --- a/libavcodec/vc1_mc.c +++ b/libavcodec/vc1_mc.c @@ -184,7 +184,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && - !v->s.last_pic.f->data[0]) + !v->s.last_pic.data[0]) return; linesize = s->cur_pic_ptr->f->linesize[0]; @@ -219,26 +219,26 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir) } if (!dir) { if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) { - srcY = s->cur_pic.f->data[0]; - srcU = s->cur_pic.f->data[1]; - srcV = s->cur_pic.f->data[2]; + srcY = s->cur_pic.data[0]; + srcU = s->cur_pic.data[1]; + srcV = s->cur_pic.data[2]; luty = v->curr_luty; lutuv = v->curr_lutuv; use_ic = *v->curr_use_ic; interlace = 1; } else { - srcY = s->last_pic.f->data[0]; - srcU = s->last_pic.f->data[1]; - srcV = s->last_pic.f->data[2]; + srcY = s->last_pic.data[0]; + srcU = s->last_pic.data[1]; + srcV = s->last_pic.data[2]; luty = v->last_luty; lutuv = v->last_lutuv; use_ic = v->last_use_ic; interlace = !!(s->last_pic.f->flags & AV_FRAME_FLAG_INTERLACED); } } else { - srcY = s->next_pic.f->data[0]; - srcU = s->next_pic.f->data[1]; - srcV = s->next_pic.f->data[2]; + srcY = s->next_pic.data[0]; + srcU = s->next_pic.data[1]; + srcV = s->next_pic.data[2]; luty = v->next_luty; lutuv = v->next_lutuv; use_ic = v->next_use_ic; @@ -464,7 +464,7 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && - !v->s.last_pic.f->data[0]) + !v->s.last_pic.data[0]) return; linesize = s->cur_pic_ptr->f->linesize[0]; @@ -474,18 +474,18 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) if (!dir) { if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) { - srcY = s->cur_pic.f->data[0]; + srcY = s->cur_pic.data[0]; luty = v->curr_luty; use_ic = *v->curr_use_ic; interlace = 1; } else { - srcY = s->last_pic.f->data[0]; + srcY = s->last_pic.data[0]; luty = v->last_luty; use_ic = v->last_use_ic; interlace = !!(s->last_pic.f->flags & AV_FRAME_FLAG_INTERLACED); } } else { - srcY = s->next_pic.f->data[0]; + srcY = s->next_pic.data[0]; luty = v->next_luty; use_ic = v->next_use_ic; interlace = !!(s->next_pic.f->flags & AV_FRAME_FLAG_INTERLACED); @@ -645,7 +645,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) int interlace; int uvlinesize; - if (!v->field_mode && !v->s.last_pic.f->data[0]) + if (!v->field_mode && !v->s.last_pic.data[0]) return; if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; @@ -664,7 +664,7 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) int opp_count = get_luma_mv(v, dir, &tx, &ty); chroma_ref_type = v->cur_field_type ^ (opp_count > 2); } - if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_pic.f->data[0]) + if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_pic.data[0]) return; s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; @@ -698,21 +698,21 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir) if (!dir) { if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) { - srcU = s->cur_pic.f->data[1]; - srcV = s->cur_pic.f->data[2]; + srcU = s->cur_pic.data[1]; + srcV = s->cur_pic.data[2]; lutuv = v->curr_lutuv; use_ic = *v->curr_use_ic; interlace = 1; } else { - srcU = s->last_pic.f->data[1]; - srcV = s->last_pic.f->data[2]; + srcU = s->last_pic.data[1]; + srcV = s->last_pic.data[2]; lutuv = v->last_lutuv; use_ic = v->last_use_ic; interlace = !!(s->last_pic.f->flags & AV_FRAME_FLAG_INTERLACED); } } else { - srcU = s->next_pic.f->data[1]; - srcV = s->next_pic.f->data[2]; + srcU = s->next_pic.data[1]; + srcV = s->next_pic.data[2]; lutuv = v->next_lutuv; use_ic = v->next_use_ic; interlace = !!(s->next_pic.f->flags & AV_FRAME_FLAG_INTERLACED); @@ -880,14 +880,14 @@ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg) else uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); if (i < 2 ? dir : dir2) { - srcU = s->next_pic.f->data[1]; - srcV = s->next_pic.f->data[2]; + srcU = s->next_pic.data[1]; + srcV = s->next_pic.data[2]; lutuv = v->next_lutuv; use_ic = v->next_use_ic; interlace = !!(s->next_pic.f->flags & AV_FRAME_FLAG_INTERLACED); } else { - srcU = s->last_pic.f->data[1]; - srcV = s->last_pic.f->data[2]; + srcU = s->last_pic.data[1]; + srcV = s->last_pic.data[2]; lutuv = v->last_lutuv; use_ic = v->last_use_ic; interlace = !!(s->last_pic.f->flags & AV_FRAME_FLAG_INTERLACED); @@ -1012,7 +1012,7 @@ void ff_vc1_interp_mc(VC1Context *v) int interlace; int linesize, uvlinesize; - if (!v->field_mode && !v->s.next_pic.f->data[0]) + if (!v->field_mode && !v->s.next_pic.data[0]) return; linesize = s->cur_pic_ptr->f->linesize[0]; @@ -1030,9 +1030,9 @@ void ff_vc1_interp_mc(VC1Context *v) uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1)); uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1)); } - srcY = s->next_pic.f->data[0]; - srcU = s->next_pic.f->data[1]; - srcV = s->next_pic.f->data[2]; + srcY = s->next_pic.data[0]; + srcU = s->next_pic.data[1]; + srcV = s->next_pic.data[2]; interlace = !!(s->next_pic.f->flags & AV_FRAME_FLAG_INTERLACED); diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 93398e3fb2..d8d58bb7eb 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -235,15 +235,15 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd) v->sprite_output_frame->linesize[plane] * row; for (sprite = 0; sprite <= v->two_sprites; sprite++) { - uint8_t *iplane = s->cur_pic.f->data[plane]; - int iline = s->cur_pic.f->linesize[plane]; + uint8_t *iplane = s->cur_pic.data[plane]; + int iline = s->cur_pic.linesize[plane]; int ycoord = yoff[sprite] + yadv[sprite] * row; int yline = ycoord >> 16; int next_line; ysub[sprite] = ycoord & 0xFFFF; if (sprite) { - iplane = s->last_pic.f->data[plane]; - iline = s->last_pic.f->linesize[plane]; + iplane = s->last_pic.data[plane]; + iline = s->last_pic.linesize[plane]; } next_line = FFMIN(yline + 1, (v->sprite_height >> !!plane) - 1) * iline; if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) { @@ -317,12 +317,12 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) if (ret < 0) return ret; - if (!s->cur_pic.f || !s->cur_pic.f->data[0]) { + if (!s->cur_pic.data[0]) { av_log(avctx, AV_LOG_ERROR, "Got no sprites\n"); return AVERROR_UNKNOWN; } - if (v->two_sprites && (!s->last_pic_ptr || !s->last_pic.f->data[0])) { + if (v->two_sprites && (!s->last_pic_ptr || !s->last_pic.data[0])) { av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n"); v->two_sprites = 0; } @@ -340,14 +340,14 @@ static void vc1_sprite_flush(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; - AVFrame *f = s->cur_pic.f; + Picture *f = &s->cur_pic; int plane, i; /* Windows Media Image codecs have a convergence interval of two keyframes. Since we can't enforce it, clear to black the missing sprite. This is wrong but it looks better than doing nothing. */ - if (f && f->data[0]) + if (f->data[0]) for (plane = 0; plane < (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY ? 1 : 3); plane++) for (i = 0; i < v->sprite_height>>!!plane; i++) memset(f->data[plane] + i * f->linesize[plane], @@ -1230,9 +1230,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, v->end_mb_x = s->mb_width; if (v->field_mode) { - s->cur_pic.f->linesize[0] <<= 1; - s->cur_pic.f->linesize[1] <<= 1; - s->cur_pic.f->linesize[2] <<= 1; + s->cur_pic.linesize[0] <<= 1; + s->cur_pic.linesize[1] <<= 1; + s->cur_pic.linesize[2] <<= 1; s->linesize <<= 1; s->uvlinesize <<= 1; } @@ -1307,9 +1307,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, } if (v->field_mode) { v->second_field = 0; - s->cur_pic.f->linesize[0] >>= 1; - s->cur_pic.f->linesize[1] >>= 1; - s->cur_pic.f->linesize[2] >>= 1; + s->cur_pic.linesize[0] >>= 1; + s->cur_pic.linesize[1] >>= 1; + s->cur_pic.linesize[2] >>= 1; s->linesize >>= 1; s->uvlinesize >>= 1; if (v->s.pict_type != AV_PICTURE_TYPE_BI && v->s.pict_type != AV_PICTURE_TYPE_B) {