[FFmpeg-devel] [PATCH] avcodec/internal: move packet related functions to their own header
James Almer
jamrial at gmail.com
Sat May 30 19:44:26 EEST 2020
Signed-off-by: James Almer <jamrial at gmail.com>
---
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 <stdint.h>
+
+#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
--
2.26.2
More information about the ffmpeg-devel
mailing list