69 #include "libavutil/ffversion.h"
72 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
128 if (min_size <= *size && *p)
130 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
177 static int initialized = 0;
179 if (initialized != 0)
194 return codec && codec->
decode;
206 last_avcodec = &codec->
next;
219 #if FF_API_SET_DIMENSIONS
274 *data = matrix_encoding;
426 w_align =
FFMAX(w_align, 8);
429 *width =
FFALIGN(*width, w_align);
430 *height =
FFALIGN(*height, h_align);
436 for (i = 0; i < 4; i++)
448 align =
FFMAX(linesize_align[0], linesize_align[3]);
449 linesize_align[1] <<= chroma_shift;
450 linesize_align[2] <<= chroma_shift;
451 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
452 *width =
FFALIGN(*width, align);
461 *xpos = (pos&1) * 128;
462 *ypos = ((pos>>1)^(pos<4)) * 128;
480 int buf_size,
int align)
482 int ch, planar, needed_size,
ret = 0;
487 if (buf_size < needed_size)
501 sample_fmt, align)) < 0) {
523 int w = frame->
width;
525 int tmpsize, unaligned;
541 for (i = 0; i < 4; i++)
550 for (i = 0; i < 3 && picture.
data[i + 1]; i++)
551 size[i] = picture.
data[i + 1] - picture.
data[i];
552 size[i] = tmpsize - (picture.
data[i] - picture.
data[0]);
554 for (i = 0; i < 4; i++) {
559 CONFIG_MEMORY_POISONING ?
562 if (!pool->
pools[i]) {
577 int planes = planar ? ch : 1;
590 if (!pool->
pools[0]) {
605 for (i = 0; i < 4; i++)
616 int planes = pool->
planes;
668 memset(pic->
data, 0,
sizeof(pic->
data));
671 for (i = 0; i < 4 && pool->
pools[i]; i++) {
705 int is_chroma = p == 1 || p == 2;
708 for (y = 0; y <
height; y++) {
710 for (x = 0; x<bytes; x++)
711 ((uint16_t*)dst)[x] = c[p];
713 memset(dst, c[p], bytes);
726 #if FF_API_GET_BUFFER
746 static const struct {
772 memcpy(frame_sd->
data, packet_sd, size);
839 #if FF_API_GET_BUFFER
876 int override_dimensions = 1;
889 override_dimensions = 0;
906 #if FF_API_GET_BUFFER
939 priv->
avctx = *avctx;
948 #define WRAP_PLANE(ref_out, data, data_size) \
950 AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
952 ret = AVERROR(ENOMEM); \
955 ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
958 av_buffer_unref(&dummy_ref); \
959 av_frame_unref(frame); \
960 ret = AVERROR(ENOMEM); \
973 if (!desc || planes <= 0) {
978 for (i = 0; i < planes; i++) {
986 planes = planar ? avctx->
channels : 1;
1051 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
1058 if (!frame->
data[0])
1090 #if FF_API_GET_BUFFER
1109 for (i = 0; i <
count; i++) {
1110 int r =
func(c, (
char *)arg + i * size);
1121 for (i = 0; i <
count; i++) {
1122 int r =
func(c, arg, i, 0);
1130 unsigned int fourcc)
1133 if (tags->
fourcc == fourcc)
1159 if (hwaccel->
id == codec_id
1160 && hwaccel->
pix_fmt == pix_fmt)
1174 "Could not find an AVHWAccel for the pixel format: %s",
1186 ret = hwa->
init(avctx);
1216 memcpy(choices, fmt, (n + 1) *
sizeof(*choices));
1241 for (n = 0; choices[
n] !=
ret; n++)
1245 choices[
n] = choices[n + 1];
1253 #if FF_API_AVFRAME_LAVC
1256 #if LIBAVCODEC_VERSION_MAJOR >= 55
1263 memset(frame, 0,
sizeof(
AVFrame));
1267 AVFrame *avcodec_alloc_frame(
void)
1272 void avcodec_free_frame(
AVFrame **frame)
1282 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
1286 return codec->max_lowres;
1291 memset(sub, 0,
sizeof(*sub));
1298 int bits_per_sample;
1338 if ((!codec && !avctx->
codec)) {
1342 if ((codec && avctx->
codec && codec != avctx->
codec)) {
1344 "but %s passed to avcodec_open2()\n", avctx->
codec->
name, codec->
name);
1348 codec = avctx->
codec;
1442 avctx->
codec = codec;
1462 "The %s '%s' is experimental but experimental codecs are not enabled, "
1463 "add '-strict %d' if you want to use it.\n",
1468 codec_string, codec2->
name);
1480 av_log(avctx,
AV_LOG_WARNING,
"Warning: not compiled with thread support, using thread emulation\n");
1482 if (CONFIG_FRAME_THREAD_ENCODER) {
1501 av_log(avctx,
AV_LOG_ERROR,
"The maximum value for lowres supported by the decoder is %d\n",
1510 "see the codecview filter instead.\n");
1529 av_log(avctx,
AV_LOG_ERROR,
"Specified sample format %s is invalid or not supported\n",
1544 av_log(avctx,
AV_LOG_ERROR,
"Specified pixel format %s is invalid or not supported\n",
1577 av_log(avctx,
AV_LOG_ERROR,
"Specified channel layout '%s' is not supported\n", buf);
1589 "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
1621 "gray decoding requested but not enabled at configuration time\n");
1633 #if FF_API_AUDIOENC_DELAY
1646 else if (channels != avctx->
channels) {
1650 "Channel layout '%s' with %d channels does not match specified number of channels %d: "
1651 "ignoring specified channel layout\n",
1664 "supported with subtitles codecs\n");
1669 "subtitles character encoding will be ignored\n",
1680 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1681 if (cd == (iconv_t)-1) {
1684 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1690 "conversion needs a libavcodec built with iconv support "
1691 "for this codec\n");
1699 #if FF_API_AVCTX_TIMEBASE
1704 if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
1719 avctx->codec->close(avctx);
1721 if (codec->priv_class && codec->priv_data_size)
1727 if (avctx->internal) {
1732 avctx->codec =
NULL;
1738 if (avpkt->
size < 0) {
1743 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
1750 if (!avpkt->
data || avpkt->
size < size) {
1754 #if FF_API_DESTRUCT_PACKET
1764 #if FF_API_DESTRUCT_PACKET
1770 if (avpkt->
size < size) {
1776 #if FF_API_DESTRUCT_PACKET
1840 int *got_packet_ptr)
1846 int needs_realloc = !user_pkt.
data;
1848 *got_packet_ptr = 0;
1861 "with more than %d channels, but extended_data is not set.\n",
1868 if (!extended_frame)
1871 memcpy(extended_frame, frame,
sizeof(
AVFrame));
1873 frame = extended_frame;
1887 av_log(avctx,
AV_LOG_ERROR,
"more samples than frame size (avcodec_encode_audio2)\n");
1898 frame = padded_frame;
1910 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1912 if (*got_packet_ptr) {
1927 if (user_pkt.
data) {
1928 if (user_pkt.
size >= avpkt->
size) {
1935 avpkt->
buf = user_pkt.
buf;
1937 #if FF_API_DESTRUCT_PACKET
1950 if (needs_realloc && avpkt->
data) {
1959 if (ret < 0 || !*got_packet_ptr) {
1974 #if FF_API_AUDIOENC_DELAY
1981 #if FF_API_OLD_ENCODE_AUDIO
1984 const short *samples)
1988 int ret, samples_size, got_packet;
1992 pkt.
size = buf_size;
2007 "support this codec\n");
2011 nb_samples = (int64_t)buf_size * 8 /
2014 if (nb_samples >= INT_MAX) {
2029 samples_size, 1)) < 0) {
2060 return ret ? ret : pkt.
size;
2065 #if FF_API_OLD_ENCODE_VIDEO
2070 int ret, got_packet = 0;
2079 pkt.
size = buf_size;
2096 return ret ? ret : pkt.
size;
2104 int *got_packet_ptr)
2108 int needs_realloc = !user_pkt.
data;
2110 *got_packet_ptr = 0;
2112 if(CONFIG_FRAME_THREAD_ENCODER &&
2131 if (frame && (frame->
width == 0 || frame->
height == 0))
2136 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
2141 if (user_pkt.
data) {
2142 if (user_pkt.
size >= avpkt->
size) {
2149 avpkt->
buf = user_pkt.
buf;
2151 #if FF_API_DESTRUCT_PACKET
2164 if (!*got_packet_ptr)
2169 if (needs_realloc && avpkt->
data) {
2178 if (ret < 0 || !*got_packet_ptr)
2212 int64_t reordered_pts, int64_t dts)
2230 pts = reordered_pts;
2249 "changes, but PARAM_CHANGE side data was sent to it.\n");
2256 flags = bytestream_get_le32(&data);
2262 avctx->
channels = bytestream_get_le32(&data);
2280 avctx->
width = bytestream_get_le32(&data);
2281 avctx->
height = bytestream_get_le32(&data);
2353 int *got_picture_ptr,
2368 *got_picture_ptr = 0;
2388 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
2416 if (*got_picture_ptr) {
2437 #if FF_API_AVCTX_TIMEBASE
2445 #if FF_API_OLD_DECODE_AUDIO
2447 int *frame_size_ptr,
2451 int ret, got_frame = 0;
2457 "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
2459 "avcodec_decode_audio4()\n");
2466 if (ret >= 0 && got_frame) {
2472 if (*frame_size_ptr < data_size) {
2474 "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
2481 if (planar && avctx->
channels > 1) {
2483 for (ch = 1; ch < avctx->
channels; ch++) {
2488 *frame_size_ptr = data_size;
2490 *frame_size_ptr = 0;
2524 uint32_t discard_padding = 0;
2541 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, &tmp);
2545 if (ret >= 0 && *got_frame_ptr) {
2563 if(side && side_size>=10) {
2565 discard_padding =
AV_RL32(side + 4);
2568 skip_reason =
AV_RL8(side + 8);
2569 discard_reason =
AV_RL8(side + 9);
2601 if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr &&
2624 AV_WL32(fside->
data, avctx->internal->skip_samples);
2628 avctx->internal->skip_samples = 0;
2632 avctx->internal->pkt =
NULL;
2639 if (
ret >= 0 && *got_frame_ptr) {
2640 if (!avctx->refcounted_frames) {
2652 #define UTF8_MAX_BYTES 4
2657 iconv_t cd = (iconv_t)-1;
2686 outb = outpkt->
data;
2687 outl = outpkt->
size;
2689 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
2690 iconv(cd,
NULL,
NULL, &outb, &outl) == (
size_t)-1 ||
2691 outl >= outpkt->
size || inl != 0) {
2698 outpkt->
size -= outl;
2699 memset(outpkt->
data + outpkt->
size, 0, outl);
2702 if (cd != (iconv_t)-1)
2714 uint32_t codepoint,
min;
2718 GET_UTF8(codepoint, *(byte++),
return 0;);
2719 min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
2720 1 << (5 * (byte - str) - 4);
2721 if (codepoint < min || codepoint >= 0x110000 ||
2722 codepoint == 0xFFFE ||
2723 codepoint >= 0xD800 && codepoint <= 0xDFFF )
2776 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, &pkt_recoded);
2790 "Invalid UTF-8 in decoded subtitles text; "
2791 "maybe missing -sub_charenc option\n");
2797 if (tmp.
data != pkt_recoded.
data) {
2851 if (CONFIG_FRAME_THREAD_ENCODER &&
2910 default :
return id;
2929 return experimental;
2987 return "unknown_codec";
2994 #define TAG_PRINT(x) \
2995 (((x) >= '0' && (x) <= '9') || \
2996 ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
2997 ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
2999 for (i = 0; i < 4; i++) {
3001 TAG_PRINT(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
3003 buf_size = buf_size > len ? buf_size - len : 0;
3013 const char *codec_name;
3021 if (!buf || buf_size <= 0)
3035 snprintf(buf, buf_size,
"%s: %s", codec_type ? codec_type :
"unknown",
3037 buf[0] ^=
'a' ^
'A';
3043 snprintf(buf + strlen(buf), buf_size - strlen(buf),
" (%s)", profile);
3047 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3048 ", %d reference frame%s",
3049 enc->
refs, enc->
refs > 1 ?
"s" :
"");
3054 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3055 " (%s / 0x%04X)", tag_buf, enc->
codec_tag);
3061 char detail[256] =
"(";
3065 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3095 if (strlen(detail) > 1) {
3096 detail[strlen(detail) - 2] = 0;
3102 av_strlcat(buf, new_line ? separator :
", ", buf_size);
3104 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3111 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3119 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3120 " [SAR %d:%d DAR %d:%d]",
3122 display_aspect_ratio.
num, display_aspect_ratio.
den);
3126 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3132 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3133 ", q=%d-%d", enc->
qmin, enc->
qmax);
3140 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3145 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3150 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3157 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3164 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3172 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3175 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3180 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3181 ", %d kb/s", bitrate / 1000);
3183 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3220 return FFMPEG_CONFIGURATION;
3225 #define LICENSE_PREFIX "libavcodec license: "
3313 if (be < 0 || be > 1)
3315 return map[
fmt][be];
3348 if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
3349 return (frame_bytes * 8LL) / (bps * ch);
3376 return 256 * sr / 245;
3381 return (480 << (sr / 22050)) / ch;
3389 case 20:
return 160;
3390 case 19:
return 144;
3391 case 29:
return 288;
3392 case 37:
return 480;
3396 case 38:
return 160;
3397 case 50:
return 240;
3402 if (frame_bytes > 0) {
3405 return 240 * (frame_bytes / 32);
3407 return 256 * (frame_bytes / 64);
3409 return 160 * (frame_bytes / 20);
3411 return 240 * (frame_bytes / 24);
3416 return frame_bytes * 8 /
bps;
3423 return frame_bytes / (9 * ch) * 16;
3425 return frame_bytes / (16 * ch) * 28;
3428 return (frame_bytes - 4 * ch) * 2 / ch;
3430 return (frame_bytes - 4) * 2 / ch;
3432 return (frame_bytes - 8) * 2 / ch;
3434 return (frame_bytes / 128) * 224 / ch;
3436 return (frame_bytes - 6 - ch) / ch;
3438 return (frame_bytes - 8) / ch;
3440 return (frame_bytes - 2 * ch) / ch;
3442 return 3 * frame_bytes / ch;
3444 return 6 * frame_bytes / ch;
3446 return 2 * (frame_bytes / (5 * ch));
3449 return 4 * frame_bytes / ch;
3456 return frame_bytes / ch;
3458 return frame_bytes * 2 / ch;
3464 int blocks = frame_bytes / ba;
3467 if (bps < 2 || bps > 5)
3469 return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8);
3471 return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
3473 return blocks * (1 + (ba - 4 * ch) * 2 / ch);
3475 return blocks * ((ba - 4 * ch) * 2 / ch);
3477 return blocks * (2 + (ba - 7 * ch) * 2 / ch);
3487 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
3491 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
3493 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
3538 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
3542 #if FF_API_MISSING_SAMPLE
3547 "version to the newest one from Git. If the problem still "
3548 "occurs, it means that your file has a feature which has not "
3549 "been implemented.\n", feature);
3556 va_list argument_list;
3558 va_start(argument_list, msg);
3563 "of this file to ftp://upload.ffmpeg.org/incoming/ "
3564 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
3566 va_end(argument_list);
3580 last_hwaccel = &hwaccel->
next;
3601 void *new_codec_mutex =
NULL;
3602 void *new_avformat_mutex =
NULL;
3630 "Insufficient thread locking. At least %d threads are "
3631 "calling avcodec_open2() at the same time right now.\n",
3634 av_log(log_ctx,
AV_LOG_ERROR,
"No lock manager is set, please see av_lockmgr_register()\n");
3680 ((
unsigned)
av_toupper((x >> 24) & 0xFF) << 24);
3809 uint32_t *av_restrict
state)
3817 for (i = 0; i < 3; i++) {
3818 uint32_t tmp = *state << 8;
3819 *state = tmp + *(p++);
3820 if (tmp == 0x100 || p == end)
3825 if (p[-1] > 1 ) p += 3;
3826 else if (p[-2] ) p += 2;
3827 else if (p[-3]|(p[-1]-1)) p++;
3834 p =
FFMIN(p, end) - 4;
#define WRAP_PLANE(ref_out, data, data_size)
#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
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)
const struct AVCodec * codec
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
#define avpriv_atomic_int_add_and_fetch
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)
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
void av_free_packet(AVPacket *pkt)
Free a packet.
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]
A dummy id pointing at the start of audio codecs.
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 CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
#define CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int coded_width
Bitstream width / height, may be different from width/height e.g.
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.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
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 CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
AVFrame * coded_frame
the picture in the bitstream
#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.
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.
os2threads to pthreads wrapper
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void avpriv_color_frame(AVFrame *frame, const int c[4])
void av_frame_set_pkt_duration(AVFrame *frame, int64_t val)
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_BUFFER_PADDING_SIZE at the end w...
planar GBR 4:4:4 36bpp, little-endian
A dummy ID pointing at the start of various fake codecs.
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
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.
#define FF_ARRAY_ELEMS(a)
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.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)
int av_dup_packet(AVPacket *pkt)
attribute_deprecated int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
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.
attribute_deprecated void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
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)
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_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
int ff_unlock_avcodec(void)
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
attribute_deprecated void(* destruct)(struct AVPacket *)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
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)
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.
#define CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
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_PROFILE_UNKNOWN
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.
int64_t sample_count
Internal sample count used by avcodec_encode_audio() to fabricate pts.
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.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
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();
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
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define FF_BUFFER_TYPE_INTERNAL
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
static void compat_release_buffer(void *opaque, uint8_t *data)
#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)
uint16_t depth_minus1
Number of bits in the component minus 1.
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 CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#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...
#define CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
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.
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 rc_max_rate
maximum bitrate
#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)
Return the greatest common divisor of a and b.
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
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
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
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.
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)
Libavcodec external API header.
const char av_codec_ffversion[]
av_cold void ff_me_cmp_init_static(void)
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
int av_packet_merge_side_data(AVPacket *pkt)
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_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
int refs
number of reference frames
static AVHWAccel * find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
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)
int bit_rate
the average bitrate
audio channel layout utility functions
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
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 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.
AVPicture pict
data+linesize for the bitmap of this subtitle.
volatile int ff_avcodec_locked
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
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.
attribute_deprecated int reference
#define FF_CEIL_RSHIFT(a, b)
FF_ENABLE_DEPRECATION_WARNINGS int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
#define CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
void av_frame_set_pkt_pos(AVFrame *frame, int64_t val)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define CODEC_FLAG2_SKIP_MANUAL
Do not skip samples and export skip information as frame side data.
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
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).