|
FFmpeg
|
utils. More...
#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"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. | |
| 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. | |
| int | ff_set_sar (AVCodecContext *avctx, AVRational sar) |
| Check that the provided sample aspect ratio is valid and set it on the codec context. | |
| int | ff_side_data_update_matrix_encoding (AVFrame *frame, enum AVMatrixEncoding matrix_encoding) |
| Add or update AV_FRAME_DATA_MATRIXENCODING side data. | |
| 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) |
| 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. | |
| const char * | avcodec_configuration (void) |
| Return the libavcodec build-time configuration. | |
| const char * | avcodec_license (void) |
| Return the libavcodec license. | |
| 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... | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
Variables | |
| const char | av_codec_ffversion [] = "FFmpeg version " FFMPEG_VERSION |
utils.
| #define TAG_PRINT | ( | x | ) |
| 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.
| 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.
| 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
| 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.
If there is no such matching pair then size is returned.
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
1.8.12