FFmpeg
|
#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/dict.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "decode.h"
#include "hwaccel.h"
#include "libavutil/opt.h"
#include "mpegvideo.h"
#include "thread.h"
#include "frame_thread_encoder.h"
#include "internal.h"
#include "raw.h"
#include "bytestream.h"
#include "version.h"
#include <stdlib.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <limits.h>
#include <float.h>
#include "libavutil/ffversion.h"
Go to the source code of this file.
Macros | |
#define | TAG_PRINT(x) |
#define | LICENSE_PREFIX "libavcodec license: " |
Functions | |
void | av_fast_padded_malloc (void *ptr, unsigned int *size, size_t min_size) |
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. More... | |
void | av_fast_padded_mallocz (void *ptr, unsigned int *size, size_t min_size) |
Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call. More... | |
int | av_codec_is_encoder (const AVCodec *codec) |
int | av_codec_is_decoder (const AVCodec *codec) |
int | ff_set_dimensions (AVCodecContext *s, int width, int height) |
Check that the provided frame dimensions are valid and set them on the codec context. More... | |
int | ff_set_sar (AVCodecContext *avctx, AVRational sar) |
Check that the provided sample aspect ratio is valid and set it on the codec context. More... | |
int | ff_side_data_update_matrix_encoding (AVFrame *frame, enum AVMatrixEncoding matrix_encoding) |
Add or update AV_FRAME_DATA_MATRIXENCODING side data. More... | |
void | avcodec_align_dimensions2 (AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]) |
Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you also ensure that all line sizes are a multiple of the respective linesize_align[i]. More... | |
void | avcodec_align_dimensions (AVCodecContext *s, int *width, int *height) |
Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you do not use any horizontal padding. More... | |
int | avcodec_enum_to_chroma_pos (int *xpos, int *ypos, enum AVChromaLocation pos) |
Converts AVChromaLocation to swscale x/y chroma position. More... | |
enum AVChromaLocation | avcodec_chroma_pos_to_enum (int xpos, int ypos) |
Converts swscale x/y chroma position to AVChromaLocation. More... | |
int | avcodec_fill_audio_frame (AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align) |
Fill AVFrame audio data and linesize pointers. More... | |
void | ff_color_frame (AVFrame *frame, const int c[4]) |
int | avcodec_default_execute (AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size) |
int | avcodec_default_execute2 (AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count) |
enum AVPixelFormat | avpriv_find_pix_fmt (const PixelFormatTag *tags, unsigned int fourcc) |
unsigned | av_codec_get_codec_properties (const AVCodecContext *codec) |
int | av_codec_get_max_lowres (const AVCodec *codec) |
int | avpriv_codec_get_cap_skip_frame_fill_param (const AVCodec *codec) |
static int64_t | get_bit_rate (AVCodecContext *ctx) |
static void | ff_lock_avcodec (AVCodecContext *log_ctx, const AVCodec *codec) |
static void | ff_unlock_avcodec (const AVCodec *codec) |
int attribute_align_arg | ff_codec_open2_recursive (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) |
Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and then restoring again. More... | |
int attribute_align_arg | avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) |
Initialize the AVCodecContext to use the given AVCodec. More... | |
void | avsubtitle_free (AVSubtitle *sub) |
Free all allocated data in the given subtitle struct. More... | |
av_cold int | avcodec_close (AVCodecContext *avctx) |
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself). More... | |
const char * | avcodec_get_name (enum AVCodecID id) |
Get the name of a codec. More... | |
size_t | av_get_codec_tag_string (char *buf, size_t buf_size, unsigned int codec_tag) |
Put a string representing the codec tag codec_tag in buf. More... | |
void | avcodec_string (char *buf, int buf_size, AVCodecContext *enc, int encode) |
const char * | av_get_profile_name (const AVCodec *codec, int profile) |
Return a name for the specified profile, if available. More... | |
const char * | avcodec_profile_name (enum AVCodecID codec_id, int profile) |
Return a name for the specified profile, if available. More... | |
unsigned | avcodec_version (void) |
Return the LIBAVCODEC_VERSION_INT constant. More... | |
const char * | avcodec_configuration (void) |
Return the libavcodec build-time configuration. More... | |
const char * | avcodec_license (void) |
Return the libavcodec license. More... | |
int | av_get_exact_bits_per_sample (enum AVCodecID codec_id) |
Return codec bits per sample. More... | |
enum AVCodecID | av_get_pcm_codec (enum AVSampleFormat fmt, int be) |
Return the PCM codec associated with a sample format. More... | |
int | av_get_bits_per_sample (enum AVCodecID codec_id) |
Return codec bits per sample. More... | |
static int | get_audio_frame_duration (enum AVCodecID id, int sr, int ch, int ba, uint32_t tag, int bits_per_coded_sample, int64_t bitrate, uint8_t *extradata, int frame_size, int frame_bytes) |
int | av_get_audio_frame_duration (AVCodecContext *avctx, int frame_bytes) |
Return audio frame duration. More... | |
int | av_get_audio_frame_duration2 (AVCodecParameters *par, int frame_bytes) |
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters instead of an AVCodecContext. More... | |
int | ff_thread_init (AVCodecContext *s) |
unsigned int | av_xiphlacing (unsigned char *s, unsigned int v) |
Encode extradata length to a buffer. More... | |
int | ff_match_2uint16 (const uint16_t(*tab)[2], int size, int a, int b) |
Return the index into tab at which {a,b} match elements {[0],[1]} of tab. More... | |
const AVCodecHWConfig * | avcodec_get_hw_config (const AVCodec *codec, int index) |
Retrieve supported hardware configurations for a codec. More... | |
AVHWAccel * | av_hwaccel_next (const AVHWAccel *hwaccel) |
If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL, returns the next registered hardware accelerator after hwaccel, or NULL if hwaccel is the last one. More... | |
void | av_register_hwaccel (AVHWAccel *hwaccel) |
Register the hardware accelerator hwaccel. More... | |
int | av_lockmgr_register (int(*cb)(void **mutex, enum AVLockOp op)) |
Register a user provided lock manager supporting the operations specified by AVLockOp. More... | |
unsigned int | avpriv_toupper4 (unsigned int x) |
int | ff_thread_ref_frame (ThreadFrame *dst, ThreadFrame *src) |
enum AVPixelFormat | ff_thread_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt) |
Wrapper around get_format() for frame-multithreaded codecs. More... | |
int | ff_thread_get_buffer (AVCodecContext *avctx, ThreadFrame *f, int flags) |
Wrapper around get_buffer() for frame-multithreaded codecs. More... | |
void | ff_thread_release_buffer (AVCodecContext *avctx, ThreadFrame *f) |
Wrapper around release_buffer() frame-for multithreaded codecs. More... | |
void | ff_thread_finish_setup (AVCodecContext *avctx) |
If the codec defines update_thread_context(), call this when they are ready for the next thread to start decoding the next frame. More... | |
void | ff_thread_report_progress (ThreadFrame *f, int progress, int field) |
Notify later decoding threads when part of their reference picture is ready. More... | |
void | ff_thread_await_progress (ThreadFrame *f, int progress, int field) |
Wait for earlier decoding threads to finish reference pictures. More... | |
int | ff_thread_can_start_frame (AVCodecContext *avctx) |
int | ff_alloc_entries (AVCodecContext *avctx, int count) |
void | ff_reset_entries (AVCodecContext *avctx) |
void | ff_thread_await_progress2 (AVCodecContext *avctx, int field, int thread, int shift) |
void | ff_thread_report_progress2 (AVCodecContext *avctx, int field, int thread, int n) |
int | avcodec_is_open (AVCodecContext *s) |
int | avpriv_bprint_to_extradata (AVCodecContext *avctx, struct AVBPrint *buf) |
Finalize buf into extradata and set its size appropriately. More... | |
const uint8_t * | avpriv_find_start_code (const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state) |
AVCPBProperties * | av_cpb_properties_alloc (size_t *size) |
Allocate a CPB properties structure and initialize its fields to default values. More... | |
AVCPBProperties * | ff_add_cpb_side_data (AVCodecContext *avctx) |
Add a CPB properties side data to an encoding context. More... | |
static void | codec_parameters_reset (AVCodecParameters *par) |
AVCodecParameters * | avcodec_parameters_alloc (void) |
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0). More... | |
void | avcodec_parameters_free (AVCodecParameters **ppar) |
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied pointer. More... | |
int | avcodec_parameters_copy (AVCodecParameters *dst, const AVCodecParameters *src) |
Copy the contents of src to dst. More... | |
int | avcodec_parameters_from_context (AVCodecParameters *par, const AVCodecContext *codec) |
Fill the parameters struct based on the values from the supplied codec context. More... | |
int | avcodec_parameters_to_context (AVCodecContext *codec, const AVCodecParameters *par) |
Fill the codec context based on the values from the supplied codec parameters. More... | |
int | ff_alloc_a53_sei (const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size) |
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info. More... | |
int64_t | ff_guess_coded_bitrate (AVCodecContext *avctx) |
Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel. More... | |
int | ff_int_from_list_or_default (void *ctx, const char *val_name, int val, const int *array_valid_values, int default_value) |
Check if a value is in the list. More... | |
Variables | |
const char | av_codec_ffversion [] = "FFmpeg version " FFMPEG_VERSION |
static AVMutex | codec_mutex = AV_MUTEX_INITIALIZER |
utils.
Definition in file utils.c.
#define TAG_PRINT | ( | x | ) |
#define LICENSE_PREFIX "libavcodec license: " |
int ff_set_dimensions | ( | AVCodecContext * | s, |
int | width, | ||
int | height | ||
) |
Check that the provided frame dimensions are valid and set them on the codec context.
Definition at line 104 of file utils.c.
Referenced by alloc_buffers(), aom_decode(), apply_param_change(), avcodec_open2(), avs_decode_init(), bmp_decode_frame(), cdg_decode_init(), cdxl_decode_frame(), cfhd_decode(), clv_decode_init(), cmv_process_header(), codec_reinit(), dds_decode(), decode_fint(), decode_frame(), decode_frame_header(), decode_frame_headers(), decode_header(), decode_idat_chunk(), decode_init(), decode_seq_header(), dirac_decode_data_unit(), dnxhd_decode_frame(), dvbsub_parse_display_definition_segment(), dvdsub_parse_extradata(), dvvideo_decode_frame(), execute_code(), ff_h263_decode_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_pnm_decode_header(), ff_rv34_decode_frame(), ff_vc1_decode_entry_point(), ff_vc1_decode_sequence_header(), ff_vp56_decode_frame(), ffmal_update_format(), fits_decode_frame(), flashsv_decode_frame(), g2m_decode_frame(), get_siz(), gif_decode_frame(), h261_decode_frame(), hqa_decode_frame(), init_image(), libdav1d_receive_frame(), libopenjpeg_decode_frame(), librsvg_decode_frame(), magy_decode_frame(), mediacodec_dec_parse_format(), mimic_decode_frame(), mpeg4_decode_header(), mpeg_decode_postinit(), mpegvideo_extract_headers(), mvc_decode_init(), parse_presentation_segment(), pcx_decode_frame(), pix_decode_frame(), pixlet_decode_frame(), process_frame_obj(), ptx_decode_frame(), rl2_decode_init(), rv20_decode_picture_header(), seqvideo_decode_init(), smvjpeg_decode_frame(), sunrast_decode_frame(), svc_decode_frame(), svq1_decode_frame(), svq3_decode_init(), tdsc_parse_tdsf(), tgq_decode_frame(), tgv_decode_frame(), tqi_decode_frame(), truemotion1_decode_header(), truemotion2rt_decode_header(), txd_decode_frame(), update_dimensions(), update_size(), v4l2_handle_event(), vp56_size_changed(), vp5_parse_header(), vp6_parse_header(), vp8_lossless_decode_frame(), vpx_decode(), vqa_decode_init(), xbm_decode_frame(), xpm_decode_frame(), and xwd_decode_frame().
int ff_set_sar | ( | AVCodecContext * | avctx, |
AVRational | sar | ||
) |
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition at line 119 of file utils.c.
Referenced by decode_frame(), decode_header(), decode_sequence_header_adv(), dirac_decode_data_unit(), dvvideo_decode_frame(), export_stream_params(), ff_h263_decode_frame(), h264_slice_header_init(), mediacodec_dec_parse_format(), and truemotion1_decode_header().
int ff_side_data_update_matrix_encoding | ( | AVFrame * | frame, |
enum AVMatrixEncoding | matrix_encoding | ||
) |
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
Definition at line 134 of file utils.c.
Referenced by ac3_decode_frame(), ff_dca_core_filter_frame(), ff_dca_lbr_filter_frame(), ff_dca_xll_filter_frame(), and output_data().
Definition at line 422 of file utils.c.
Referenced by h264_frame_start().
int avcodec_default_execute2 | ( | AVCodecContext * | c, |
int(*)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr) | func, | ||
void * | arg, | ||
int * | ret, | ||
int | count | ||
) |
enum AVPixelFormat avpriv_find_pix_fmt | ( | const PixelFormatTag * | tags, |
unsigned int | fourcc | ||
) |
Definition at line 477 of file utils.c.
Referenced by avformat_find_stream_info(), avi_write_header(), dshow_pixfmt(), frm_read_header(), mov_get_rawvideo_codec_tag(), and raw_init_decoder().
Definition at line 506 of file utils.c.
Referenced by try_decode_frame(), and try_decode_video_frame().
|
static |
Definition at line 510 of file utils.c.
Referenced by avcodec_open2(), and avcodec_string().
|
static |
Definition at line 541 of file utils.c.
Referenced by avcodec_open2(), and ff_codec_open2_recursive().
|
static |
Definition at line 547 of file utils.c.
Referenced by avcodec_open2(), and ff_codec_open2_recursive().
int attribute_align_arg ff_codec_open2_recursive | ( | AVCodecContext * | avctx, |
const AVCodec * | codec, | ||
AVDictionary ** | options | ||
) |
Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and then restoring again.
Assumes the mutex is already locked
Definition at line 553 of file utils.c.
Referenced by init(), smvjpeg_decode_init(), and tdsc_init().
|
static |
Definition at line 1568 of file utils.c.
Referenced by av_get_audio_frame_duration(), and av_get_audio_frame_duration2().
int ff_thread_init | ( | AVCodecContext * | s | ) |
Definition at line 1796 of file utils.c.
Referenced by avcodec_open2().
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.
Definition at line 1817 of file utils.c.
Referenced by ff_h263_encode_picture_header(), ff_mpv_encode_init(), and svq1_write_header().
Definition at line 1853 of file utils.c.
Referenced by ff_codec_get_id(), ff_mpv_decode_init(), mpeg_decode_frame(), and validate_codec_tag().
int ff_thread_ref_frame | ( | ThreadFrame * | dst, |
ThreadFrame * | src | ||
) |
Definition at line 1861 of file utils.c.
Referenced by ff_h264_ref_picture(), ff_mpeg_ref_picture(), hevc_ref_frame(), update_frames(), vp9_decode_frame(), and vp9_frame_ref().
enum AVPixelFormat ff_thread_get_format | ( | AVCodecContext * | avctx, |
const enum AVPixelFormat * | fmt | ||
) |
Wrapper around get_format() for frame-multithreaded codecs.
Call this function instead of avctx->get_format(). Cannot be called after the codec has called ff_thread_finish_setup().
avctx | The current context. |
fmt | The list of available formats. |
int ff_thread_get_buffer | ( | AVCodecContext * | avctx, |
ThreadFrame * | f, | ||
int | flags | ||
) |
Wrapper around get_buffer() for frame-multithreaded codecs.
Call this function instead of ff_get_buffer(f). Cannot be called after the codec has called ff_thread_finish_setup().
avctx | The current context. |
f | The frame to write into. |
void ff_thread_release_buffer | ( | AVCodecContext * | avctx, |
ThreadFrame * | f | ||
) |
Wrapper around release_buffer() frame-for multithreaded codecs.
Call this function instead of avctx->release_buffer(f). The AVFrame will be copied and the actual release_buffer() call will be performed later. The contents of data pointed to by the AVFrame should not be changed until ff_thread_get_buffer() is called on it.
avctx | The current context. |
f | The picture being released. |
Definition at line 1896 of file utils.c.
Referenced by ff_thread_ref_frame().
void ff_thread_finish_setup | ( | AVCodecContext * | avctx | ) |
If the codec defines update_thread_context(), call this when they are ready for the next thread to start decoding the next frame.
After calling it, do not change any variables read by the update_thread_context() method, or call ff_thread_get_buffer().
avctx | The context. |
void ff_thread_report_progress | ( | ThreadFrame * | f, |
int | progress, | ||
int | field | ||
) |
Notify later decoding threads when part of their reference picture is ready.
Call this when some part of the picture is finished decoding. Later calls with lower values of progress have no effect.
f | The picture being decoded. |
progress | Value, in arbitrary units, of how much of the picture has decoded. |
field | The field being decoded, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field. |
void ff_thread_await_progress | ( | ThreadFrame * | f, |
int | progress, | ||
int | field | ||
) |
Wait for earlier decoding threads to finish reference pictures.
Call this before accessing some part of a picture, with a given value for progress, and it will return after the responsible decoding thread calls ff_thread_report_progress() with the same or higher value for progress.
f | The picture being referenced. |
progress | Value, in arbitrary units, to wait for. |
field | The field being referenced, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field. |
int ff_thread_can_start_frame | ( | AVCodecContext * | avctx | ) |
Definition at line 1914 of file utils.c.
Referenced by ff_mpv_frame_start(), and h264_frame_start().
int ff_alloc_entries | ( | AVCodecContext * | avctx, |
int | count | ||
) |
void ff_reset_entries | ( | AVCodecContext * | avctx | ) |
void ff_thread_await_progress2 | ( | AVCodecContext * | avctx, |
int | field, | ||
int | thread, | ||
int | shift | ||
) |
void ff_thread_report_progress2 | ( | AVCodecContext * | avctx, |
int | field, | ||
int | thread, | ||
int | n | ||
) |
int avpriv_bprint_to_extradata | ( | AVCodecContext * | avctx, |
struct AVBPrint * | buf | ||
) |
Finalize buf into extradata and set its size appropriately.
Definition at line 1943 of file utils.c.
Referenced by dvdsub_init().
AVCPBProperties* ff_add_cpb_side_data | ( | AVCodecContext * | avctx | ) |
Add a CPB properties side data to an encoding context.
Definition at line 2013 of file utils.c.
Referenced by aom_init(), ff_mpv_encode_init(), libx265_encode_init(), nvenc_setup_encoder(), qsv_retrieve_enc_params(), svc_encode_init(), vpx_init(), and X264_init().
|
static |
Definition at line 2039 of file utils.c.
Referenced by avcodec_parameters_alloc(), avcodec_parameters_copy(), avcodec_parameters_free(), and avcodec_parameters_from_context().
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.
frame | Raw frame to get A53 side data from |
prefix_len | Number of bytes to allocate before SEI message |
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 |
sei_size | Pointer to a variable to store generated SEI message length |
'GA94' is standard in North America for ATSC, but hard coding this style may not be the right thing to do – other formats do exist. This information is not available in the side_data so we are going with this right now.
Definition at line 2212 of file utils.c.
Referenced by ff_nvenc_send_frame(), qsv_h264_set_encode_ctrl(), vtenc_send_frame(), and X264_frame().
int64_t ff_guess_coded_bitrate | ( | AVCodecContext * | avctx | ) |
Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel.
Definition at line 2255 of file utils.c.
Referenced by encode_init(), raw_encode_init(), v308_encode_init(), v408_encode_init(), v410_encode_init(), and y41p_encode_init().
int ff_int_from_list_or_default | ( | void * | ctx, |
const char * | val_name, | ||
int | val, | ||
const int * | array_valid_values, | ||
int | default_value | ||
) |
Check if a value is in the list.
If not, return the default value
ctx | Context for the log msg |
val_name | Name of the checked value, for log msg |
array_valid_values | Array of valid int, ended with INT_MAX |
default_value | Value return if checked value is not in the array |
Definition at line 2276 of file utils.c.
Referenced by prores_encode_frame().
const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION |
|
static |
Definition at line 68 of file utils.c.
Referenced by ff_lock_avcodec(), and ff_unlock_avcodec().