FFmpeg
|
#include "config.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "codec.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwconfig.h"
#include "thread.h"
#include "threadframe.h"
#include "internal.h"
#include "put_bits.h"
#include "startcode.h"
#include <stdlib.h>
#include <limits.h>
Go to the source code of this file.
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 *avcodec) |
int | av_codec_is_decoder (const AVCodec *avcodec) |
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 | avpriv_codec_get_cap_skip_frame_fill_param (const AVCodec *codec) |
const char * | avcodec_get_name (enum AVCodecID id) |
Get the name of a codec. More... | |
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... | |
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 *avcodec, int index) |
Retrieve supported hardware configurations for a codec. More... | |
int | ff_thread_ref_frame (ThreadFrame *dst, const ThreadFrame *src) |
int | ff_thread_get_buffer (AVCodecContext *avctx, AVFrame *f, int flags) |
Wrapper around get_buffer() for frame-multithreaded codecs. More... | |
int | ff_thread_get_ext_buffer (AVCodecContext *avctx, ThreadFrame *f, int flags) |
Wrapper around ff_get_buffer() for frame-multithreaded codecs. More... | |
void | ff_thread_release_buffer (AVCodecContext *avctx, AVFrame *f) |
Wrapper around release_buffer() frame-for multithreaded codecs. More... | |
void | ff_thread_release_ext_buffer (AVCodecContext *avctx, ThreadFrame *f) |
Unref a ThreadFrame. 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 (const 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_slice_thread_init_progress (AVCodecContext *avctx) |
int | ff_slice_thread_allocz_entries (AVCodecContext *avctx, int count) |
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) |
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 unsigned | bcd2uint (uint8_t bcd) |
int | ff_alloc_timecode_sei (const AVFrame *frame, AVRational rate, size_t prefix_len, void **data, size_t *sei_size) |
Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode 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... | |
utils.
Definition in file utils.c.
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 91 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(), cri_decode_frame(), dds_decode(), decode_blocks(), 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(), gem_decode_frame(), get_siz(), gif_decode_frame(), h261_decode_frame(), hdr_decode_frame(), hqa_decode_frame(), init_image(), libdav1d_parse_extradata(), libdav1d_receive_frame(), libjxl_decode_frame(), libopenjpeg_decode_frame(), librsvg_decode_frame(), libuavs3d_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(), pgx_decode_frame(), photocd_decode_frame(), pix_decode_frame(), pixlet_decode_frame(), process_frame_obj(), ptx_decode_frame(), qoi_decode_frame(), rl2_decode_init(), rv20_decode_picture_header(), seqvideo_decode_init(), set_context_with_sequence(), sga_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_context_with_frame_header(), update_dimensions(), update_size(), v4l2_handle_event(), vbn_decode_frame(), vp56_size_changed(), vp5_parse_header(), vp6_parse_header(), vp8_lossless_decode_frame(), vpx_decode(), vqa_decode_init(), wbmp_decode_frame(), 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 106 of file utils.c.
Referenced by aom_decode(), decode_frame(), decode_sequence_header_adv(), dirac_decode_data_unit(), dvvideo_decode_frame(), export_stream_params(), ff_h263_decode_frame(), h264_slice_header_init(), libdav1d_receive_frame(), mediacodec_dec_parse_format(), truemotion1_decode_header(), and update_context_with_frame_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 121 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 409 of file utils.c.
Referenced by h264_field_start().
Definition at line 438 of file utils.c.
Referenced by try_decode_frame().
|
static |
Definition at line 603 of file utils.c.
Referenced by av_get_audio_frame_duration(), and av_get_audio_frame_duration2().
int ff_thread_init | ( | AVCodecContext * | s | ) |
Encode extradata length to a buffer.
Used by xiph codecs.
s | buffer to write to; must be at least (v/255+1) bytes long |
v | size of extradata in bytes |
Definition at line 863 of file utils.c.
Referenced by fixup_vorbis_headers(), libvorbis_encode_init(), parse_packed_headers(), put_main_header(), and track_header().
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 877 of file utils.c.
Referenced by ff_h263_encode_picture_header(), ff_mpv_encode_init(), and svq1_write_header().
int ff_thread_ref_frame | ( | ThreadFrame * | dst, |
const ThreadFrame * | src | ||
) |
Definition at line 896 of file utils.c.
Referenced by ff_h264_ref_picture(), ff_h264_replace_picture(), ff_mpeg_ref_picture(), h264_field_start(), hevc_ref_frame(), update_frames(), vp9_decode_frame(), and vp9_frame_ref().
int ff_thread_get_buffer | ( | AVCodecContext * | avctx, |
AVFrame * | 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. |
int ff_thread_get_ext_buffer | ( | AVCodecContext * | avctx, |
ThreadFrame * | f, | ||
int | flags | ||
) |
Wrapper around ff_get_buffer() for frame-multithreaded codecs.
Call this function instead of ff_get_buffer() if you might need to wait for progress on this frame. 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, |
AVFrame * | 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_release_ext_buffer | ( | AVCodecContext * | avctx, |
ThreadFrame * | f | ||
) |
Unref a ThreadFrame.
This is basically a wrapper around av_frame_unref() and should be called instead of it.
avctx | The current context. |
f | The picture being released. |
Definition at line 937 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 | ( | const 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 | ) |
int ff_slice_thread_init_progress | ( | AVCodecContext * | avctx | ) |
int ff_slice_thread_allocz_entries | ( | AVCodecContext * | avctx, |
int | count | ||
) |
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 | ||
) |
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.
size | if non-NULL, the size of the allocated struct will be written here. This is useful for embedding it in side data. |
Definition at line 1014 of file utils.c.
Referenced by ff_add_cpb_side_data(), and ff_mpv_encode_picture().
AVCPBProperties* ff_add_cpb_side_data | ( | AVCodecContext * | avctx | ) |
Add a CPB properties side data to an encoding context.
Definition at line 1028 of file utils.c.
Referenced by aom_init(), config_enc_params(), ff_mpv_encode_init(), libx265_encode_init(), mpeg_decode_sequence_extension(), nvenc_setup_encoder(), qsv_retrieve_enc_params(), svc_encode_init(), vpx_init(), and X264_init().
|
static |
Definition at line 1059 of file utils.c.
Referenced by ff_alloc_timecode_sei().
int ff_alloc_timecode_sei | ( | const AVFrame * | frame, |
AVRational | rate, | ||
size_t | prefix_len, | ||
void ** | data, | ||
size_t * | sei_size | ||
) |
Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info.
frame | Raw frame to get S12M timecode side data from |
rate | The frame rate |
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 S12M timecode 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 |
Definition at line 1068 of file utils.c.
Referenced by prepare_sei_data_array().
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 1132 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 1153 of file utils.c.
Referenced by prores_encode_frame().