2008-12-08 21:21:38 +00:00
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2010-04-20 14:45:34 +00:00
|
|
|
* @file
|
2008-12-08 21:21:38 +00:00
|
|
|
* common internal api header.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef AVCODEC_INTERNAL_H
|
|
|
|
|
#define AVCODEC_INTERNAL_H
|
|
|
|
|
|
2009-02-24 19:04:43 +00:00
|
|
|
#include <stdint.h>
|
2011-11-15 15:34:50 -05:00
|
|
|
|
2013-12-11 02:03:29 +00:00
|
|
|
#include "libavutil/channel_layout.h"
|
2009-02-24 19:04:43 +00:00
|
|
|
#include "avcodec.h"
|
2013-03-25 14:11:41 +02:00
|
|
|
#include "config.h"
|
2009-02-24 19:04:43 +00:00
|
|
|
|
2022-06-28 15:13:04 +02:00
|
|
|
#if CONFIG_LCMS2
|
|
|
|
|
# include "fflcms2.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-08-20 16:52:08 +02:00
|
|
|
#define FF_SANE_NB_CHANNELS 512U
|
2012-10-22 13:40:10 -04:00
|
|
|
|
2017-11-06 15:43:39 +01:00
|
|
|
#if HAVE_SIMD_ALIGN_64
|
|
|
|
|
# define STRIDE_ALIGN 64 /* AVX-512 */
|
|
|
|
|
#elif HAVE_SIMD_ALIGN_32
|
2014-05-18 21:59:57 -03:00
|
|
|
# define STRIDE_ALIGN 32
|
2014-07-22 22:32:40 +02:00
|
|
|
#elif HAVE_SIMD_ALIGN_16
|
2014-03-15 14:47:04 +01:00
|
|
|
# define STRIDE_ALIGN 16
|
|
|
|
|
#else
|
|
|
|
|
# define STRIDE_ALIGN 8
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-15 15:34:50 -05:00
|
|
|
typedef struct AVCodecInternal {
|
|
|
|
|
/**
|
2021-09-24 18:06:28 +02:00
|
|
|
* When using frame-threaded decoding, this field is set for the first
|
|
|
|
|
* worker thread (e.g. to decode extradata just once).
|
2011-11-15 15:34:50 -05:00
|
|
|
*/
|
|
|
|
|
int is_copy;
|
2011-12-18 13:20:15 -05:00
|
|
|
|
2017-01-24 15:00:22 +01:00
|
|
|
/**
|
|
|
|
|
* This field is set to 1 when frame threading is being used and the parent
|
|
|
|
|
* AVCodecContext of this AVCodecInternal is a worker-thread context (i.e.
|
|
|
|
|
* one of those actually doing the decoding), 0 otherwise.
|
|
|
|
|
*/
|
|
|
|
|
int is_frame_mt;
|
|
|
|
|
|
2022-09-15 19:20:11 +02:00
|
|
|
/**
|
|
|
|
|
* Audio encoders can set this flag during init to indicate that they
|
|
|
|
|
* want the small last frame to be padded to a multiple of pad_samples.
|
|
|
|
|
*/
|
|
|
|
|
int pad_samples;
|
|
|
|
|
|
2022-08-04 15:57:41 +02:00
|
|
|
struct FramePool *pool;
|
2012-12-05 16:25:03 +01:00
|
|
|
|
2024-10-15 22:37:56 +02:00
|
|
|
struct AVRefStructPool *progress_frame_pool;
|
2022-08-12 02:17:39 +02:00
|
|
|
|
2013-10-27 13:00:37 +01:00
|
|
|
void *thread_ctx;
|
2013-11-04 11:14:38 +01:00
|
|
|
|
2021-09-23 22:34:39 +02:00
|
|
|
/**
|
|
|
|
|
* This packet is used to hold the packet given to decoders
|
|
|
|
|
* implementing the .decode API; it is unused by the generic
|
|
|
|
|
* code for decoders implementing the .receive_frame API and
|
|
|
|
|
* may be freely used (but not freed) by them with the caveat
|
|
|
|
|
* that the packet will be unreferenced generically in
|
|
|
|
|
* avcodec_flush_buffers().
|
|
|
|
|
*/
|
|
|
|
|
AVPacket *in_pkt;
|
2022-05-09 22:30:11 +02:00
|
|
|
struct AVBSFContext *bsf;
|
2016-10-26 13:59:15 +02:00
|
|
|
|
2013-10-27 13:12:53 +01:00
|
|
|
/**
|
2016-10-26 13:41:12 +02:00
|
|
|
* Properties (timestamps+side data) extracted from the last packet passed
|
|
|
|
|
* for decoding.
|
2013-10-27 13:12:53 +01:00
|
|
|
*/
|
2016-10-26 13:41:12 +02:00
|
|
|
AVPacket *last_pkt_props;
|
2013-11-04 11:41:55 +01:00
|
|
|
|
2012-03-22 18:07:57 +01:00
|
|
|
/**
|
|
|
|
|
* temporary buffer used for encoders to store their bitstream
|
|
|
|
|
*/
|
|
|
|
|
uint8_t *byte_buffer;
|
|
|
|
|
unsigned int byte_buffer_size;
|
2012-06-14 21:19:02 +02:00
|
|
|
|
|
|
|
|
void *frame_thread_encoder;
|
2012-07-04 22:03:13 +02:00
|
|
|
|
2022-04-11 10:37:24 +02:00
|
|
|
/**
|
|
|
|
|
* The input frame is stored here for encoders implementing the simple
|
|
|
|
|
* encode API.
|
|
|
|
|
*
|
|
|
|
|
* Not allocated in other cases.
|
|
|
|
|
*/
|
|
|
|
|
AVFrame *in_frame;
|
2020-06-09 18:31:32 -03:00
|
|
|
|
2022-07-16 16:36:23 +02:00
|
|
|
/**
|
|
|
|
|
* When the AV_CODEC_FLAG_RECON_FRAME flag is used. the encoder should store
|
|
|
|
|
* here the reconstructed frame corresponding to the last returned packet.
|
|
|
|
|
*
|
|
|
|
|
* Not allocated in other cases.
|
|
|
|
|
*/
|
|
|
|
|
AVFrame *recon_frame;
|
|
|
|
|
|
2021-04-18 07:01:22 +02:00
|
|
|
/**
|
2022-03-16 21:09:54 +01:00
|
|
|
* If this is set, then FFCodec->close (if existing) needs to be called
|
2021-04-18 07:01:22 +02:00
|
|
|
* for the parent AVCodecContext.
|
|
|
|
|
*/
|
|
|
|
|
int needs_close;
|
|
|
|
|
|
2012-07-04 22:03:13 +02:00
|
|
|
/**
|
|
|
|
|
* Number of audio samples to skip at the start of the next decoded frame
|
|
|
|
|
*/
|
|
|
|
|
int skip_samples;
|
2014-05-12 00:21:44 +02:00
|
|
|
|
2014-03-06 18:37:42 +01:00
|
|
|
/**
|
|
|
|
|
* hwaccel-specific private data
|
|
|
|
|
*/
|
|
|
|
|
void *hwaccel_priv_data;
|
2016-03-22 19:09:53 +01:00
|
|
|
|
|
|
|
|
/**
|
2024-04-03 12:32:51 +02:00
|
|
|
* decoding: AVERROR_EOF has been returned from ff_decode_get_packet(); must
|
|
|
|
|
* not be used by decoders that use the decode() callback, as they
|
|
|
|
|
* do not call ff_decode_get_packet() directly.
|
|
|
|
|
*
|
|
|
|
|
* encoding: a flush frame has been submitted to avcodec_send_frame().
|
2016-03-22 19:09:53 +01:00
|
|
|
*/
|
|
|
|
|
int draining;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-08-24 03:19:05 +02:00
|
|
|
* Temporary buffers for newly received or not yet output packets/frames.
|
2016-03-22 19:09:53 +01:00
|
|
|
*/
|
|
|
|
|
AVPacket *buffer_pkt;
|
|
|
|
|
AVFrame *buffer_frame;
|
|
|
|
|
int draining_done;
|
2021-01-25 12:03:44 +01:00
|
|
|
|
2022-06-28 15:13:04 +02:00
|
|
|
#if CONFIG_LCMS2
|
|
|
|
|
FFIccContext icc; /* used to read and write embedded ICC profiles */
|
|
|
|
|
#endif
|
2024-03-17 20:51:29 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set when the user has been warned about a failed allocation from
|
|
|
|
|
* a fixed frame pool.
|
|
|
|
|
*/
|
|
|
|
|
int warned_on_failed_allocation_from_fixed_pool;
|
2011-11-15 15:34:50 -05:00
|
|
|
} AVCodecInternal;
|
|
|
|
|
|
2010-01-10 04:06:34 +00:00
|
|
|
/**
|
|
|
|
|
* Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
|
|
|
|
|
* If there is no such matching pair then size is returned.
|
|
|
|
|
*/
|
2010-01-10 04:04:51 +00:00
|
|
|
int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
|
|
|
|
|
|
2021-12-13 19:55:39 +01:00
|
|
|
unsigned int ff_toupper4(unsigned int x);
|
2010-05-18 19:16:40 +00:00
|
|
|
|
2012-07-02 23:16:59 +02:00
|
|
|
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
|
|
|
|
|
|
2016-04-20 19:19:25 +02:00
|
|
|
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec);
|
|
|
|
|
|
2020-06-18 11:58:50 +08:00
|
|
|
/**
|
|
|
|
|
* Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info
|
|
|
|
|
*
|
|
|
|
|
* @param frame Raw frame to get S12M timecode side data from
|
2020-07-12 22:19:31 +08:00
|
|
|
* @param rate The frame rate
|
2020-06-18 11:58:50 +08:00
|
|
|
* @param prefix_len Number of bytes to allocate before SEI message
|
|
|
|
|
* @param data Pointer to a variable to store allocated memory
|
|
|
|
|
* Upon return the variable will hold NULL on error or if frame has no S12M timecode info.
|
|
|
|
|
* Otherwise it will point to prefix_len uninitialized bytes followed by
|
|
|
|
|
* *sei_size SEI message
|
|
|
|
|
* @param sei_size Pointer to a variable to store generated SEI message length
|
|
|
|
|
* @return Zero on success, negative error code on failure
|
|
|
|
|
*/
|
2020-07-12 22:19:31 +08:00
|
|
|
int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_len,
|
2020-06-18 11:58:50 +08:00
|
|
|
void **data, size_t *sei_size);
|
2016-06-04 21:11:52 +03:00
|
|
|
|
2017-03-06 08:53:28 +01:00
|
|
|
/**
|
|
|
|
|
* Get an estimated video bitrate based on frame size, frame rate and coded
|
|
|
|
|
* bits per pixel.
|
|
|
|
|
*/
|
|
|
|
|
int64_t ff_guess_coded_bitrate(AVCodecContext *avctx);
|
|
|
|
|
|
2008-12-08 21:21:38 +00:00
|
|
|
#endif /* AVCODEC_INTERNAL_H */
|