2008-12-08 23:21:38 +02: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 17:45:34 +03:00
|
|
|
* @file
|
2008-12-08 23:21:38 +02:00
|
|
|
* common internal api header.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVCODEC_INTERNAL_H
|
|
|
|
#define AVCODEC_INTERNAL_H
|
|
|
|
|
2009-02-24 21:04:43 +02:00
|
|
|
#include <stdint.h>
|
2011-11-15 23:34:50 +03:00
|
|
|
|
2012-11-21 23:34:46 +03:00
|
|
|
#include "libavutil/buffer.h"
|
2013-12-11 05:03:29 +03:00
|
|
|
#include "libavutil/channel_layout.h"
|
2012-02-07 23:37:45 +03:00
|
|
|
#include "libavutil/mathematics.h"
|
2011-11-15 23:34:50 +03:00
|
|
|
#include "libavutil/pixfmt.h"
|
2009-02-24 21:04:43 +02:00
|
|
|
#include "avcodec.h"
|
2013-03-25 15:11:41 +03:00
|
|
|
#include "config.h"
|
2009-02-24 21:04:43 +02:00
|
|
|
|
2015-03-11 22:43:58 +02:00
|
|
|
/**
|
2015-04-02 14:17:01 +02:00
|
|
|
* The codec does not modify any global variables in the init function,
|
|
|
|
* allowing to call the init function without locking any global mutexes.
|
2015-03-11 22:43:58 +02:00
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_INIT_THREADSAFE (1 << 0)
|
|
|
|
/**
|
2015-04-02 14:17:01 +02:00
|
|
|
* The codec allows calling the close function for deallocation even if
|
|
|
|
* the init function returned a failure. Without this capability flag, a
|
|
|
|
* codec does such cleanup internally when returning failures from the
|
|
|
|
* init function and does not expect the close function to be called at
|
|
|
|
* all.
|
2015-03-11 22:43:58 +02:00
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
|
2015-09-11 18:36:56 +02:00
|
|
|
/**
|
|
|
|
* Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set
|
2017-05-02 01:37:41 +02:00
|
|
|
* AVFrame.pkt_dts manually. If the flag is set, decode.c won't overwrite
|
|
|
|
* this field. If it's unset, decode.c tries to guess the pkt_dts field
|
2015-09-11 18:36:56 +02:00
|
|
|
* from the input AVPacket.
|
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2)
|
2015-11-02 11:27:58 +02:00
|
|
|
/**
|
|
|
|
* The decoder extracts and fills its parameters even if the frame is
|
2015-11-16 20:36:57 +02:00
|
|
|
* skipped due to the skip_frame setting.
|
2015-11-02 11:27:58 +02:00
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3)
|
2016-12-18 17:42:24 +02:00
|
|
|
/**
|
|
|
|
* The decoder sets the cropping fields in the output frames manually.
|
|
|
|
* If this cap is set, the generic code will initialize output frame
|
|
|
|
* dimensions to coded rather than display values.
|
|
|
|
*/
|
2017-05-08 18:11:17 +02:00
|
|
|
#define FF_CODEC_CAP_EXPORTS_CROPPING (1 << 4)
|
2017-09-07 22:48:17 +02:00
|
|
|
/**
|
|
|
|
* Codec initializes slice-based threading with a main function
|
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
|
2017-01-09 19:01:02 +02:00
|
|
|
/*
|
|
|
|
* The codec supports frame threading and has inter-frame dependencies, so it
|
|
|
|
* uses ff_thread_report/await_progress().
|
|
|
|
*/
|
|
|
|
#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)
|
2015-03-11 22:43:58 +02:00
|
|
|
|
2019-12-29 22:22:05 +02:00
|
|
|
/**
|
|
|
|
* AVCodec.codec_tags termination value
|
|
|
|
*/
|
|
|
|
#define FF_CODEC_TAGS_END -1
|
|
|
|
|
|
|
|
|
2015-03-16 10:57:36 +02:00
|
|
|
#ifdef TRACE
|
|
|
|
# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
|
|
|
|
#else
|
2015-12-18 15:50:54 +02:00
|
|
|
# define ff_tlog(ctx, ...) do { } while(0)
|
2015-03-16 10:57:36 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-07-02 13:14:22 +02:00
|
|
|
#define FF_DEFAULT_QUANT_BIAS 999999
|
|
|
|
|
2017-09-01 19:44:27 +02:00
|
|
|
#define FF_QSCALE_TYPE_MPEG1 0
|
|
|
|
#define FF_QSCALE_TYPE_MPEG2 1
|
|
|
|
#define FF_QSCALE_TYPE_H264 2
|
|
|
|
#define FF_QSCALE_TYPE_VP56 3
|
|
|
|
|
2019-08-20 16:52:08 +02:00
|
|
|
#define FF_SANE_NB_CHANNELS 512U
|
2012-10-22 20:40:10 +03:00
|
|
|
|
2014-11-18 04:42:40 +02:00
|
|
|
#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1)
|
2014-11-17 01:22:27 +02:00
|
|
|
|
2017-11-06 16:43:39 +02:00
|
|
|
#if HAVE_SIMD_ALIGN_64
|
|
|
|
# define STRIDE_ALIGN 64 /* AVX-512 */
|
|
|
|
#elif HAVE_SIMD_ALIGN_32
|
2014-05-19 03:59:57 +03:00
|
|
|
# define STRIDE_ALIGN 32
|
2014-07-22 23:32:40 +03:00
|
|
|
#elif HAVE_SIMD_ALIGN_16
|
2014-03-15 16:47:04 +03:00
|
|
|
# define STRIDE_ALIGN 16
|
|
|
|
#else
|
|
|
|
# define STRIDE_ALIGN 8
|
|
|
|
#endif
|
|
|
|
|
decode: restructure the core decoding code
Currently, the new decoding API is pretty much just a wrapper around the
old deprecated one. This is problematic, since it interferes with making
full use of the flexibility added by the new API. The old API should
also be removed at some future point.
Reorganize the code so that the new send_packet/receive_frame functions
call the actual decoding directly and change the old deprecated
avcodec_decode_* functions into wrappers around the new API.
The new internal API for decoders is now changing as well. Before this
commit, it mirrors the public API, so the decoders need to implement
send_packet() and receive_frame() callbacks. This turns out to require
awkward constructs in both the decoders and the generic code. After this
commit, the decoders only implement the receive_frame() callback and
call a new internal function, ff_decode_get_packet() to obtain input
data, in the same manner to how the bitstream filters now work.
avcodec will now always make a reference to the input packet, which means
that non-refcounted input packets will be copied. Keeping the previous
behaviour, where this copy could sometimes be avoided, would make the
code significantly more complex and fragile for only dubious gains,
since packets are typically small and everyone who cares about
performance should use refcounted packets anyway.
2016-10-26 13:59:15 +02:00
|
|
|
typedef struct DecodeSimpleContext {
|
|
|
|
AVPacket *in_pkt;
|
|
|
|
} DecodeSimpleContext;
|
|
|
|
|
2020-06-09 23:31:32 +02:00
|
|
|
typedef struct EncodeSimpleContext {
|
|
|
|
AVFrame *in_frame;
|
|
|
|
} EncodeSimpleContext;
|
|
|
|
|
2012-11-21 23:34:46 +03:00
|
|
|
typedef struct AVCodecInternal {
|
2011-11-15 23:34:50 +03:00
|
|
|
/**
|
|
|
|
* Whether the parent AVCodecContext is a copy of the context which had
|
|
|
|
* init() called on it.
|
|
|
|
* This is used by multithreading - shared tables and picture pointers
|
|
|
|
* should be freed from the original context only.
|
|
|
|
*/
|
|
|
|
int is_copy;
|
2011-12-18 21:20:15 +03:00
|
|
|
|
2012-05-07 14:55:03 +03:00
|
|
|
/**
|
|
|
|
* An audio frame with less than required samples has been submitted and
|
|
|
|
* padded with silence. Reject all subsequent frames.
|
|
|
|
*/
|
|
|
|
int last_audio_frame;
|
2012-05-10 03:14:44 +03:00
|
|
|
|
2013-11-29 22:49:18 +03:00
|
|
|
AVFrame *to_free;
|
2012-11-21 23:34:46 +03:00
|
|
|
|
2017-01-17 17:28:30 +02:00
|
|
|
AVBufferRef *pool;
|
2012-12-05 18:25:03 +03:00
|
|
|
|
2013-10-27 15:00:37 +03:00
|
|
|
void *thread_ctx;
|
2013-11-04 13:14:38 +03:00
|
|
|
|
decode: restructure the core decoding code
Currently, the new decoding API is pretty much just a wrapper around the
old deprecated one. This is problematic, since it interferes with making
full use of the flexibility added by the new API. The old API should
also be removed at some future point.
Reorganize the code so that the new send_packet/receive_frame functions
call the actual decoding directly and change the old deprecated
avcodec_decode_* functions into wrappers around the new API.
The new internal API for decoders is now changing as well. Before this
commit, it mirrors the public API, so the decoders need to implement
send_packet() and receive_frame() callbacks. This turns out to require
awkward constructs in both the decoders and the generic code. After this
commit, the decoders only implement the receive_frame() callback and
call a new internal function, ff_decode_get_packet() to obtain input
data, in the same manner to how the bitstream filters now work.
avcodec will now always make a reference to the input packet, which means
that non-refcounted input packets will be copied. Keeping the previous
behaviour, where this copy could sometimes be avoided, would make the
code significantly more complex and fragile for only dubious gains,
since packets are typically small and everyone who cares about
performance should use refcounted packets anyway.
2016-10-26 13:59:15 +02:00
|
|
|
DecodeSimpleContext ds;
|
2020-04-25 23:48:21 +02:00
|
|
|
AVBSFContext *bsf;
|
decode: restructure the core decoding code
Currently, the new decoding API is pretty much just a wrapper around the
old deprecated one. This is problematic, since it interferes with making
full use of the flexibility added by the new API. The old API should
also be removed at some future point.
Reorganize the code so that the new send_packet/receive_frame functions
call the actual decoding directly and change the old deprecated
avcodec_decode_* functions into wrappers around the new API.
The new internal API for decoders is now changing as well. Before this
commit, it mirrors the public API, so the decoders need to implement
send_packet() and receive_frame() callbacks. This turns out to require
awkward constructs in both the decoders and the generic code. After this
commit, the decoders only implement the receive_frame() callback and
call a new internal function, ff_decode_get_packet() to obtain input
data, in the same manner to how the bitstream filters now work.
avcodec will now always make a reference to the input packet, which means
that non-refcounted input packets will be copied. Keeping the previous
behaviour, where this copy could sometimes be avoided, would make the
code significantly more complex and fragile for only dubious gains,
since packets are typically small and everyone who cares about
performance should use refcounted packets anyway.
2016-10-26 13:59:15 +02:00
|
|
|
|
2013-10-27 15:12:53 +03:00
|
|
|
/**
|
2016-10-26 13:41:12 +02:00
|
|
|
* Properties (timestamps+side data) extracted from the last packet passed
|
|
|
|
* for decoding.
|
2013-10-27 15:12:53 +03:00
|
|
|
*/
|
2016-10-26 13:41:12 +02:00
|
|
|
AVPacket *last_pkt_props;
|
2013-11-04 13:41:55 +03:00
|
|
|
|
2012-03-22 20:07:57 +03:00
|
|
|
/**
|
|
|
|
* temporary buffer used for encoders to store their bitstream
|
|
|
|
*/
|
|
|
|
uint8_t *byte_buffer;
|
|
|
|
unsigned int byte_buffer_size;
|
2012-06-14 22:19:02 +03:00
|
|
|
|
|
|
|
void *frame_thread_encoder;
|
2012-07-04 23:03:13 +03:00
|
|
|
|
2020-06-09 23:31:32 +02:00
|
|
|
EncodeSimpleContext es;
|
|
|
|
|
2012-07-04 23:03:13 +03:00
|
|
|
/**
|
|
|
|
* Number of audio samples to skip at the start of the next decoded frame
|
|
|
|
*/
|
|
|
|
int skip_samples;
|
2014-05-12 01:21:44 +03:00
|
|
|
|
2014-03-06 20:37:42 +03:00
|
|
|
/**
|
|
|
|
* hwaccel-specific private data
|
|
|
|
*/
|
|
|
|
void *hwaccel_priv_data;
|
2016-03-22 20:09:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* checks API usage: after codec draining, flush is required to resume operation
|
|
|
|
*/
|
|
|
|
int draining;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* buffers for using new encode/decode API through legacy API
|
|
|
|
*/
|
|
|
|
AVPacket *buffer_pkt;
|
|
|
|
AVFrame *buffer_frame;
|
|
|
|
int draining_done;
|
decode: restructure the core decoding code
Currently, the new decoding API is pretty much just a wrapper around the
old deprecated one. This is problematic, since it interferes with making
full use of the flexibility added by the new API. The old API should
also be removed at some future point.
Reorganize the code so that the new send_packet/receive_frame functions
call the actual decoding directly and change the old deprecated
avcodec_decode_* functions into wrappers around the new API.
The new internal API for decoders is now changing as well. Before this
commit, it mirrors the public API, so the decoders need to implement
send_packet() and receive_frame() callbacks. This turns out to require
awkward constructs in both the decoders and the generic code. After this
commit, the decoders only implement the receive_frame() callback and
call a new internal function, ff_decode_get_packet() to obtain input
data, in the same manner to how the bitstream filters now work.
avcodec will now always make a reference to the input packet, which means
that non-refcounted input packets will be copied. Keeping the previous
behaviour, where this copy could sometimes be avoided, would make the
code significantly more complex and fragile for only dubious gains,
since packets are typically small and everyone who cares about
performance should use refcounted packets anyway.
2016-10-26 13:59:15 +02:00
|
|
|
int compat_decode_warned;
|
|
|
|
/* this variable is set by the decoder internals to signal to the old
|
|
|
|
* API compat wrappers the amount of data consumed from the last packet */
|
|
|
|
size_t compat_decode_consumed;
|
|
|
|
/* when a partial packet has been consumed, this stores the remaining size
|
|
|
|
* of the packet (that should be submitted in the next decode call */
|
|
|
|
size_t compat_decode_partial_size;
|
|
|
|
AVFrame *compat_decode_frame;
|
2020-06-09 23:35:00 +02:00
|
|
|
AVPacket *compat_encode_packet;
|
2017-04-23 01:08:42 +02:00
|
|
|
|
2016-10-01 17:22:02 +02:00
|
|
|
int showed_multi_packet_warning;
|
2017-03-08 13:36:05 +02:00
|
|
|
|
|
|
|
int skip_samples_multiplier;
|
2017-04-28 12:19:13 +02:00
|
|
|
|
|
|
|
/* to prevent infinite loop on errors when draining */
|
|
|
|
int nb_draining_errors;
|
2019-04-14 18:42:25 +02:00
|
|
|
|
|
|
|
/* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */
|
|
|
|
int changed_frames_dropped;
|
|
|
|
int initial_format;
|
|
|
|
int initial_width, initial_height;
|
|
|
|
int initial_sample_rate;
|
|
|
|
int initial_channels;
|
|
|
|
uint64_t initial_channel_layout;
|
2011-11-15 23:34:50 +03:00
|
|
|
} AVCodecInternal;
|
|
|
|
|
2011-06-08 09:27:53 +03:00
|
|
|
struct AVCodecDefault {
|
|
|
|
const uint8_t *key;
|
|
|
|
const uint8_t *value;
|
|
|
|
};
|
|
|
|
|
2014-03-24 16:26:17 +03:00
|
|
|
extern const uint8_t ff_log2_run[41];
|
|
|
|
|
2010-01-10 06:06:34 +02: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 06:04:51 +02:00
|
|
|
int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
|
|
|
|
|
2011-10-17 11:12:51 +03:00
|
|
|
unsigned int avpriv_toupper4(unsigned int x);
|
2010-05-18 22:16:40 +03:00
|
|
|
|
2015-10-14 01:42:10 +02:00
|
|
|
void ff_color_frame(AVFrame *frame, const int color[4]);
|
2013-02-16 14:13:27 +03:00
|
|
|
|
2012-01-12 22:12:24 +03:00
|
|
|
/**
|
|
|
|
* Maximum size in bytes of extradata.
|
|
|
|
* This value was chosen such that every bit of the buffer is
|
|
|
|
* addressable by a 32-bit signed integer as used by get_bits.
|
|
|
|
*/
|
2015-06-29 23:48:34 +02:00
|
|
|
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
|
2012-01-12 22:12:24 +03:00
|
|
|
|
2011-12-18 21:20:15 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2012-03-22 05:55:21 +03:00
|
|
|
* @param avctx the AVCodecContext of the encoder
|
2011-12-18 21:20:15 +03:00
|
|
|
* @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.
|
2012-02-02 00:23:19 +03:00
|
|
|
* avpkt->size is set to the specified size.
|
2011-12-18 21:20:15 +03:00
|
|
|
* All other AVPacket fields will be reset with av_init_packet().
|
|
|
|
* @param size the minimum required packet size
|
2015-08-03 18:33:03 +02:00
|
|
|
* @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
|
2015-07-27 19:36:16 +02:00
|
|
|
* speed slightly.
|
2015-03-31 16:14:22 +02:00
|
|
|
* @return non negative on success, negative error code on failure
|
2011-12-18 21:20:15 +03:00
|
|
|
*/
|
2015-07-27 19:36:16 +02:00
|
|
|
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size);
|
2012-03-22 05:55:21 +03:00
|
|
|
|
2012-02-07 23:37:45 +03:00
|
|
|
/**
|
|
|
|
* Rescale from sample rate to AVCodecContext.time_base.
|
|
|
|
*/
|
|
|
|
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx,
|
|
|
|
int64_t samples)
|
|
|
|
{
|
2012-04-11 21:23:27 +03:00
|
|
|
if(samples == AV_NOPTS_VALUE)
|
|
|
|
return AV_NOPTS_VALUE;
|
2012-02-07 23:37:45 +03:00
|
|
|
return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate },
|
|
|
|
avctx->time_base);
|
|
|
|
}
|
|
|
|
|
2015-12-16 06:44:54 +02:00
|
|
|
/**
|
|
|
|
* 2^(x) for integer x
|
|
|
|
* @return correctly rounded float
|
|
|
|
*/
|
|
|
|
static av_always_inline float ff_exp2fi(int x) {
|
|
|
|
/* Normal range */
|
|
|
|
if (-126 <= x && x <= 128)
|
2016-11-15 21:09:52 +02:00
|
|
|
return av_int2float((x+127) << 23);
|
2015-12-16 06:44:54 +02:00
|
|
|
/* Too large */
|
|
|
|
else if (x > 128)
|
|
|
|
return INFINITY;
|
|
|
|
/* Subnormal numbers */
|
|
|
|
else if (x > -150)
|
|
|
|
return av_int2float(1 << (x+149));
|
|
|
|
/* Negligibly small */
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-10 15:22:56 +03:00
|
|
|
/**
|
|
|
|
* Get a buffer for a frame. This is a wrapper around
|
|
|
|
* AVCodecContext.get_buffer() and should be used instead calling get_buffer()
|
|
|
|
* directly.
|
|
|
|
*/
|
2012-11-21 23:34:46 +03:00
|
|
|
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
|
|
|
|
|
2019-08-30 16:37:25 +02:00
|
|
|
#define FF_REGET_BUFFER_FLAG_READONLY 1 ///< the returned buffer does not need to be writable
|
2012-11-21 23:34:46 +03:00
|
|
|
/**
|
2019-08-30 16:37:25 +02:00
|
|
|
* Identical in function to ff_get_buffer(), except it reuses the existing buffer
|
|
|
|
* if available.
|
2012-11-21 23:34:46 +03:00
|
|
|
*/
|
2019-08-30 16:37:25 +02:00
|
|
|
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
|
2012-11-10 15:22:56 +03:00
|
|
|
|
2012-03-24 02:20:05 +03:00
|
|
|
int ff_thread_can_start_frame(AVCodecContext *avctx);
|
|
|
|
|
2012-07-03 00:16:59 +03:00
|
|
|
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
|
|
|
|
|
2012-10-19 04:12:56 +03:00
|
|
|
/**
|
|
|
|
* Call avcodec_open2 recursively by decrementing counter, unlocking mutex,
|
|
|
|
* calling the function and then restoring again. Assumes the mutex is
|
|
|
|
* already locked
|
|
|
|
*/
|
|
|
|
int ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
|
|
|
|
|
2012-12-30 00:09:59 +03:00
|
|
|
/**
|
|
|
|
* Finalize buf into extradata and set its size appropriately.
|
|
|
|
*/
|
2012-12-31 00:54:53 +03:00
|
|
|
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf);
|
2012-12-30 00:09:59 +03:00
|
|
|
|
2013-03-26 15:32:12 +03:00
|
|
|
const uint8_t *avpriv_find_start_code(const uint8_t *p,
|
2013-03-25 15:11:41 +03:00
|
|
|
const uint8_t *end,
|
2013-03-26 15:32:12 +03:00
|
|
|
uint32_t *state);
|
2013-03-25 15:11:41 +03:00
|
|
|
|
2016-04-20 19:19:25 +02:00
|
|
|
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec);
|
|
|
|
|
2013-10-27 11:24:22 +03:00
|
|
|
/**
|
|
|
|
* Check that the provided frame dimensions are valid and set them on the codec
|
|
|
|
* context.
|
|
|
|
*/
|
|
|
|
int ff_set_dimensions(AVCodecContext *s, int width, int height);
|
|
|
|
|
2014-04-28 23:08:33 +03:00
|
|
|
/**
|
|
|
|
* Check that the provided sample aspect ratio is valid and set it on the codec
|
|
|
|
* context.
|
|
|
|
*/
|
|
|
|
int ff_set_sar(AVCodecContext *avctx, AVRational sar);
|
|
|
|
|
2013-12-11 05:03:29 +03:00
|
|
|
/**
|
|
|
|
* Add or update AV_FRAME_DATA_MATRIXENCODING side data.
|
|
|
|
*/
|
|
|
|
int ff_side_data_update_matrix_encoding(AVFrame *frame,
|
|
|
|
enum AVMatrixEncoding matrix_encoding);
|
|
|
|
|
2014-03-06 19:48:18 +03:00
|
|
|
/**
|
|
|
|
* Select the (possibly hardware accelerated) pixel format.
|
|
|
|
* This is a wrapper around AVCodecContext.get_format() and should be used
|
|
|
|
* instead of calling get_format() directly.
|
2017-10-26 01:18:43 +02:00
|
|
|
*
|
|
|
|
* The list of pixel formats must contain at least one valid entry, and is
|
|
|
|
* terminated with AV_PIX_FMT_NONE. If it is possible to decode to software,
|
|
|
|
* the last entry in the list must be the most accurate software format.
|
|
|
|
* If it is not possible to decode to software, AVCodecContext.sw_pix_fmt
|
|
|
|
* must be set before calling this function.
|
2014-03-06 19:48:18 +03:00
|
|
|
*/
|
|
|
|
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
|
|
|
|
|
2014-02-19 20:52:26 +03:00
|
|
|
/**
|
|
|
|
* Set various frame properties from the codec context / packet data.
|
|
|
|
*/
|
|
|
|
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
|
2014-03-10 15:37:12 +03:00
|
|
|
|
2015-10-03 15:19:10 +02:00
|
|
|
/**
|
|
|
|
* Add a CPB properties side data to an encoding context.
|
|
|
|
*/
|
|
|
|
AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx);
|
|
|
|
|
2016-06-04 20:11:52 +02:00
|
|
|
/**
|
|
|
|
* Check AVFrame for A53 side data and allocate and fill SEI message with A53 info
|
|
|
|
*
|
|
|
|
* @param frame Raw frame to get A53 side data from
|
|
|
|
* @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 A53 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
|
|
|
|
*/
|
|
|
|
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
|
|
|
|
void **data, size_t *sei_size);
|
2020-06-18 05:58:50 +02: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
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
|
|
|
|
void **data, size_t *sei_size);
|
2016-06-04 20:11:52 +02:00
|
|
|
|
2017-03-06 09:53:28 +02: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);
|
|
|
|
|
2018-12-02 22:36:24 +02:00
|
|
|
/**
|
|
|
|
* Check if a value is in the list. If not, return the default value
|
|
|
|
*
|
|
|
|
* @param ctx Context for the log msg
|
|
|
|
* @param val_name Name of the checked value, for log msg
|
|
|
|
* @param array_valid_values Array of valid int, ended with INT_MAX
|
|
|
|
* @param default_value Value return if checked value is not in the array
|
|
|
|
* @return Value or default_value.
|
|
|
|
*/
|
|
|
|
int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
|
|
|
|
const int * array_valid_values, int default_value);
|
|
|
|
|
2020-02-03 21:42:30 +02:00
|
|
|
void ff_dvdsub_parse_palette(uint32_t *palette, const char *p);
|
|
|
|
|
2017-09-14 07:33:05 +02:00
|
|
|
#if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec)
|
2017-08-24 21:07:04 +02:00
|
|
|
# define av_export_avcodec __declspec(dllimport)
|
|
|
|
#else
|
|
|
|
# define av_export_avcodec
|
|
|
|
#endif
|
|
|
|
|
2008-12-08 23:21:38 +02:00
|
|
|
#endif /* AVCODEC_INTERNAL_H */
|