63 #include "libavutil/ffversion.h"
66 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
157 static int initialized = 0;
159 if (initialized != 0)
174 return codec && codec->
decode;
186 last_avcodec = &codec->
next;
199 #if FF_API_SET_DIMENSIONS
254 *data = matrix_encoding;
408 w_align =
FFMAX(w_align, 8);
411 *width =
FFALIGN(*width, w_align);
412 *height =
FFALIGN(*height, h_align);
422 *width =
FFMAX(*width, 32);
425 for (i = 0; i < 4; i++)
437 align =
FFMAX(linesize_align[0], linesize_align[3]);
438 linesize_align[1] <<= chroma_shift;
439 linesize_align[2] <<= chroma_shift;
440 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
441 *width =
FFALIGN(*width, align);
450 *xpos = (pos&1) * 128;
451 *ypos = ((pos>>1)^(pos<4)) * 128;
469 int buf_size,
int align)
471 int ch, planar, needed_size, ret = 0;
476 if (buf_size < needed_size)
490 sample_fmt, align)) < 0) {
513 int w = frame->
width;
515 int tmpsize, unaligned;
533 for (i = 0; i < 4; i++)
542 for (i = 0; i < 3 && data[i + 1]; i++)
543 size[i] = data[i + 1] - data[i];
544 size[i] = tmpsize - (data[i] - data[0]);
546 for (i = 0; i < 4; i++) {
551 CONFIG_MEMORY_POISONING ?
554 if (!pool->
pools[i]) {
569 int planes = planar ? ch : 1;
582 if (!pool->
pools[0]) {
597 for (i = 0; i < 4; i++)
608 int planes = pool->
planes;
663 "Unable to get pixel format descriptor for format %s\n",
668 memset(pic->
data, 0,
sizeof(pic->
data));
671 for (i = 0; i < 4 && pool->
pools[i]; i++) {
706 int is_chroma = p == 1 || p == 2;
709 for (y = 0; y <
height; y++) {
711 for (x = 0; x<bytes; x++)
712 ((uint16_t*)dst)[x] = c[p];
714 memset(dst, c[p], bytes);
753 static const struct {
779 memcpy(frame_sd->
data, packet_sd, size);
855 int override_dimensions = 1;
868 override_dimensions = 0;
912 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
955 for (i = 0; i <
count; i++) {
956 int r =
func(c, (
char *)arg + i * size);
967 for (i = 0; i <
count; i++) {
968 int r =
func(c, arg, i, 0);
979 if (tags->
fourcc == fourcc)
1005 if (hwaccel->
id == codec_id
1006 && hwaccel->
pix_fmt == pix_fmt)
1020 "Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.\n");
1025 "Could not find an AVHWAccel for the pixel format: %s",
1044 ret = hwa->
init(avctx);
1074 memcpy(choices, fmt, (n + 1) *
sizeof(*choices));
1092 #if FF_API_CAP_VDPAU
1101 for (n = 0; choices[
n] != ret; n++)
1105 choices[
n] = choices[n + 1];
1117 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
1121 return codec->properties;
1131 memset(sub, 0,
sizeof(*sub));
1138 int bits_per_sample;
1179 if ((!codec && !avctx->
codec)) {
1183 if ((codec && avctx->
codec && codec != avctx->
codec)) {
1185 "but %s passed to avcodec_open2()\n", avctx->
codec->
name, codec->
name);
1189 codec = avctx->
codec;
1283 avctx->
codec = codec;
1303 "The %s '%s' is experimental but experimental codecs are not enabled, "
1304 "add '-strict %d' if you want to use it.\n",
1309 codec_string, codec2->
name);
1321 av_log(avctx,
AV_LOG_WARNING,
"Warning: not compiled with thread support, using thread emulation\n");
1342 av_log(avctx,
AV_LOG_ERROR,
"The maximum value for lowres supported by the decoder is %d\n",
1351 "see the codecview filter instead.\n");
1356 #if FF_API_CODED_FRAME
1379 av_log(avctx,
AV_LOG_ERROR,
"Specified sample format %s is invalid or not supported\n",
1394 av_log(avctx,
AV_LOG_ERROR,
"Specified pixel format %s is invalid or not supported\n",
1433 av_log(avctx,
AV_LOG_ERROR,
"Specified channel layout '%s' is not supported\n", buf);
1445 "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
1463 av_log(avctx,
AV_LOG_WARNING,
"Specified bit depth %d not possible with the specified pixel formats depth %d\n",
1484 "ticks_per_frame %d too large for the timebase %d/%d.",
1500 "gray decoding requested but not enabled at configuration time\n");
1512 #if FF_API_AUDIOENC_DELAY
1525 else if (channels != avctx->
channels) {
1529 "Channel layout '%s' with %d channels does not match specified number of channels %d: "
1530 "ignoring specified channel layout\n",
1543 "supported with subtitles codecs\n");
1548 "subtitles character encoding will be ignored\n",
1559 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1560 if (cd == (iconv_t)-1) {
1563 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1569 "conversion needs a libavcodec built with iconv support "
1570 "for this codec\n");
1578 #if FF_API_AVCTX_TIMEBASE
1583 if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
1598 avctx->codec->close(avctx);
1600 if (codec->priv_class && codec->priv_data_size)
1604 #if FF_API_CODED_FRAME
1612 if (avctx->internal) {
1617 avctx->codec =
NULL;
1623 if (avpkt->
size < 0) {
1628 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
1633 if (avctx && 2*min_size < size) {
1635 if (!avpkt->
data || avpkt->
size < size) {
1645 if (avpkt->
size < size) {
1710 int *got_packet_ptr)
1716 int needs_realloc = !user_pkt.
data;
1718 *got_packet_ptr = 0;
1731 "with more than %d channels, but extended_data is not set.\n",
1738 if (!extended_frame)
1741 memcpy(extended_frame, frame,
sizeof(
AVFrame));
1743 frame = extended_frame;
1757 av_log(avctx,
AV_LOG_ERROR,
"more samples than frame size (avcodec_encode_audio2)\n");
1768 frame = padded_frame;
1782 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1784 if (*got_packet_ptr) {
1799 if (user_pkt.
data) {
1800 if (user_pkt.
size >= avpkt->
size) {
1807 avpkt->
buf = user_pkt.
buf;
1817 if (needs_realloc && avpkt->
data) {
1826 if (ret < 0 || !*got_packet_ptr) {
1841 #if FF_API_AUDIOENC_DELAY
1851 int *got_packet_ptr)
1855 int needs_realloc = !user_pkt.
data;
1857 *got_packet_ptr = 0;
1859 if(CONFIG_FRAME_THREAD_ENCODER &&
1878 if (frame && (frame->
width == 0 || frame->
height == 0))
1883 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1888 if (user_pkt.
data) {
1889 if (user_pkt.
size >= avpkt->
size) {
1896 avpkt->
buf = user_pkt.
buf;
1906 if (!*got_packet_ptr)
1911 if (needs_realloc && avpkt->
data) {
1920 if (ret < 0 || !*got_packet_ptr)
1952 int64_t reordered_pts, int64_t dts)
1970 pts = reordered_pts;
1990 "changes, but PARAM_CHANGE side data was sent to it.\n");
1997 flags = bytestream_get_le32(&data);
2003 val = bytestream_get_le32(&data);
2004 if (val <= 0 || val > INT_MAX) {
2020 val = bytestream_get_le32(&data);
2021 if (val <= 0 || val > INT_MAX) {
2031 avctx->
width = bytestream_get_le32(&data);
2032 avctx->
height = bytestream_get_le32(&data);
2092 int *got_picture_ptr,
2107 *got_picture_ptr = 0;
2128 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
2156 if (*got_picture_ptr) {
2177 #if FF_API_AVCTX_TIMEBASE
2211 uint32_t discard_padding = 0;
2228 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, &tmp);
2232 if (ret >= 0 && *got_frame_ptr) {
2249 if(side && side_size>=10) {
2251 discard_padding =
AV_RL32(side + 4);
2254 skip_reason =
AV_RL8(side + 8);
2255 discard_reason =
AV_RL8(side + 9);
2287 if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr &&
2310 AV_WL32(fside->
data, avctx->internal->skip_samples);
2314 avctx->internal->skip_samples = 0;
2318 avctx->internal->pkt =
NULL;
2325 if (ret >= 0 && *got_frame_ptr) {
2326 if (!avctx->refcounted_frames) {
2338 #define UTF8_MAX_BYTES 4
2343 iconv_t cd = (iconv_t)-1;
2372 outb = outpkt->
data;
2373 outl = outpkt->
size;
2375 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
2376 iconv(cd,
NULL,
NULL, &outb, &outl) == (
size_t)-1 ||
2377 outl >= outpkt->
size || inl != 0) {
2384 outpkt->
size -= outl;
2385 memset(outpkt->
data + outpkt->
size, 0, outl);
2388 if (cd != (iconv_t)-1)
2400 uint32_t codepoint,
min;
2404 GET_UTF8(codepoint, *(byte++),
return 0;);
2405 min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
2406 1 << (5 * (byte - str) - 4);
2407 if (codepoint < min || codepoint >= 0x110000 ||
2408 codepoint == 0xFFFE ||
2409 codepoint >= 0xD800 && codepoint <= 0xDFFF )
2462 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, &pkt_recoded);
2476 "Invalid UTF-8 in decoded subtitles text; "
2477 "maybe missing -sub_charenc option\n");
2483 if (tmp.
data != pkt_recoded.
data) {
2538 if (CONFIG_FRAME_THREAD_ENCODER &&
2571 #if FF_API_CODED_FRAME
2588 default :
return id;
2607 return experimental;
2665 return "unknown_codec";
2670 int i,
len, ret = 0;
2672 #define TAG_PRINT(x) \
2673 (((x) >= '0' && (x) <= '9') || \
2674 ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
2675 ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
2677 for (i = 0; i < 4; i++) {
2679 TAG_PRINT(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
2681 buf_size = buf_size > len ? buf_size - len : 0;
2691 const char *codec_name;
2698 if (!buf || buf_size <= 0)
2704 snprintf(buf, buf_size,
"%s: %s", codec_type ? codec_type :
"unknown",
2706 buf[0] ^=
'a' ^
'A';
2712 snprintf(buf + strlen(buf), buf_size - strlen(buf),
" (%s)", profile);
2716 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2717 ", %d reference frame%s",
2718 enc->
refs, enc->
refs > 1 ?
"s" :
"");
2723 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2724 " (%s / 0x%04X)", tag_buf, enc->
codec_tag);
2730 char detail[256] =
"(";
2734 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2764 if (strlen(detail) > 1) {
2765 detail[strlen(detail) - 2] = 0;
2771 av_strlcat(buf, new_line ? separator :
", ", buf_size);
2773 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2780 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2788 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2789 " [SAR %d:%d DAR %d:%d]",
2791 display_aspect_ratio.
num, display_aspect_ratio.
den);
2795 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2801 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2802 ", q=%d-%d", enc->
qmin, enc->
qmax);
2805 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2806 ", Closed Captions");
2808 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2816 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2821 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2826 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2833 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2840 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2848 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2851 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2856 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2857 ", %"PRId64
" kb/s", bitrate / 1000);
2859 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2860 ", max. %"PRId64
" kb/s", (int64_t)enc->
rc_max_rate / 1000);
2906 return FFMPEG_CONFIGURATION;
2911 #define LICENSE_PREFIX "libavcodec license: "
3001 if (be < 0 || be > 1)
3003 return map[
fmt][be];
3036 if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
3037 return (frame_bytes * 8LL) / (bps * ch);
3064 return 256 * sr / 245;
3069 return (480 << (sr / 22050)) / ch;
3077 case 20:
return 160;
3078 case 19:
return 144;
3079 case 29:
return 288;
3080 case 37:
return 480;
3084 case 38:
return 160;
3085 case 50:
return 240;
3090 if (frame_bytes > 0) {
3093 return 240 * (frame_bytes / 32);
3095 return 256 * (frame_bytes / 64);
3097 return 160 * (frame_bytes / 20);
3099 return 240 * (frame_bytes / 24);
3104 return frame_bytes * 8 /
bps;
3107 if (ch > 0 && ch < INT_MAX/16) {
3111 return frame_bytes / (9 * ch) * 16;
3114 return frame_bytes / (16 * ch) * 28;
3117 return (frame_bytes - 4 * ch) * 2 / ch;
3119 return (frame_bytes - 4) * 2 / ch;
3121 return (frame_bytes - 8) * 2 / ch;
3125 return frame_bytes * 14 / (8 * ch);
3128 return (frame_bytes / 128) * 224 / ch;
3130 return (frame_bytes - 6 - ch) / ch;
3132 return (frame_bytes - 8) / ch;
3134 return (frame_bytes - 2 * ch) / ch;
3136 return 3 * frame_bytes / ch;
3138 return 6 * frame_bytes / ch;
3140 return 2 * (frame_bytes / (5 * ch));
3143 return 4 * frame_bytes / ch;
3150 return frame_bytes / ch;
3152 return frame_bytes * 2 / ch;
3158 int blocks = frame_bytes / ba;
3161 if (bps < 2 || bps > 5)
3163 return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8);
3165 return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
3167 return blocks * (1 + (ba - 4 * ch) * 2 / ch);
3169 return blocks * ((ba - 4 * ch) * 2 / ch);
3171 return blocks * (2 + (ba - 7 * ch) * 2 / ch);
3181 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
3185 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
3187 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
3232 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
3236 #if FF_API_MISSING_SAMPLE
3241 "version to the newest one from Git. If the problem still "
3242 "occurs, it means that your file has a feature which has not "
3243 "been implemented.\n", feature);
3250 va_list argument_list;
3252 va_start(argument_list, msg);
3257 "of this file to ftp://upload.ffmpeg.org/incoming/ "
3258 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
3260 va_end(argument_list);
3274 last_hwaccel = &hwaccel->
next;
3295 void *new_codec_mutex =
NULL;
3296 void *new_avformat_mutex =
NULL;
3326 "Insufficient thread locking. At least %d threads are "
3327 "calling avcodec_open2() at the same time right now.\n",
3330 av_log(log_ctx,
AV_LOG_ERROR,
"No lock manager is set, please see av_lockmgr_register()\n");
3379 ((
unsigned)
av_toupper((x >> 24) & 0xFF) << 24);
3488 uint32_t *av_restrict
state)
3496 for (i = 0; i < 3; i++) {
3497 uint32_t tmp = *state << 8;
3498 *state = tmp + *(p++);
3499 if (tmp == 0x100 || p == end)
3504 if (p[-1] > 1 ) p += 3;
3505 else if (p[-2] ) p += 2;
3506 else if (p[-3]|(p[-1]-1)) p++;
3513 p =
FFMIN(p, end) - 4;
3526 *size =
sizeof(*props);
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FF_SANE_NB_CHANNELS
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
static int apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
void av_frame_set_channels(AVFrame *frame, int val)
#define FF_SUB_CHARENC_MODE_PRE_DECODER
the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv ...
const struct AVCodec * codec
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
const char const char void * val
#define avpriv_atomic_int_add_and_fetch
static int64_t get_bit_rate(AVCodecContext *ctx)
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor Code outside libavcodec should access this field using: av_codec_{get,set}_codec_descriptor(avctx)
static AVCodec * find_encdec(enum AVCodecID id, int encoder)
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Number of sample formats. DO NOT USE if linking dynamically.
static enum AVPixelFormat pix_fmt
#define AV_NUM_DATA_POINTERS
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr)
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
static int shift(int a, int b)
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int(* init)(AVCodecContext *avctx)
Initialize the hwaccel private data.
int stride_align[AV_NUM_DATA_POINTERS]
ptrdiff_t const GLvoid * data
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
#define AV_CODEC_FLAG2_SKIP_MANUAL
Do not skip samples and export skip information as frame side data.
int coded_width
Bitstream width / height, may be different from width/height e.g.
int capabilities
Hardware accelerated codec capabilities.
void(* flush)(AVCodecContext *)
Flush buffers.
int av_lockmgr_register(int(*cb)(void **mutex, enum AVLockOp op))
Register a user provided lock manager supporting the operations specified by AVLockOp.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
packed RGB 8:8:8, 24bpp, RGBRGB...
int64_t pos
byte position in stream, -1 if unknown
enum AVColorRange av_frame_get_color_range(const AVFrame *frame)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
#define LIBAVCODEC_VERSION_MICRO
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int nb_extended_buf
Number of elements in extended_buf.
int ff_unlock_avcodec(const AVCodec *codec)
#define FF_SUB_CHARENC_MODE_DO_NOTHING
do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for inst...
const char * avcodec_license(void)
Return the libavcodec license.
enum AVPixelFormat pix_fmt
Supported pixel format.
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
Pad last frame with silence.
AVPacket * pkt
Current packet as passed into the decoder, to avoid having to pass the packet into every function...
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
enum AVMediaType codec_type
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_frame_set_pkt_duration(AVFrame *frame, int64_t val)
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
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 w...
planar GBR 4:4:4 36bpp, little-endian
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
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.
AVBufferPool * pools[4]
Pools for each data plane.
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
void av_frame_set_pkt_size(AVFrame *frame, int val)
planar GBR 4:4:4 36bpp, big-endian
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
AVLockOp
Lock operation used by lockmgr.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
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.
char * text
0 terminated plain UTF-8 text
unsigned avcodec_get_edge_width(void)
Return the amount of padding in pixels which the get_buffer callback must provide around the edge of ...
const char * av_color_space_name(enum AVColorSpace space)
Macro definitions for various function/variable attributes.
FF_DISABLE_DEPRECATION_WARNINGS void av_log_missing_feature(void *avc, const char *feature, int want_sample)
Log a generic warning message about a missing feature.
static void * codec_mutex
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int av_codec_is_decoder(const AVCodec *codec)
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
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.
int av_codec_is_encoder(const AVCodec *codec)
uint64_t vbv_delay
The delay between the time the packet this structure is associated with is received and the time when...
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
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...
struct AVHWAccel * hwaccel
Hardware accelerator in use.
static int volatile entangled_thread_counter
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
planar GBRA 4:4:4:4 64bpp, big-endian
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
static double cb(void *priv, double x, double y)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
enum AVSampleFormat sample_fmt
audio sample format
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Opaque data information usually continuous.
int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
Unpack a dictionary from side_data.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
8 bit with AV_PIX_FMT_RGB32 palette
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
const char * av_color_range_name(enum AVColorRange range)
static av_cold int end(AVCodecContext *avctx)
static int setup_hwaccel(AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static AVCodec * first_avcodec
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
Multithreading support functions.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
#define FF_CODEC_PROPERTY_LOSSLESS
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define LIBAVCODEC_VERSION_INT
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
void * frame_thread_encoder
Structure to hold side data for an AVFrame.
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
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 the...
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
planar GBR 4:4:4 48bpp, big-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
static int(* lockmgr_cb)(void **mutex, enum AVLockOp op)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
does needed setup of pkt_pts/pos and such for (re)get_buffer();
#define AV_CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
#define AV_LOG_VERBOSE
Detailed information.
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val)
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
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.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
char * stats_out
pass1 encoding statistics output buffer
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
AVCPBProperties * av_cpb_properties_alloc(size_t *size)
Allocate a CPB properties structure and initialize its fields to default values.
const OptionDef options[]
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val)
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...
static av_cold void avcodec_init(void)
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Submit a new frame to a decoding thread.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
Libavcodec version macros.
int(* close)(AVCodecContext *)
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
const uint64_t * channel_layouts
array of support channel layouts, or NULL if unknown. array is terminated by 0
planar GBR 4:4:4 27bpp, big-endian
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
const char * av_chroma_location_name(enum AVChromaLocation location)
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AVCodecID
Identify the syntax and semantics of the bitstream.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define avpriv_atomic_ptr_cas
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
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 av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
#define MAKE_ACCESSORS(str, name, type, field)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
unsigned int avpriv_toupper4(unsigned int x)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
int qmax
maximum quantizer
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val)
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...
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
int active_thread_type
Which multithreading methods are in use by the codec.
attribute_deprecated int av_dup_packet(AVPacket *pkt)
int avcodec_is_open(AVCodecContext *s)
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
int capabilities
Codec capabilities.
int initial_padding
Audio only.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_thread_init(AVCodecContext *s)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
int flags
AV_CODEC_FLAG_*.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of a and b.
enum AVPacketSideDataType type
int av_log_get_level(void)
Get the current log level.
const char * name
Name of the codec implementation.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
const struct AVProfile * profiles
If non-NULL, an array of profiles recognized for this codec.
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
void ff_thread_free(AVCodecContext *avctx)
const char av_codec_ffversion[]
av_cold void ff_me_cmp_init_static(void)
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
int priv_data_size
Size of the private data to allocate in AVCodecInternal.hwaccel_priv_data.
int flags
A combination of AV_PKT_FLAG values.
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
reference-counted frame API
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
uint64_t channel_layout
Audio channel layout.
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
uint32_t end_display_time
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int64_t pts
Same as packet pts, in AV_TIME_BASE.
int rc_buffer_size
decoder bitstream buffer size
uint64_t channel_layout
Channel layout of the audio data.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int(* encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
static AVCodec ** last_avcodec
int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options)
common internal API header
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
int refs
number of reference frames
static AVHWAccel * find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
uint8_t nb_components
The number of components each pixel has, (1-4)
static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
audio channel layout utility functions
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
const char * name
Name of the hardware accelerated codec.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
volatile int ff_avcodec_locked
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers, this array will hold all the references which cannot fit into AVFrame.buf.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int(* alloc_frame)(AVCodecContext *avctx, AVFrame *frame)
Allocate a custom buffer.
static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
int width
picture width / height.
#define FF_PROFILE_UNKNOWN
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
void av_frame_set_pkt_pos(AVFrame *frame, int64_t val)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
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 st...
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.
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
const AVProfile * profiles
array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} ...
int64_t reordered_opaque
opaque 64bit number (generally a PTS) that will be reordered and output in AVFrame.reordered_opaque
#define AV_EF_EXPLODE
abort decoding on minor error detection
static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int refcounted_frames
If non-zero, the decoded audio and video frames returned from avcodec_decode_video2() and avcodec_dec...
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
packed RGB 8:8:8, 24bpp, BGRBGR...
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Usually treated as AVMEDIA_TYPE_DATA.
void av_log_ask_for_sample(void *avc, const char *msg,...)
Opaque data information usually sparse.
int ff_alloc_packet(AVPacket *avpkt, int size)
const char * av_get_colorspace_name(enum AVColorSpace val)
Get the name of a colorspace.
static pthread_mutex_t * mutex
static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
char * sub_charenc
DTS of the last frame.
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it...
#define FF_ARRAY_ELEMS(a)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
the normal 2^n-1 "JPEG" YUV ranges
int sub_charenc_mode
Subtitles character encoding mode.
int av_packet_split_side_data(AVPacket *pkt)
int av_codec_get_max_lowres(const AVCodec *codec)
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal decoder state / flush internal buffers.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
const AVS_VideoInfo int align
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
int frame_size
Number of samples per channel in an audio frame.
This structure describes the bitrate properties of an encoded bitstream.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
Libavcodec external API header.
enum AVMediaType codec_type
void(* init_static_data)(struct AVCodec *codec)
Initialize codec static data, called from avcodec_register().
A list of zero terminated key/value strings.
AVSampleFormat
Audio sample formats.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
int sample_rate
samples per second
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar GBR 4:4:4 30bpp, big-endian
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static int recode_subtitle(AVCodecContext *avctx, AVPacket *outpkt, const AVPacket *inpkt)
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
uint8_t * data
The data buffer.
int qmin
minimum quantizer
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
planar GBR 4:4:4 42bpp, little-endian
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
static int utf8_check(const uint8_t *str)
int64_t reordered_opaque
reordered opaque 64bit (generally an integer or a double precision float PTS but can be anything)...
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame)
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
int av_frame_get_channels(const AVFrame *frame)
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
enum AVColorSpace colorspace
YUV colorspace type.
rational number numerator/denominator
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
const char * name
short name for the profile
Recommmends skipping the specified number of samples.
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int(* func)(AVBPrint *dst, const char *in, const char *arg)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
planar GBR 4:4:4 42bpp, big-endian
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
static FF_ENABLE_DEPRECATION_WARNINGS AVHWAccel * first_hwaccel
char * codec_whitelist
',' separated list of allowed decoders.
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
const char * name
Name of the codec described by this descriptor.
enum AVChromaLocation chroma_location
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
static AVHWAccel ** last_hwaccel
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
AVHWAccel * av_hwaccel_next(const AVHWAccel *hwaccel)
If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL...
This struct describes the properties of a single codec described by an AVCodecID. ...
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static int64_t pts
Global timestamp for the audio frames.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
This side data should be associated with an audio stream and contains ReplayGain information in form ...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
const AVClass * priv_class
AVClass for the private context.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
void ff_color_frame(AVFrame *frame, const int c[4])
uint8_t max_lowres
maximum value for lowres supported by the decoder, no direct access, use av_codec_get_max_lowres() ...
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
A reference to a data buffer.
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
Converts swscale x/y chroma position to AVChromaLocation.
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
int avpriv_lock_avformat(void)
#define HWACCEL_CODEC_CAP_EXPERIMENTAL
HWAccel is experimental and is thus avoided in favor of non experimental codecs.
void av_register_hwaccel(AVHWAccel *hwaccel)
Register the hardware accelerator hwaccel.
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
planar GBRA 4:4:4:4 32bpp
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 time...
planar GBR 4:4:4 27bpp, little-endian
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
void * hwaccel_priv_data
hwaccel-specific private data
uint32_t start_display_time
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...
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
int ff_thread_can_start_frame(AVCodecContext *avctx)
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
enum AVCodecID id
Codec implemented by the hardware accelerator.
void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
Notify later decoding threads when part of their reference picture is ready.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
#define AV_PIX_FMT_RGB555
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int caps_internal
Internal codec capabilities.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame)
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
static void get_subtitle_defaults(AVSubtitle *sub)
uint8_t * dump_separator
dump format separator.
#define FF_ENABLE_DEPRECATION_WARNINGS
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
as in Berlin toast format
int channels
number of audio channels
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
const int * supported_samplerates
array of supported audio samplerates, or NULL if unknown, array is terminated by 0 ...
struct AVCodecInternal * internal
Private context used for internal data.
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
Y , 16bpp, little-endian.
char * ass
0 terminated ASS/SSA compatible event line.
This side data corresponds to the AVCPBProperties struct.
static void * avformat_mutex
unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
int flags2
AV_CODEC_FLAG2_*.
enum AVColorPrimaries color_primaries
static const struct twinvq_data tab
unsigned int byte_buffer_size
void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
Wait for earlier decoding threads to finish reference pictures.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
av_cold void avcodec_register(AVCodec *codec)
Register the codec codec and initialize libavcodec.
int64_t pts_correction_last_dts
PTS of the last frame.
static void * av_mallocz_array(size_t nmemb, size_t size)
int frame_number
Frame counter, set by libavcodec.
void ff_frame_thread_encoder_free(AVCodecContext *avctx)
int64_t pts_correction_num_faulty_pts
Current statistics for PTS correction.
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
AVChromaLocation
Location of chroma samples.
enum AVColorTransferCharacteristic color_trc
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
planar GBR 4:4:4 48bpp, little-endian
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
static int add_metadata_from_side_data(AVPacket *avpkt, AVFrame *frame)
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
Recommmends skipping the specified number of samples.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
int ff_alloc_entries(AVCodecContext *avctx, int count)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
int avpriv_unlock_avformat(void)
const uint8_t * avpriv_find_start_code(const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state)
int debug_mv
debug Code outside libavcodec should access this field using AVOptions
void ff_reset_entries(AVCodecContext *avctx)
ReplayGain information in the form of the AVReplayGain struct.
int(* init)(AVCodecContext *)
int depth
Number of bits in the component.
uint8_t ** extended_data
pointers to the data planes/channels.
planar GBRA 4:4:4:4 64bpp, little-endian
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Stereoscopic 3d metadata.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
This structure stores compressed data.
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
int(* encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
static int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.
planar GBR 4:4:4 30bpp, little-endian
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
int64_t rc_max_rate
maximum bitrate
#define AV_CEIL_RSHIFT(a, b)
int last_audio_frame
An audio frame with less than required samples has been submitted and padded with silence...
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
uint8_t * subtitle_header
Header containing style information for text subtitles.
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian