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 EF83E40B9C for ; Sat, 7 May 2022 11:30:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D54268B3C5; Sat, 7 May 2022 14:29:17 +0300 (EEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2020.outbound.protection.outlook.com [40.92.91.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14F7268B3B4 for ; Sat, 7 May 2022 14:29:14 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyMyTyGbv2aVCvXBU6iYjtRUCgyusxjY/W4f6HaDYA3dzfjWOQnCPt5hdi9d98iYtrSfaJnDJ9RB3N/G6Zd3dzgRsR+Is3/n9W/EBmZSecLnfZ1swmWJwncvuFsli0fakmf96M6OMDsn46FfJr9uo+RyuM6bVPB5T5qSLRt/Jh1HC/wynVOWRM3wh1uREjTmf1A1wHCOnL2allWwpl6slok+JXO0nhnty033P8LNIre8uHrRzyPlLtQeKkNP9jfQ/zKSmhxfoQMKsoKdi0DBukdVy9x7EfT6uXsU4xnBZkPY1b0Cxq4JfadWZvEX+pUo/jqcCYrwI7NdV4fR6qki2w== 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=V3ch0UyERBZTHrC2JXf0/WaxTkbV0fscDQMLDVy1jCk=; b=BwAOtZfxdWuOajlbD523drKfOK3/LYCD3ZL4pGw3hL96hiA7HILZG/fhcNW95KwoNq4kdvoZvW+n9rld986v6fVYKcl8nXVfXMJ1+IbRnxxq9l5fm7T1MC1PSGAJzWWLQVJXqkXLoj88lLb5oiQfKJyhy+VwQ/+2YO9/LOt1kF1K2bUJrdHNbGFBT7CWDf2nRduQfy6811YVdVCX6ylIOn4uQ24ZGfgDZw4dwH2UXUaRrzY5kiGgyh8X+qGamhmRCDbVwD5/N3VshsDiz1MSdc82bcqzW3cMi0gn2b157iNcmkEhAvUuVUqLGo/FhK0vb269rZp2vwGxQqncqKX2Hg== 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=V3ch0UyERBZTHrC2JXf0/WaxTkbV0fscDQMLDVy1jCk=; b=ZttHMPQ8L91adVK19702kkXRmji07HaMLKGADBQYzu54ckCqbxqFxA6zvFsWvk6tji/Vpe8ihlhDV2hYxQ9Cc8Xp0jv5OGZQ2tf9FHhKcoSHj4m7L68mcgiIcAQ9UykJmin1TPb7Wuk0cPgNJ2xAGagOUeKk9e0P5pDG/32m63IFSMoe1vCkCK31Gf0A7VUESqUzdUKYJjpd+DaupzgU8maV7B4rmvIpWezCBJq+Oq6Kn0Pakbigfn152jJOOHI+LctcOc0nRiB0bkj5z1Z+R8oVh3hQcqtykaQuSq757PmC0J4gmr6nfyGFyThw1hwDxEaiiIaQJ5RmQ+pAF72gGg== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by DB6PR0102MB2663.eurprd01.prod.exchangelabs.com (2603:10a6:6:e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Sat, 7 May 2022 11:29:08 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431%6]) with mapi id 15.20.5206.024; Sat, 7 May 2022 11:29:08 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 May 2022 13:27:55 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [9CbqTGOX0XsclYn8gIHn5qsBiOw45iPm] X-ClientProxiedBy: ZRAP278CA0004.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::14) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220507112830.406162-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ddb325bc-4dae-42dc-bb9a-08da301ccca8 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiRIovyFjHwHllp74iOQFItwr5ii/vgMvbz2dRhKgkeS+sfBTsH2gPH/BE0FLxrXTBXDpTqAMqE2qqY1JoLnFmf4jVfI/SRMDOzpgM6UIApM8/gLaChtTWNsOh1NyqRzBcWHzDPKHr2rPTjE6bIPzpyFdD8KvEndKnASotObjnPv5GCpkjGheadBAiIiW8jlzvG3nNFZQR4a/NbRqPnPgms6SZ1Uj5LC9I6sDV6p568p5edzkYao7cNCt82AxnytMcphZ2KqMiA/y92+Wql/KqdRJVHP3yK54scsHzoDLl9NRjSyLhNuFEnhlWIL/kRN3i9w58WnRtKiOm27TVbLifFczgCKe9JMHtUSTj26LXQg1NB+aTOhGKP8pdppt+rdsBQeryN4AwkUWtOx72C/ri1RSA/LUpooqmXb7TkKz/IB0Xu+nnuRGcYUNco0HVkUwa5xwCdIGWeFsubkjaYiyRaDIao63YAs5pGHVkWHrRAdCFefFtnM1YauB6ZMFlImLzdDZi6WxpNBHbI+kgWUjZYjJ1VYGD+y2qs5z0QEtpbfQbOYpCuUtvkcxw38KudPwVyqq4lOrzHItKk3GFPkrj9igWOSS+nmMQyKZBS1nXrlmCLKd6rct3DgQYbG6LbxEr0IudXDhgezooDaM7J57JjAbXHKymhvJBuLQpoFMJewLT5A9VVbxW6jxuT1aqD72LbTTCFmKiipTpTHhT06aEZjg+p+AI9S89QwxyUsi+pxar66eUHwWGzGGDWkVSi9O+4= X-MS-TrafficTypeDiagnostic: DB6PR0102MB2663:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1lovh9BNCGcgv5EJvZfgWTlpfdvkzcE8/dJsBSn0GZ2eBYGcCQGOaTXFEGNPeTM5T9CsWmdwQ/kzTOiGGoy9BNaP1/4vLpBzNUBMNZSdEJ4/fBaRAkxHnYp0FWaA3+DWtHpZtlZJszZj2/XAWNVvBomrIOLUT/UKgIxOI9YTYCa/tRkOBhmFeFhTzTnlpv/yS12LwJfn470T/fi9vyodLG8ICbXuNUeJG0dbHvfQ3qn7T8ZoIqNFkSatn6aM+dXRg+OUcM+WeqdVZqSFfK+i4/KkmmGPxAde44szdQWQbr2cOFZ5XbeRvY0ZbNf5LXhPax8jxEBf691Rjfttjqq4RMLKtyF0RZhqLGok1hwiQ/u9VP0CXEuo8FzfkEfyYa2KEnZsnwnTE0e2PjDZuETk8h8T1GwgbbH6hK61rF1TSBtQYFcVj+TFMbT8sIFHAyeEJrVQqNS/NYO+W2L+8ZF9LdteE6BzpSwtVH9u1TF4U0D+4oI1z4v2sdurIL/F4Ye8eMdjFjT8EhKiqVGVSiWsg2mCGeTEwHI+4WkxPqzMe3tF90ZpcwOMpUa7wgEV2BbkOfg7eCQEg0Qr+OvPN+T4YEOTpCugln4lJSziURSScirzByL1YFfAB+6M3BvKN289 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YJOPUOXiyDFOHxfc/FJQysmg2eQgTCsosVxe5PKiAjgVAIix+cCnBO/6ZObU?= =?us-ascii?Q?05tWSdhAatK/ad+lfWxEyr/Bs9qyJOfPUu43iwAOoLHaORTEWF3VrA2PG9gK?= =?us-ascii?Q?9eutmmrMflOQitcF5r6gTPO2/u47X7JiV4QSz2E7aoJdSIEkxiEnL7IMO9FV?= =?us-ascii?Q?iHynyI6YX898VmocE0efFo3tYGgQPKFlpsMUkBBn7PGprBhTrGe9aRxF4ZVf?= =?us-ascii?Q?z2y4UFg32TmAB/DyWfQjEist4FxynN3QpMelnr0iK3NM3XlyaUGHlFc4ppeE?= =?us-ascii?Q?Ac/JWjOeOOwwHHNV3A9b1VSng6MQ/zE7rGuV8jjxaf6e1q8oXjuq4E5ai/Cp?= =?us-ascii?Q?wnLKDJngRlLdigw6jQnwTB/NLIUSjX5JP83TCDziX7bJJDoTeSdUKajvbHns?= =?us-ascii?Q?yHhQsaaZOOISz5YwqUZpWF/yDGs1njF8v4AuCE/NSGPpnvCEv3N7J3X/+Eis?= =?us-ascii?Q?iV++v0bVYIdiRWBvJiTg2WAISdsXnKFfsHGhAUd/7im6583Zjrq6paQqD6fb?= =?us-ascii?Q?bYQNk8dCskhyHmkEtaLbFein9gATXUMN04QSo6XAY5hJ62Z/ya2Wqi+vv39/?= =?us-ascii?Q?XGzoxL2HRqlowHXybmF0FJeyWE+4bBnWslumGmPYZEJiNNgZpAnpXvO3Zt18?= =?us-ascii?Q?2b4M4QWunIhJKZFnny0WBK7NTvsTFZBQ1gvxag6sdTUfXy8OXSljvycHCIF1?= =?us-ascii?Q?luq96TkmVPlihjPHCrv7anVD2FjsT9FGsTBFronRAdubEri0i4h/Ng6TBP77?= =?us-ascii?Q?Tqevzu7SiJfbpRwkcipZNoVmfY/wtEtQFA1K5e5NtZ93ysAviCLg+GUienzt?= =?us-ascii?Q?DEKm9H1ut5iEUsuXuQLliz156+50r97VEDeFsGwvsucTVBlSApsKxmwGJfi0?= =?us-ascii?Q?TmnFoDklS53TEHyld9L+0j2wIOksSAGFurmo6J+aYLkrKy8C6HQk0kqy8bMi?= =?us-ascii?Q?8O8L9rBIIcSne9ZwlBkqpV6oLHIFB+geITRb70rCEMVtEiDBjBEWv+XQ/yYZ?= =?us-ascii?Q?E9yng8s2xW8+gZ/2mVYnjJuDuq8pOh59gh5q67pj6qa4G6joSdsgWvEWfsyw?= =?us-ascii?Q?ME8cjYezF+R06iNbJikJ7WwUmHhKnycQJTlzY73cfZFOvoz6pmaLw//2V4Y1?= =?us-ascii?Q?uypaRy7QOBSJZCkZI3/X1n/9+SsosPymVM58hGfnOhXghryD2yrAjxTSoxYz?= =?us-ascii?Q?nm0m5aFQ6Jps1f1N36dC7Cq10os7j0agY/tOJxTCsLTs1TDS8TwgKPcpVyaX?= =?us-ascii?Q?fZkpRHBH0flx7sixcm1KR9DlbTEgLJ+lmDSp/APfPFnxcIqiHNqXJ2IdSfvh?= =?us-ascii?Q?S582Qn851xiBCAhzJwmO1tCiW+h7upEZJAMoP/3vwhfGGNPPFBrJnok+C1KM?= =?us-ascii?Q?42OdzGPLcTBcuPxymI447ykONBwY2fOp9/xfzWxKP2AY5xakBEWVvdFo5Cs9?= =?us-ascii?Q?h2R0eD1BLjC0+SyseM0bV0JIGKkKBTB6jOmGTzcbRyIGMIdVNkPr9A=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddb325bc-4dae-42dc-bb9a-08da301ccca8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 11:29:07.9375 (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: DB6PR0102MB2663 Subject: [FFmpeg-devel] [PATCH 09/44] avformat/utils: Move ff_get_packet_palette() to rawutils.c 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: ff_get_packet_palette() and ff_reshuffle_raw_rgb() belong together: E.g. the former takes the return value of the latter as argument. So move ff_get_packet_palette() to rawutils.c (which consists solely of ff_reshuffle_raw_rgb()). Also add a separate header for these two functions. Signed-off-by: Andreas Rheinhardt --- libavformat/avienc.c | 1 + libavformat/internal.h | 27 -------------------- libavformat/movenc.c | 1 + libavformat/rawutils.c | 28 ++++++++++++++++++++- libavformat/rawutils.h | 56 ++++++++++++++++++++++++++++++++++++++++++ libavformat/utils.c | 24 ------------------ 6 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 libavformat/rawutils.h diff --git a/libavformat/avienc.c b/libavformat/avienc.c index e36e88335f..2264241d57 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -28,6 +28,7 @@ #include "config_components.h" #include "riff.h" #include "mpegts.h" +#include "rawutils.h" #include "libavformat/avlanguage.h" #include "libavutil/avstring.h" #include "libavutil/avutil.h" diff --git a/libavformat/internal.h b/libavformat/internal.h index eb18277cea..da9abde637 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -901,33 +901,6 @@ int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int */ int ff_standardize_creation_time(AVFormatContext *s); -#define CONTAINS_PAL 2 -/** - * Reshuffles the lines to use the user specified stride. - * - * @param ppkt input and output packet - * @return negative error code or - * 0 if no new packet was allocated - * non-zero if a new packet was allocated and ppkt has to be freed - * CONTAINS_PAL if in addition to a new packet the old contained a palette - */ -int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride); - -/** - * Retrieves the palette from a packet, either from side data, or - * appended to the video data in the packet itself (raw video only). - * It is commonly used after a call to ff_reshuffle_raw_rgb(). - * - * Use 0 for the ret parameter to check for side data only. - * - * @param pkt pointer to packet before calling ff_reshuffle_raw_rgb() - * @param ret return value from ff_reshuffle_raw_rgb(), or 0 - * @param palette pointer to palette buffer - * @return negative error code or - * 1 if the packet has a palette, else 0 - */ -int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette); - struct AVBPrint; /** * Finalize buf into extradata and set its size appropriately. diff --git a/libavformat/movenc.c b/libavformat/movenc.c index d32328d40c..c720fd742d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -62,6 +62,7 @@ #include "mov_chan.h" #include "movenc_ttml.h" #include "mux.h" +#include "rawutils.h" #include "ttmlenc.h" #include "version.h" #include "vpcc.h" diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c index 996412adb9..e44c946d47 100644 --- a/libavformat/rawutils.c +++ b/libavformat/rawutils.c @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/intreadwrite.h" +#include "libavcodec/packet.h" #include "avformat.h" -#include "internal.h" +#include "rawutils.h" int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride) { @@ -65,3 +67,27 @@ fail: return ret; } + +int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette) +{ + uint8_t *side_data; + size_t size; + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size); + if (side_data) { + if (size != AVPALETTE_SIZE) { + av_log(s, AV_LOG_ERROR, "Invalid palette side data\n"); + return AVERROR_INVALIDDATA; + } + memcpy(palette, side_data, AVPALETTE_SIZE); + return 1; + } + + if (ret == CONTAINS_PAL) { + for (int i = 0; i < AVPALETTE_COUNT; i++) + palette[i] = AV_RL32(pkt->data + pkt->size - AVPALETTE_SIZE + i*4); + return 1; + } + + return 0; +} diff --git a/libavformat/rawutils.h b/libavformat/rawutils.h new file mode 100644 index 0000000000..a91123412b --- /dev/null +++ b/libavformat/rawutils.h @@ -0,0 +1,56 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_RAWUTILS_H +#define AVFORMAT_RAWUTILS_H + +#include +#include "libavcodec/codec_par.h" +#include "libavcodec/packet.h" +#include "avformat.h" + +#define CONTAINS_PAL 2 +/** + * Reshuffles the lines to use the user specified stride. + * + * @param ppkt input and output packet + * @return negative error code or + * 0 if no new packet was allocated + * non-zero if a new packet was allocated and ppkt has to be freed + * CONTAINS_PAL if in addition to a new packet the old contained a palette + */ +int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride); + +/** + * Retrieves the palette from a packet, either from side data, or + * appended to the video data in the packet itself (raw video only). + * It is commonly used after a call to ff_reshuffle_raw_rgb(). + * + * Use 0 for the ret parameter to check for side data only. + * + * @param pkt pointer to packet before calling ff_reshuffle_raw_rgb() + * @param ret return value from ff_reshuffle_raw_rgb(), or 0 + * @param palette pointer to palette buffer + * @return negative error code or + * 1 if the packet has a palette, else 0 + */ +int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette); + +#endif /* AVFORMAT_RAWUTILS_H */ diff --git a/libavformat/utils.c b/libavformat/utils.c index b53e2aff0c..cc5507a19e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1715,30 +1715,6 @@ int ff_standardize_creation_time(AVFormatContext *s) return ret; } -int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette) -{ - uint8_t *side_data; - size_t size; - - side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size); - if (side_data) { - if (size != AVPALETTE_SIZE) { - av_log(s, AV_LOG_ERROR, "Invalid palette side data\n"); - return AVERROR_INVALIDDATA; - } - memcpy(palette, side_data, AVPALETTE_SIZE); - return 1; - } - - if (ret == CONTAINS_PAL) { - for (int i = 0; i < AVPALETTE_COUNT; i++) - palette[i] = AV_RL32(pkt->data + pkt->size - AVPALETTE_SIZE + i*4); - return 1; - } - - return 0; -} - int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf) { int ret; -- 2.32.0 _______________________________________________ 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".