From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 5D4AA47406 for ; Thu, 7 Sep 2023 01:07:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 929E368C8D0; Thu, 7 Sep 2023 04:06:20 +0300 (EEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2043.outbound.protection.outlook.com [40.92.75.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AEC1168C8CE for ; Thu, 7 Sep 2023 04:06:18 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OhCvE6RpccNArB3pbzrV92NlB82IxfE4EVAPGxJPJVutwDJSSa3MrMatNgEqUGOVnH2DJbmEAphj3hr3D9/H00SnzXo6hXZLgFeV9RLcLSImcCuRevbq7GBEbQ8E6Nhy78jcB6zaPDN6Y4brDU+/cGBolLTXEtZSYhiCbDCyKeX/rff2P3sGXRXPGfLAB3bhhop3gkcOqZRr9dO+VQ8ZPBwRQ+4NTDuL9g5GfCBqbGvo4pwC65pC7sumoXUeagXTsAN8ct6sCqfM/BN4OGW0LnxV2ULKBNxAwdhM4pMvg8lmrWR2TAX+Uv2YN0ZuD0nCEfKQA4A5ilu98Yl/jr+v0g== 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=PQMBcu07s1welAQdO+rXtsl02G/yEwSBo1QU2rCLGHo=; b=QJlhFwX7grwqb6xWF0EA90beywxSrMk55bkkbh6X93b7svSFPl4UPeeVK8X7wimUw21T//xvvyBn9tChpeMTHXjnrs0NDqLTFrwrRI7PV3Ua67kVUPh/QTzNXov4UO7ZuVLy84xZxHaU6QazdN0qoLAU98lqr4l+gaJTvSjW+0tN1C7/TG4oYmv9he9pRc9rVFKB6lBP1gphqlvuB+mo/unenXpKdPrhaJnyg5AGnHZ1urZ2zSl96u0Bon1VXPJjMpKhUy9qXPYY6VD7cnl7K60rZCXI4vnG64T6coeEVwTHJggnmQAlT/ScjUGyOLtnNixkhpoH1FPWY/oiQqsgUw== 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=PQMBcu07s1welAQdO+rXtsl02G/yEwSBo1QU2rCLGHo=; b=m1hcvfnmR1+ICt9O7mBmP/QAVaw9j2p8iN77vBa9qVJwbsj/rHVTF1yvuUMuLIQPCoJfHym4Vkm6W3gGOsOGTt5LhpxfgMoF4T/XE5nWfjq9iyPudH2bEjTB1cjz+YZwQJdsBOPrEuK9aCaKI0CtI/VexUaDeGLigbc5dx4EEsbZ1ao2TMXqpRlP6CDW+djFA+naIubrt4SNB+IUtQeseDr9yVfE7QeytSbf5eVTQUfn6Dfkal6PJBnTClXzlx8EKCbiLsZk99ylgsq5g4eSqoJEiQDQB4HUZkHnlwmK3VCGS7666Y6nvejnkybxe2U0hjZt8Oa6v4Z4wxvNANLqbA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0336.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Thu, 7 Sep 2023 01:06:17 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6745.034; Thu, 7 Sep 2023 01:06:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2023 03:05:37 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [Q+LwYdVTB42Z3jMEYQ/jh0+sgN/oFsSt] X-ClientProxiedBy: ZR0P278CA0096.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::11) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20230907010538.488975-20-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0336:EE_ X-MS-Office365-Filtering-Correlation-Id: caf9ffab-70ae-4726-db53-08dbaf3ea376 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cSrIBxRVzKIftwQHeZYZUFLuqEHNDYj15InV30HgE4b+/Eq6Ln4EF0s6/Pe4fU9ukHnSYIZ5faAUEBqHiGBFMxnRMg9WSFEo2sNgU13y0cEiLORX4Luuh9eJvyTT/PSmIBa23RcJ5hR9i6GILdFiQgaQdi9WonT43BlbK/V3ptGjQEXe+OkHLaC4jtsHIdxu6B5dlSkVWECrqnYHhR8Y6JOnc6nlNhjtniZUnRYfFz3bXFrPXbsFzFeobo8DrCYFB3BYrW4FwRH4jH9eiEPeojmM592SkUUwRZqySQsM3QKPFz1k58xxObE3iZ9wVrxWNgEJ+yxVleV/KUAAhNNPM4hcXeyUhZnRqpZGP8feHKsFGxCmKvvRo0W/nCeaRa78czf66mHKqpfTqGU3K51TKBlC4x9OzOh0j3+8ONSf3+4IU2MwK8vn+5UgoEAFI3TqRW7x9zjPOUE3GU04GMNDPUdAsSdGsZqjj/8OuDRLVLuPxibKEeD8/bckQQ7bQkWvCLj87D1qe4U7HY5taUdkvnR+z7loozErXRwlOLhAAEtOFzQjINRthAfa2Csg3shpEge6bwZdM8lSReBskKcRcd4c+G++6rezWEU7fHP1zI5bbiW95v4vjodp6bKTzq+J X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iKroCOuf4ypal6nKW4C5593cg8tMF6XlG35h81bSPKE96vVVcZ+cI+obK1bd?= =?us-ascii?Q?KvurhXUP7fsdHBPdRNhokFNsAsM56VTIy1+5FLTnVypXlImewfJ1Dlvoxisd?= =?us-ascii?Q?W4NWI4z8SOXRRJR4/8oAQEfXWNRMIHJafUKux/cnEwSrPa/piSG7HenNw7ON?= =?us-ascii?Q?VC4oSaDn5FQwk2W09YRLDCywCMW1Hk58PqqPn9ks8qCSSTXUqlwCOSlUrnjm?= =?us-ascii?Q?7npF8dYmLRjfRTHppwnQ14N4nGnqAPgiJWQIe9VeXYtHCFU6hU4MqOXk7pmD?= =?us-ascii?Q?CN4kwf5A3EpXdfiybayRtjV+iAjnY8I7jsv9vRAhDCN/7SrgEaXwP6PmcOk1?= =?us-ascii?Q?U944ugfLIYoQJ6IErLtJszRh84h1SufTujnrwyI2/jH+fpUw41Ilas8L5XPf?= =?us-ascii?Q?hDndVw+pTzCoL8cGzubH3DxQysllyR3K45/TwAvBKHY/ibSnbj+y6/rhhT90?= =?us-ascii?Q?xfsf4V4i/lVFkL1cpdbmFDTIKQVu4cR+cN5zssP29fur/adfXp+ubomC+yW0?= =?us-ascii?Q?/Cmt7uOP2roF/aKGVf8LmCWTJxzLegdKn+6iEZRJa62kF1P1stObF7gydTsH?= =?us-ascii?Q?8K2FwZ1ZGBkhoV8iI3wW33QzTX/3OajU1FIctONGUQg57kkQjk/Yo7tuzBhE?= =?us-ascii?Q?3k5Xj3Cu9xR2amPJ8iv2Azo195r9DAeNKc13ni2nxCCSpLKkwDIblwNimL0T?= =?us-ascii?Q?U00lXVAdnswFr4R/ysMKkJ/wmmqtcs0I3feH1qVzfcABJF0xmaYz9hSEJyK3?= =?us-ascii?Q?DdTfv+dXKbbDvWjfp43qKajlUiIflJoauy7qTsIqK6G/Cs7SgooCjn/GPo6p?= =?us-ascii?Q?ANvDYm/b+douQtwM9/pKGNrmLKmRkyox7iUH1581cD/Z4wNamk9l2if3nJJ8?= =?us-ascii?Q?RLuUjlCt/8iu8svcB0SO+dJsxfUhtsfc53YbBx2rwroFo+o/z4pr0SoBfXw3?= =?us-ascii?Q?0c0rBsOm1CxbSRyLWpV706VBn9IgWCPfezZGir4jOna7DDXEgfDoS4nYQdpg?= =?us-ascii?Q?dv9mw6Nm7g3MxmkCyI+xw8iFyhtpb16tQ8eZopGUw4uqRsL8C9w/jmgL+z47?= =?us-ascii?Q?Khwn+pXKDHVT8Z4ALhocLccyyUy8u8ps7nbY9zs+lKUlbFA8PzpJaXnpI7O+?= =?us-ascii?Q?F3OSrn3dVFtpMAZtinRlCEPNw9coWieiqo1qZxqAvbPBmr8tDufQcpudGNBc?= =?us-ascii?Q?IQaVKJztG5DhwP3XBNCXZO7wg4GTRHThQMYI/RT5Xzk6LkhzM4us3EcuDVY/?= =?us-ascii?Q?JuSnCw9bxVlS7yJpW80F?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: caf9ffab-70ae-4726-db53-08dbaf3ea376 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 01:06:17.0713 (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: DU2P250MB0336 Subject: [FFmpeg-devel] [PATCH v2 21/22] avutil/imgutils: Add wrapper for av_image_copy() to avoid casts 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: av_image_copy() accepts const uint8_t* const * as source; lots of user have uint8_t* const * and therefore either cast (the majority) or copy the array of pointers. This commit changes this by adding a static inline wrapper for av_image_copy() that casts between the two types so that we do not need to add casts everywhere else. Signed-off-by: Andreas Rheinhardt --- The same can of course be done for the other functions affected by this issue. I just wanted to get feedback about this before investing time into it. doc/APIchanges | 4 ++++ doc/examples/demux_decode.c | 6 +++--- libavcodec/amfenc.c | 6 +++--- libavcodec/libkvazaar.c | 6 +++--- libavcodec/libopenh264dec.c | 3 ++- libavcodec/libvpxdec.c | 4 ++-- libavcodec/mediacodecenc.c | 7 ++----- libavcodec/mmaldec.c | 4 ++-- libavcodec/nuv.c | 4 ++-- libavcodec/nvenc.c | 6 +++--- libavcodec/omx.c | 3 ++- libavcodec/v210dec.c | 3 ++- libavdevice/xv.c | 4 ++-- libavfilter/lavfutils.c | 3 ++- libavfilter/vf_framepack.c | 28 ++++++++++------------------ libavfilter/vf_pullup.c | 12 ++++++------ libavfilter/yadif_common.c | 6 +++--- libavutil/frame.c | 8 +++----- libavutil/hwcontext_d3d11va.c | 8 ++++---- libavutil/hwcontext_dxva2.c | 4 ++-- libavutil/imgutils.h | 16 ++++++++++++++++ 21 files changed, 78 insertions(+), 67 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0914a4da32..17e7c91f02 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-09-07 - xxxxxxxxxx - lavu 58.xx.100 - imgutils.h + Add av_image_copy2(), a wrapper around the av_image_copy() + to overcome limitations of automatic conversions. + 2023-09-07 - xxxxxxxxxx - lavu 58.xx.100 - fifo.h Constify the AVFifo pointees in av_fifo_peek() and av_fifo_peek_to_cb(). diff --git a/doc/examples/demux_decode.c b/doc/examples/demux_decode.c index 298a369f43..f26611d8f4 100644 --- a/doc/examples/demux_decode.c +++ b/doc/examples/demux_decode.c @@ -78,9 +78,9 @@ static int output_video_frame(AVFrame *frame) /* copy decoded frame to destination buffer: * this is required since rawvideo expects non aligned data */ - av_image_copy(video_dst_data, video_dst_linesize, - (const uint8_t **)(frame->data), frame->linesize, - pix_fmt, width, height); + av_image_copy2(video_dst_data, video_dst_linesize, + frame->data, frame->linesize, + pix_fmt, width, height); /* write to rawvideo file */ fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file); diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 518b8396e7..061859f85c 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -430,9 +430,9 @@ static int amf_copy_surface(AVCodecContext *avctx, const AVFrame *frame, dst_data[i] = plane->pVtbl->GetNative(plane); dst_linesize[i] = plane->pVtbl->GetHPitch(plane); } - av_image_copy(dst_data, dst_linesize, - (const uint8_t**)frame->data, frame->linesize, frame->format, - avctx->width, avctx->height); + av_image_copy2(dst_data, dst_linesize, + frame->data, frame->linesize, frame->format, + avctx->width, avctx->height); return 0; } diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 2ef34dd82e..0ebf37607a 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -221,9 +221,9 @@ static int libkvazaar_encode(AVCodecContext *avctx, frame->width / 2, 0 }; - av_image_copy(dst, dst_linesizes, - (const uint8_t **)frame->data, frame->linesize, - frame->format, frame->width, frame->height); + av_image_copy2(dst, dst_linesizes, + frame->data, frame->linesize, + frame->format, frame->width, frame->height); } input_pic->pts = frame->pts; diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index af53219b41..7d650ae03e 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -141,7 +141,8 @@ static int svc_decode_frame(AVCodecContext *avctx, AVFrame *avframe, linesize[0] = info.UsrData.sSystemBuffer.iStride[0]; linesize[1] = linesize[2] = info.UsrData.sSystemBuffer.iStride[1]; linesize[3] = 0; - av_image_copy(avframe->data, avframe->linesize, (const uint8_t **) ptrs, linesize, avctx->pix_fmt, avctx->width, avctx->height); + av_image_copy2(avframe->data, avframe->linesize, ptrs, linesize, + avctx->pix_fmt, avctx->width, avctx->height); avframe->pts = info.uiOutYuvTimeStamp; avframe->pkt_dts = AV_NOPTS_VALUE; diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 40c8caf887..72ef5fa9a7 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -329,8 +329,8 @@ static int vpx_decode(AVCodecContext *avctx, AVFrame *picture, } else { if ((ret = ff_get_buffer(avctx, picture, 0)) < 0) return ret; - av_image_copy(picture->data, picture->linesize, (const uint8_t**)planes, - linesizes, avctx->pix_fmt, img->d_w, img->d_h); + av_image_copy2(picture->data, picture->linesize, planes, + linesizes, avctx->pix_fmt, img->d_w, img->d_h); } *got_frame = 1; } diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c index 485ab7b4ed..a1ae5d5ec5 100644 --- a/libavcodec/mediacodecenc.c +++ b/libavcodec/mediacodecenc.c @@ -428,9 +428,6 @@ static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, ui MediaCodecEncContext *s = avctx->priv_data; uint8_t *dst_data[4] = {}; int dst_linesize[4] = {}; - const uint8_t *src_data[4] = { - frame->data[0], frame->data[1], frame->data[2], frame->data[3] - }; if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) { dst_data[0] = dst; @@ -449,8 +446,8 @@ static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, ui av_assert0(0); } - av_image_copy(dst_data, dst_linesize, src_data, frame->linesize, - avctx->pix_fmt, avctx->width, avctx->height); + av_image_copy2(dst_data, dst_linesize, frame->data, frame->linesize, + avctx->pix_fmt, avctx->width, avctx->height); } static int mediacodec_send(AVCodecContext *avctx, diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 8d67d10cd9..4bb3eb22ef 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -648,8 +648,8 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, av_image_fill_arrays(src, linesize, buffer->data + buffer->type->video.offset[0], avctx->pix_fmt, w, h, 1); - av_image_copy(frame->data, frame->linesize, (const uint8_t **)src, linesize, - avctx->pix_fmt, avctx->width, avctx->height); + av_image_copy2(frame->data, frame->linesize, src, linesize, + avctx->pix_fmt, avctx->width, avctx->height); } frame->sample_aspect_ratio = avctx->sample_aspect_ratio; diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 82048e9326..1dda770c97 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -56,8 +56,8 @@ static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height) int src_linesize[4]; av_image_fill_arrays(src_data, src_linesize, src, f->format, width, height, 1); - av_image_copy(f->data, f->linesize, (const uint8_t **)src_data, src_linesize, - f->format, width, height); + av_image_copy2(f->data, f->linesize, src_data, src_linesize, + f->format, width, height); } /** diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 9875f02dc8..65b96d6cf6 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2008,9 +2008,9 @@ static int nvenc_copy_frame(AVCodecContext *avctx, NvencSurface *nv_surface, if (frame->format == AV_PIX_FMT_YUV420P) FFSWAP(uint8_t*, dst_data[1], dst_data[2]); - av_image_copy(dst_data, dst_linesize, - (const uint8_t**)frame->data, frame->linesize, frame->format, - avctx->width, avctx->height); + av_image_copy2(dst_data, dst_linesize, + frame->data, frame->linesize, frame->format, + avctx->width, avctx->height); return 0; } diff --git a/libavcodec/omx.c b/libavcodec/omx.c index 8d6519d141..82fd492071 100644 --- a/libavcodec/omx.c +++ b/libavcodec/omx.c @@ -793,7 +793,8 @@ static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, need_copy = 1; } if (need_copy) - av_image_copy(dst, linesize, (const uint8_t**) frame->data, frame->linesize, avctx->pix_fmt, avctx->width, avctx->height); + av_image_copy2(dst, linesize, frame->data, frame->linesize, + avctx->pix_fmt, avctx->width, avctx->height); buffer->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; buffer->nOffset = 0; // Convert the timestamps to microseconds; some encoders can ignore diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 04bcc612b7..d80fb4e7c6 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -201,7 +201,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, if (ret < 0) return ret; decode_row((const uint32_t *)psrc, (uint16_t *)pointers[0], (uint16_t *)pointers[1], (uint16_t *)pointers[2], avctx->width * avctx->height, s->unpack_frame); - av_image_copy(pic->data, pic->linesize, (const uint8_t **)pointers, linesizes, avctx->pix_fmt, avctx->width, avctx->height); + av_image_copy2(pic->data, pic->linesize, pointers, linesizes, + avctx->pix_fmt, avctx->width, avctx->height); av_freep(&pointers[0]); } diff --git a/libavdevice/xv.c b/libavdevice/xv.c index b3d79d57a8..cba933ef17 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -315,8 +315,8 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4], } } - av_image_copy(data, img->pitches, (const uint8_t **)input_data, linesize, - xv->image_format, img->width, img->height); + av_image_copy2(data, img->pitches, input_data, linesize, + xv->image_format, img->width, img->height); return xv_repaint(s); } diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c index 9aa781ef7b..6130f21e7f 100644 --- a/libavfilter/lavfutils.c +++ b/libavfilter/lavfutils.c @@ -117,7 +117,8 @@ int ff_load_image(uint8_t *data[4], int linesize[4], goto end; ret = 0; - av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h); + av_image_copy2(data, linesize, frame->data, frame->linesize, + *pix_fmt, *w, *h); end: avcodec_free_context(&codec_ctx); diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c index 8693ad6488..cbfcf1e036 100644 --- a/libavfilter/vf_framepack.c +++ b/libavfilter/vf_framepack.c @@ -234,22 +234,18 @@ static void horizontal_frame_pack(AVFilterLink *outlink, } else { for (i = 0; i < 2; i++) { const int psize = 1 + (s->depth > 8); - const uint8_t *src[4]; uint8_t *dst[4]; int sub_w = psize * s->input_views[i]->width >> s->pix_desc->log2_chroma_w; - src[0] = s->input_views[i]->data[0]; - src[1] = s->input_views[i]->data[1]; - src[2] = s->input_views[i]->data[2]; - dst[0] = out->data[0] + i * s->input_views[i]->width * psize; dst[1] = out->data[1] + i * sub_w; dst[2] = out->data[2] + i * sub_w; - av_image_copy(dst, out->linesize, src, s->input_views[i]->linesize, - s->input_views[i]->format, - s->input_views[i]->width, - s->input_views[i]->height); + av_image_copy2(dst, out->linesize, + s->input_views[i]->data, s->input_views[i]->linesize, + s->input_views[i]->format, + s->input_views[i]->width, + s->input_views[i]->height); } } } @@ -263,15 +259,10 @@ static void vertical_frame_pack(AVFilterLink *outlink, int i; for (i = 0; i < 2; i++) { - const uint8_t *src[4]; uint8_t *dst[4]; int linesizes[4]; int sub_h = s->input_views[i]->height >> s->pix_desc->log2_chroma_h; - src[0] = s->input_views[i]->data[0]; - src[1] = s->input_views[i]->data[1]; - src[2] = s->input_views[i]->data[2]; - dst[0] = out->data[0] + i * out->linesize[0] * (interleaved + s->input_views[i]->height * (1 - interleaved)); dst[1] = out->data[1] + i * out->linesize[1] * @@ -286,10 +277,11 @@ static void vertical_frame_pack(AVFilterLink *outlink, linesizes[2] = out->linesize[2] + interleaved * out->linesize[2]; - av_image_copy(dst, linesizes, src, s->input_views[i]->linesize, - s->input_views[i]->format, - s->input_views[i]->width, - s->input_views[i]->height); + av_image_copy2(dst, linesizes, + s->input_views[i]->data, s->input_views[i]->linesize, + s->input_views[i]->format, + s->input_views[i]->width, + s->input_views[i]->height); } } diff --git a/libavfilter/vf_pullup.c b/libavfilter/vf_pullup.c index 7245684085..14beb972c5 100644 --- a/libavfilter/vf_pullup.c +++ b/libavfilter/vf_pullup.c @@ -666,9 +666,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) goto end; } - av_image_copy(b->planes, s->planewidth, - (const uint8_t**)in->data, in->linesize, - inlink->format, inlink->w, inlink->h); + av_image_copy2(b->planes, s->planewidth, + in->data, in->linesize, + inlink->format, inlink->w, inlink->h); p = (in->flags & AV_FRAME_FLAG_INTERLACED) ? !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0; @@ -714,9 +714,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); - av_image_copy(out->data, out->linesize, - (const uint8_t**)f->buffer->planes, s->planewidth, - inlink->format, inlink->w, inlink->h); + av_image_copy2(out->data, out->linesize, + f->buffer->planes, s->planewidth, + inlink->format, inlink->w, inlink->h); ret = ff_filter_frame(outlink, out); pullup_release_frame(f); diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c index 561659e346..b26989f574 100644 --- a/libavfilter/yadif_common.c +++ b/libavfilter/yadif_common.c @@ -89,9 +89,9 @@ static void fixstride(AVFilterLink *link, AVFrame *f) if(!dst) return; av_frame_copy_props(dst, f); - av_image_copy(dst->data, dst->linesize, - (const uint8_t **)f->data, f->linesize, - dst->format, dst->width, dst->height); + av_image_copy2(dst->data, dst->linesize, + f->data, f->linesize, + dst->format, dst->width, dst->height); av_frame_unref(f); av_frame_move_ref(f, dst); av_frame_free(&dst); diff --git a/libavutil/frame.c b/libavutil/frame.c index b6cee2d886..a3f07ca089 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -833,7 +833,6 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, static int frame_copy_video(AVFrame *dst, const AVFrame *src) { - const uint8_t *src_data[4]; int planes; if (dst->width < src->width || @@ -848,10 +847,9 @@ static int frame_copy_video(AVFrame *dst, const AVFrame *src) if (!dst->data[i] || !src->data[i]) return AVERROR(EINVAL); - memcpy(src_data, src->data, sizeof(src_data)); - av_image_copy(dst->data, dst->linesize, - src_data, src->linesize, - dst->format, src->width, src->height); + av_image_copy2(dst->data, dst->linesize, + src->data, src->linesize, + dst->format, src->width, src->height); return 0; } diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index aa50538d64..cc8c97d2b6 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -452,8 +452,8 @@ static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, fill_texture_ptrs(map_data, map_linesize, ctx, &desc, &map); - av_image_copy(dst->data, dst->linesize, (const uint8_t **)map_data, map_linesize, - ctx->sw_format, w, h); + av_image_copy2(dst->data, dst->linesize, map_data, map_linesize, + ctx->sw_format, w, h); ID3D11DeviceContext_Unmap(device_hwctx->device_context, staging, 0); } else { @@ -464,8 +464,8 @@ static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, fill_texture_ptrs(map_data, map_linesize, ctx, &desc, &map); - av_image_copy(map_data, map_linesize, (const uint8_t **)src->data, src->linesize, - ctx->sw_format, w, h); + av_image_copy2(map_data, map_linesize, src->data, src->linesize, + ctx->sw_format, w, h); ID3D11DeviceContext_Unmap(device_hwctx->device_context, staging, 0); diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c index ea378df720..2c11f151ff 100644 --- a/libavutil/hwcontext_dxva2.c +++ b/libavutil/hwcontext_dxva2.c @@ -356,8 +356,8 @@ static int dxva2_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, if (ret < 0) goto fail; - av_image_copy(map->data, map->linesize, (const uint8_t **)src->data, src->linesize, - ctx->sw_format, src->width, src->height); + av_image_copy2(map->data, map->linesize, src->data, src->linesize, + ctx->sw_format, src->width, src->height); fail: av_frame_free(&map); diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 91312a72d3..c7fc330117 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -174,6 +174,22 @@ void av_image_copy(uint8_t * const dst_data[4], const int dst_linesizes[4], const uint8_t * const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height); +/** + * Wrapper around av_image_copy() to workaround the limitation + * that the conversion from uint8_t * const * to const uint8_t * const * + * is not performed automatically in C. + * @see av_image_copy + */ +static inline +void av_image_copy2(uint8_t * const dst_data[4], const int dst_linesizes[4], + uint8_t * const src_data[4], const int src_linesizes[4], + enum AVPixelFormat pix_fmt, int width, int height) +{ + av_image_copy(dst_data, dst_linesizes, + (const uint8_t * const *)src_data, src_linesizes, + pix_fmt, width, height); +} + /** * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where * available, this function will use special functionality for reading from such -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".