#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/crc.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/audioconvert.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/dict.h"
#include "avcodec.h"
#include "dsputil.h"
#include "libavutil/opt.h"
#include "imgconvert.h"
#include "thread.h"
#include "frame_thread_encoder.h"
#include "audioconvert.h"
#include "internal.h"
#include "bytestream.h"
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.h>
Go to the source code of this file.
Defines | |
#define | INTERNAL_BUFFER_SIZE (32 + 1) |
#define | MAKE_ACCESSORS(str, name, type, field) |
#define | SANE_NB_CHANNELS 128U |
#define | IS_PRINT(x) |
#define | LICENSE_PREFIX "libavcodec license: " |
Functions | |
void * | av_fast_realloc (void *ptr, unsigned int *size, size_t min_size) |
Reallocate the given block if it is not large enough, otherwise do nothing. | |
static int | ff_fast_malloc (void *ptr, unsigned int *size, size_t min_size, int zero_realloc) |
void | av_fast_malloc (void *ptr, unsigned int *size, size_t min_size) |
Allocate a buffer, reusing the given one if large enough. | |
void | av_fast_padded_malloc (void *ptr, unsigned int *size, size_t min_size) |
Same behaviour av_fast_malloc but the buffer has additional FF_INPUT_PADDING_SIZE at the end which will will always be 0. | |
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. | |
AVCodec * | av_codec_next (const AVCodec *c) |
If c is NULL, returns the first registered codec, if c is non-NULL, returns the next registered codec after c, or NULL if c is the last one. | |
static void | avcodec_init (void) |
int | av_codec_is_encoder (const AVCodec *codec) |
int | av_codec_is_decoder (const AVCodec *codec) |
void | avcodec_register (AVCodec *codec) |
Register the codec codec and initialize libavcodec. | |
unsigned | avcodec_get_edge_width (void) |
Return the amount of padding in pixels which the get_buffer callback must provide around the edge of the image for codecs which do not have the CODEC_FLAG_EMU_EDGE flag. | |
void | avcodec_set_dimensions (AVCodecContext *s, int width, int height) |
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]. | |
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. | |
void | ff_init_buffer_info (AVCodecContext *s, AVFrame *frame) |
does needed setup of pkt_pts/pos and such for (re)get_buffer(); | |
int | avcodec_fill_audio_frame (AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align) |
Fill audio frame data and linesize. | |
static int | audio_get_buffer (AVCodecContext *avctx, AVFrame *frame) |
static int | video_get_buffer (AVCodecContext *s, AVFrame *pic) |
int | avcodec_default_get_buffer (AVCodecContext *avctx, AVFrame *frame) |
void | avcodec_default_release_buffer (AVCodecContext *s, AVFrame *pic) |
int | avcodec_default_reget_buffer (AVCodecContext *s, AVFrame *pic) |
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 PixelFormat | avcodec_default_get_format (struct AVCodecContext *s, const enum PixelFormat *fmt) |
void | avcodec_get_frame_defaults (AVFrame *frame) |
Set the fields of the given AVFrame to default values. | |
AVFrame * | avcodec_alloc_frame (void) |
Allocate an AVFrame and set its fields to default values. | |
void | avcodec_free_frame (AVFrame **frame) |
Free the frame and any dynamically allocated objects in it, e.g. | |
static void | avcodec_get_subtitle_defaults (AVSubtitle *sub) |
static int | get_bit_rate (AVCodecContext *ctx) |
int attribute_align_arg | avcodec_open (AVCodecContext *avctx, AVCodec *codec) |
Initialize the AVCodecContext to use the given AVCodec. | |
int attribute_align_arg | avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) |
Initialize the AVCodecContext to use the given AVCodec. | |
int | ff_alloc_packet2 (AVCodecContext *avctx, AVPacket *avpkt, int size) |
Check AVPacket size and/or allocate data. | |
int | ff_alloc_packet (AVPacket *avpkt, int size) |
static int | pad_last_frame (AVCodecContext *s, AVFrame **dst, const AVFrame *src) |
Pad last frame with silence. | |
int attribute_align_arg | avcodec_encode_audio2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) |
Encode a frame of audio. | |
int attribute_align_arg | avcodec_encode_audio (AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) |
Encode an audio frame from samples into buf. | |
int attribute_align_arg | avcodec_encode_video (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict) |
int attribute_align_arg | avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) |
Encode a frame of video. | |
int | avcodec_encode_subtitle (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub) |
static int64_t | guess_correct_pts (AVCodecContext *ctx, int64_t reordered_pts, int64_t dts) |
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times. | |
static void | apply_param_change (AVCodecContext *avctx, AVPacket *avpkt) |
int attribute_align_arg | avcodec_decode_video2 (AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt) |
Decode the video frame of size avpkt->size from avpkt->data into picture. | |
int attribute_align_arg | avcodec_decode_audio3 (AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) |
Wrapper function which calls avcodec_decode_audio4. | |
int attribute_align_arg | avcodec_decode_audio4 (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt) |
Decode the audio frame of size avpkt->size from avpkt->data into frame. | |
int | avcodec_decode_subtitle2 (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) |
Decode a subtitle message. | |
void | avsubtitle_free (AVSubtitle *sub) |
Free all allocated data in the given subtitle struct. | |
av_cold int | avcodec_close (AVCodecContext *avctx) |
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself). | |
static enum AVCodecID | remap_deprecated_codec_id (enum AVCodecID id) |
AVCodec * | avcodec_find_encoder (enum AVCodecID id) |
Find a registered encoder with a matching codec ID. | |
AVCodec * | avcodec_find_encoder_by_name (const char *name) |
Find a registered encoder with the specified name. | |
AVCodec * | avcodec_find_decoder (enum AVCodecID id) |
Find a registered decoder with a matching codec ID. | |
AVCodec * | avcodec_find_decoder_by_name (const char *name) |
Find a registered decoder with the specified name. | |
const char * | avcodec_get_name (enum AVCodecID id) |
Get the name of a codec. | |
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. | |
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. | |
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. | |
void | avcodec_flush_buffers (AVCodecContext *avctx) |
Flush buffers, should be called when seeking or when switching to a different stream. | |
static void | video_free_buffers (AVCodecContext *s) |
static void | audio_free_buffers (AVCodecContext *avctx) |
void | avcodec_default_free_buffers (AVCodecContext *avctx) |
int | av_get_exact_bits_per_sample (enum AVCodecID codec_id) |
Return codec bits per sample. | |
enum AVCodecID | av_get_pcm_codec (enum AVSampleFormat fmt, int be) |
Return the PCM codec associated with a sample format. | |
int | av_get_bits_per_sample (enum AVCodecID codec_id) |
Return codec bits per sample. | |
int | av_get_audio_frame_duration (AVCodecContext *avctx, int frame_bytes) |
Return audio frame duration. | |
int | ff_thread_init (AVCodecContext *s) |
unsigned int | av_xiphlacing (unsigned char *s, unsigned int v) |
Encode extradata length to a buffer. | |
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. | |
void | av_log_missing_feature (void *avc, const char *feature, int want_sample) |
Log a generic warning message about a missing feature. | |
void | av_log_ask_for_sample (void *avc, const char *msg,...) |
void | av_register_hwaccel (AVHWAccel *hwaccel) |
Register the hardware accelerator hwaccel. | |
AVHWAccel * | av_hwaccel_next (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. | |
AVHWAccel * | ff_find_hwaccel (enum AVCodecID codec_id, enum PixelFormat pix_fmt) |
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt. | |
int | av_lockmgr_register (int(*cb)(void **mutex, enum AVLockOp op)) |
Register a user provided lock manager supporting the operations specified by AVLockOp. | |
int | avpriv_lock_avformat (void) |
int | avpriv_unlock_avformat (void) |
unsigned int | avpriv_toupper4 (unsigned int x) |
int | ff_thread_get_buffer (AVCodecContext *avctx, AVFrame *f) |
Wrapper around get_buffer() for frame-multithreaded codecs. | |
void | ff_thread_release_buffer (AVCodecContext *avctx, AVFrame *f) |
Wrapper around release_buffer() frame-for multithreaded codecs. | |
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. | |
void | ff_thread_report_progress (AVFrame *f, int progress, int field) |
Notify later decoding threads when part of their reference picture is ready. | |
void | ff_thread_await_progress (AVFrame *f, int progress, int field) |
Wait for earlier decoding threads to finish reference pictures. | |
int | ff_thread_can_start_frame (AVCodecContext *avctx) |
enum AVMediaType | avcodec_get_type (enum AVCodecID codec_id) |
Get the type of the given codec. | |
int | avcodec_is_open (AVCodecContext *s) |
Variables | |
static int volatile | entangled_thread_counter = 0 |
static int(* | ff_lockmgr_cb )(void **mutex, enum AVLockOp op) |
static void * | codec_mutex |
static void * | avformat_mutex |
static AVCodec * | first_avcodec = NULL |
static AVHWAccel * | first_hwaccel = NULL |
Definition in file utils.c.
#define INTERNAL_BUFFER_SIZE (32 + 1) |
#define IS_PRINT | ( | x | ) |
Value:
(((x) >= '0' && (x) <= '9') || \ ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \ ((x) == '.' || (x) == ' ' || (x) == '-'))
Referenced by av_get_codec_tag_string().
#define LICENSE_PREFIX "libavcodec license: " |
#define MAKE_ACCESSORS | ( | str, | |||
name, | |||||
type, | |||||
field | ) |
#define SANE_NB_CHANNELS 128U |
Referenced by avcodec_open2().
static void apply_param_change | ( | AVCodecContext * | avctx, | |
AVPacket * | avpkt | |||
) | [static] |
Definition at line 1500 of file utils.c.
Referenced by avcodec_decode_audio4(), and avcodec_decode_video2().
static void audio_free_buffers | ( | AVCodecContext * | avctx | ) | [static] |
static int audio_get_buffer | ( | AVCodecContext * | avctx, | |
AVFrame * | frame | |||
) | [static] |
void av_log_ask_for_sample | ( | void * | avc, | |
const char * | msg, | |||
... | ||||
) |
int avcodec_default_execute2 | ( | AVCodecContext * | c, | |
int(*)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr) | func, | |||
void * | arg, | |||
int * | ret, | |||
int | count | |||
) |
static void avcodec_get_subtitle_defaults | ( | AVSubtitle * | sub | ) | [static] |
static void avcodec_init | ( | void | ) | [static] |
int avpriv_lock_avformat | ( | void | ) |
Definition at line 2509 of file utils.c.
Referenced by ff_codec_get_id(), ff_MPV_common_init(), mpeg_decode_frame(), and validate_codec_tag().
int avpriv_unlock_avformat | ( | void | ) |
int ff_alloc_packet2 | ( | AVCodecContext * | avctx, | |
AVPacket * | avpkt, | |||
int | size | |||
) |
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.
avctx | the AVCodecContext of the encoder | |
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. avpkt->size is set to the specified size. All other AVPacket fields will be reset with av_init_packet(). | |
size | the minimum required packet size |
Definition at line 1054 of file utils.c.
Referenced by a64multi_encode_frame(), aac_encode_frame(), aacPlus_encode_frame(), adx_encode_frame(), alac_encode_frame(), amr_wb_encode_frame(), avui_encode_frame(), bmp_encode_frame(), dnxhd_encode_picture(), encode_frame(), encode_nals(), encode_picture_lossless(), encode_picture_ls(), encode_superframe(), Faac_encode_frame(), ff_alloc_packet(), ff_MPV_encode_picture(), flac_encode_frame(), flashsv2_encode_frame(), flashsv_encode_frame(), gif_encode_frame(), libgsm_encode_frame(), libopenjpeg_encode_frame(), libschroedinger_encode_frame(), mp3lame_encode_frame(), MPA_encode_frame(), oggvorbis_encode_frame(), pam_encode_frame(), pcm_encode_frame(), pcx_encode_frame(), pnm_encode_frame(), prores_encode_frame(), qtrle_encode_frame(), ra144_encode_frame(), raw_encode(), roq_dpcm_encode_frame(), roq_encode_frame(), storeframe(), sunrast_encode_frame(), svq1_encode_frame(), targa_encode_frame(), twolame_encode_frame(), utvideo_encode_frame(), v308_encode_frame(), v408_encode_frame(), v410_encode_frame(), vorbis_encode_frame(), XAVS_frame(), xbm_encode_frame(), xvid_encode_frame(), xwd_encode_frame(), y41p_encode_frame(), and yuv4_encode_frame().
static int ff_fast_malloc | ( | void * | ptr, | |
unsigned int * | size, | |||
size_t | min_size, | |||
int | zero_realloc | |||
) | [inline, static] |
Definition at line 76 of file utils.c.
Referenced by av_fast_malloc(), av_fast_padded_malloc(), and av_fast_padded_mallocz().
AVHWAccel* ff_find_hwaccel | ( | enum AVCodecID | codec_id, | |
enum PixelFormat | pix_fmt | |||
) |
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
codec_id | the codec to match | |
pix_fmt | the pixel format to match |
Definition at line 2460 of file utils.c.
Referenced by decode_slice_header(), ff_h263_decode_init(), vc1_decode_init(), and vcr2_init_sequence().
void ff_init_buffer_info | ( | AVCodecContext * | s, | |
AVFrame * | frame | |||
) |
does needed setup of pkt_pts/pos and such for (re)get_buffer();
Definition at line 305 of file utils.c.
Referenced by audio_get_buffer(), avcodec_default_reget_buffer(), ff_thread_get_buffer(), and video_get_buffer().
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 2412 of file utils.c.
Referenced by ff_h263_encode_picture_header(), ff_MPV_encode_init(), and svq1_write_header().
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 | ) |
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, | |
AVFrame * | f | |||
) |
Wrapper around get_buffer() for frame-multithreaded codecs.
Call this function instead of avctx->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_init | ( | AVCodecContext * | s | ) |
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. |
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. |
static int get_bit_rate | ( | AVCodecContext * | ctx | ) | [static] |
static int64_t guess_correct_pts | ( | AVCodecContext * | ctx, | |
int64_t | reordered_pts, | |||
int64_t | dts | |||
) | [static] |
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times.
Input timestamps may wrap around, in which case the output will as well.
pts | the pts field of the decoded AVPacket, as passed through AVFrame.pkt_pts | |
dts | the dts field of the decoded AVPacket |
Definition at line 1478 of file utils.c.
Referenced by avcodec_decode_audio4(), and avcodec_decode_video2().
static int pad_last_frame | ( | AVCodecContext * | s, | |
AVFrame ** | dst, | |||
const AVFrame * | src | |||
) | [static] |
Pad last frame with silence.
Definition at line 1099 of file utils.c.
Referenced by avcodec_encode_audio2().
Definition at line 1845 of file utils.c.
Referenced by avcodec_find_decoder(), and avcodec_find_encoder().
static void video_free_buffers | ( | AVCodecContext * | s | ) | [static] |
static int video_get_buffer | ( | AVCodecContext * | s, | |
AVFrame * | pic | |||
) | [static] |
void* avformat_mutex [static] |
Definition at line 55 of file utils.c.
Referenced by av_lockmgr_register(), avpriv_lock_avformat(), and avpriv_unlock_avformat().
void* codec_mutex [static] |
Definition at line 54 of file utils.c.
Referenced by av_lockmgr_register(), avcodec_close(), and avcodec_open2().
int volatile entangled_thread_counter = 0 [static] |
int(* ff_lockmgr_cb)(void **mutex, enum AVLockOp op) [static] |
Referenced by av_lockmgr_register(), avcodec_close(), avcodec_open2(), avpriv_lock_avformat(), and avpriv_unlock_avformat().
AVCodec* first_avcodec = NULL [static] |
AVHWAccel* first_hwaccel = NULL [static] |