From patchwork Sat May 30 16:44:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 20020 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2368D44BE04 for ; Sat, 30 May 2020 19:45:17 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F271368025D; Sat, 30 May 2020 19:45:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26A136801C6 for ; Sat, 30 May 2020 19:45:10 +0300 (EEST) Received: by mail-qt1-f193.google.com with SMTP id c12so4499385qtq.11 for ; Sat, 30 May 2020 09:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nFTOLPzZ+CRUXd2gLRqsr+XKmDcfJv4vlH9Nzxn5qZQ=; b=l/FDHh3t8B9CRq0n6+AfUYRuwY+CpZAhSDz5/p+plbb355WjUtf0WC8iYX38T/DiM1 /aqpgeS+DcqTCiM7dXeZcuAFyrbxk5zZjqmveEgOJt8HYSAZ0Ra3QY8hOyM/C9N9o4Ix FECYSz6nU3B2ppDV/16K8bxdRL7wnbDR6T9TpLbNAi9jNQDGe0LpOdq5QZekitiVQvOM NVJXozqTdd7MQ/IAioPSFLvjngEkW+v3PaeVOzYISqueIr5XWfr24ywpg9Wkrb7vDYwl rLpu4Rq/J/nZ3/lLJt/nifvy3ZcEdgusyFpZwN2XkcG2h0c42RZ+RQh06F9xC2G+cR06 B9oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nFTOLPzZ+CRUXd2gLRqsr+XKmDcfJv4vlH9Nzxn5qZQ=; b=B1/RJJ+4B+Adbx5rO07xW4HXWRiEPA2RzwF9XGopK7E8UcIqorENjSOjjjzffzMCyq WGpHBAyp/BkGkyNn/pSyNdlN/rHmDzmMZHYuJXaj3q69OPuIhkcilNlUsWmGU4lJBf3E MDFeyAlWp4DqMxnpen9x8bb9/zDqaqD7J1TtPTyHav+Tpy/FCkGc7CF3SRGhooy5ABp6 4KIfrF8FaGNn5xe7MS8bap7AJ5rvHkyMSJgMlk7Mq/7enNbdsOAgLaZwXc5bkxuhEM0T /PI2/iXTWVaU7mRlCQpSEdrLu743xrAiLxOThhGagdV6dSeXBKo8f6eXUL8l86VJggFY mxUw== X-Gm-Message-State: AOAM5323RSBtQKJwG0f2FzoWLzRqb9cJXlIPewlV11dk2iEvlXGMGDkX c5j1nwuoyiVVvWGboinyApdgCMtC X-Google-Smtp-Source: ABdhPJxgEZW2OPVoQ3Eb3r+R5RABtTbjd05+Usw/10msLxsN5DGYjOsIuOsm8HzyIqKfMf55XQt+2Q== X-Received: by 2002:ac8:468d:: with SMTP id g13mr13650714qto.47.1590857109048; Sat, 30 May 2020 09:45:09 -0700 (PDT) Received: from localhost.localdomain ([181.23.72.208]) by smtp.gmail.com with ESMTPSA id 70sm9153463qkk.10.2020.05.30.09.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:45:08 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 13:44:26 -0300 Message-Id: <20200530164426.474-1-jamrial@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/internal: move packet related functions to their own header X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- I included the new header directly in internal.h because the alternative was including it in a hundred or so files that call ff_alloc_packet2(). If that's nonetheless prefered, i can go ahead with it. libavcodec/internal.h | 35 +------------------- libavcodec/packet_internal.h | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 libavcodec/packet_internal.h diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 0e3415d69b..fa5052723b 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -32,6 +32,7 @@ #include "libavutil/pixfmt.h" #include "avcodec.h" #include "config.h" +#include "packet_internal.h" /** * The codec does not modify any global variables in the init function, @@ -222,36 +223,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); */ #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) -/** - * Check AVPacket size and/or allocate data. - * - * Encoders supporting AVCodec.encode2() can use this as a convenience to - * ensure the output packet data is large enough, whether provided by the user - * or allocated in this function. - * - * @param avctx the AVCodecContext of the encoder - * @param avpkt the AVPacket - * If avpkt->data is already set, avpkt->size is checked - * to ensure it is large enough. - * If avpkt->data is NULL, a new buffer is allocated. - * avpkt->size is set to the specified size. - * All other AVPacket fields will be reset with av_init_packet(). - * @param size the minimum required packet size - * @param min_size This is a hint to the allocation algorithm, which indicates - * to what minimal size the caller might later shrink the packet - * to. Encoders often allocate packets which are larger than the - * amount of data that is written into them as the exact amount is - * not known at the time of allocation. min_size represents the - * size a packet might be shrunk to by the caller. Can be set to - * 0. setting this roughly correctly allows the allocation code - * to choose between several allocation strategies to improve - * speed slightly. - * @return non negative on success, negative error code on failure - */ -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size); - -attribute_deprecated int ff_alloc_packet(AVPacket *avpkt, int size); - /** * Rescale from sample rate to AVCodecContext.time_base. */ @@ -360,10 +331,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame); */ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx); -int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); - -int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp); - /** * Check AVFrame for A53 side data and allocate and fill SEI message with A53 info * diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h new file mode 100644 index 0000000000..6d48f7f528 --- /dev/null +++ b/libavcodec/packet_internal.h @@ -0,0 +1,63 @@ +/* + * 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 AVCODEC_PACKET_INTERNAL_H +#define AVCODEC_PACKET_INTERNAL_H + +#include + +#include "libavutil/attributes.h" + +#include "avcodec.h" +#include "packet.h" + +/** + * Check AVPacket size and/or allocate data. + * + * Encoders supporting AVCodec.encode2() can use this as a convenience to + * ensure the output packet data is large enough, whether provided by the user + * or allocated in this function. + * + * @param avctx the AVCodecContext of the encoder + * @param avpkt the AVPacket + * If avpkt->data is already set, avpkt->size is checked + * to ensure it is large enough. + * If avpkt->data is NULL, a new buffer is allocated. + * avpkt->size is set to the specified size. + * All other AVPacket fields will be reset with av_init_packet(). + * @param size the minimum required packet size + * @param min_size This is a hint to the allocation algorithm, which indicates + * to what minimal size the caller might later shrink the packet + * to. Encoders often allocate packets which are larger than the + * amount of data that is written into them as the exact amount is + * not known at the time of allocation. min_size represents the + * size a packet might be shrunk to by the caller. Can be set to + * 0. setting this roughly correctly allows the allocation code + * to choose between several allocation strategies to improve + * speed slightly. + * @return non negative on success, negative error code on failure + */ +int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size); + +attribute_deprecated int ff_alloc_packet(AVPacket *avpkt, int size); + +int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); + +int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp); + +#endif // AVCODEC_PACKET_INTERNAL_H