64 #include "libavutil/ffversion.h"
67 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
158 static int initialized = 0;
160 if (initialized != 0)
187 last_avcodec = &codec->
next;
200 #if FF_API_SET_DIMENSIONS
255 *data = matrix_encoding;
411 w_align =
FFMAX(w_align, 8);
414 *width =
FFALIGN(*width, w_align);
415 *height =
FFALIGN(*height, h_align);
425 *width =
FFMAX(*width, 32);
428 for (i = 0; i < 4; i++)
440 align =
FFMAX(linesize_align[0], linesize_align[3]);
441 linesize_align[1] <<= chroma_shift;
442 linesize_align[2] <<= chroma_shift;
443 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
444 *width =
FFALIGN(*width, align);
453 *xpos = (pos&1) * 128;
454 *ypos = ((pos>>1)^(pos<4)) * 128;
472 int buf_size,
int align)
474 int ch,
planar, needed_size, ret = 0;
479 if (buf_size < needed_size)
493 sample_fmt, align)) < 0) {
516 int w = frame->
width;
518 int tmpsize, unaligned;
536 for (i = 0; i < 4; i++)
545 for (i = 0; i < 3 && data[i + 1]; i++)
546 size[i] = data[i + 1] - data[i];
547 size[i] = tmpsize - (data[i] - data[0]);
549 for (i = 0; i < 4; i++) {
554 CONFIG_MEMORY_POISONING ?
557 if (!pool->
pools[i]) {
572 int planes = planar ? ch : 1;
585 if (!pool->
pools[0]) {
600 for (i = 0; i < 4; i++)
611 int planes = pool->
planes;
666 "Unable to get pixel format descriptor for format %s\n",
671 memset(pic->
data, 0,
sizeof(pic->
data));
674 for (i = 0; i < 4 && pool->
pools[i]; i++) {
709 int is_chroma = p == 1 || p == 2;
712 for (y = 0; y <
height; y++) {
714 for (x = 0; x<bytes; x++)
715 ((uint16_t*)dst)[x] = c[p];
717 memset(dst, c[p], bytes);
759 static const struct {
791 memcpy(frame_sd->
data, packet_sd, size);
884 for (i = 0; i < num_planes; i++) {
893 av_log(avctx,
AV_LOG_ERROR,
"Buffer returned by get_buffer2() did not zero unused plane pointers\n");
902 int override_dimensions = 1;
914 override_dimensions = 0;
965 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
1008 for (i = 0; i <
count; i++) {
1009 int r =
func(c, (
char *)arg + i * size);
1021 for (i = 0; i <
count; i++) {
1022 int r =
func(c, arg, i, 0);
1034 if (tags->
fourcc == fourcc)
1060 if (hwaccel->
id == codec_id
1061 && hwaccel->
pix_fmt == pix_fmt)
1075 "Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.\n");
1080 "Could not find an AVHWAccel for the pixel format: %s",
1099 ret = hwa->
init(avctx);
1129 memcpy(choices, fmt, (n + 1) *
sizeof(*choices));
1149 #if FF_API_CAP_VDPAU
1156 if (hw_frames_ctx->
format != ret) {
1158 "does not match the format of provided AVHWFramesContext\n");
1168 for (n = 0; choices[
n] != ret; n++)
1172 choices[
n] = choices[n + 1];
1184 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
1188 return codec->properties;
1202 memset(sub, 0,
sizeof(*sub));
1209 int bits_per_sample;
1250 if ((!codec && !avctx->
codec)) {
1254 if ((codec && avctx->
codec && codec != avctx->
codec)) {
1256 "but %s passed to avcodec_open2()\n", avctx->
codec->
name, codec->
name);
1260 codec = avctx->
codec;
1366 avctx->
codec = codec;
1386 "The %s '%s' is experimental but experimental codecs are not enabled, "
1387 "add '-strict %d' if you want to use it.\n",
1392 codec_string, codec2->
name);
1404 av_log(avctx,
AV_LOG_WARNING,
"Warning: not compiled with thread support, using thread emulation\n");
1433 "see the codecview filter instead.\n");
1438 #if FF_API_CODED_FRAME
1468 av_log(avctx,
AV_LOG_ERROR,
"Specified sample format %s is invalid or not supported\n",
1483 av_log(avctx,
AV_LOG_ERROR,
"Specified pixel format %s is invalid or not supported\n",
1522 av_log(avctx,
AV_LOG_ERROR,
"Specified channel layout '%s' is not supported\n", buf);
1534 "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
1552 av_log(avctx,
AV_LOG_WARNING,
"Specified bit depth %d not possible with the specified pixel formats depth %d\n",
1573 "ticks_per_frame %d too large for the timebase %d/%d.",
1584 "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n");
1599 "gray decoding requested but not enabled at configuration time\n");
1611 #if FF_API_AUDIOENC_DELAY
1624 else if (channels != avctx->
channels) {
1628 "Channel layout '%s' with %d channels does not match specified number of channels %d: "
1629 "ignoring specified channel layout\n",
1642 "supported with subtitles codecs\n");
1647 "subtitles character encoding will be ignored\n",
1658 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1659 if (cd == (iconv_t)-1) {
1662 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1668 "conversion needs a libavcodec built with iconv support "
1669 "for this codec\n");
1677 #if FF_API_AVCTX_TIMEBASE
1682 if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
1697 avctx->codec->close(avctx);
1699 if (codec->priv_class && codec->priv_data_size)
1703 #if FF_API_CODED_FRAME
1711 if (avctx->internal) {
1718 avctx->codec =
NULL;
1724 if (avpkt->
size < 0) {
1729 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
1734 if (avctx && 2*min_size < size) {
1736 if (!avpkt->
data || avpkt->
size < size) {
1746 if (avpkt->
size < size) {
1811 int *got_packet_ptr)
1817 int needs_realloc = !user_pkt.
data;
1819 *got_packet_ptr = 0;
1822 av_log(avctx,
AV_LOG_ERROR,
"This encoder requires using the avcodec_send_frame() API.\n");
1837 "with more than %d channels, but extended_data is not set.\n",
1844 if (!extended_frame)
1847 memcpy(extended_frame, frame,
sizeof(
AVFrame));
1849 frame = extended_frame;
1863 av_log(avctx,
AV_LOG_ERROR,
"more samples than frame size (avcodec_encode_audio2)\n");
1874 frame = padded_frame;
1888 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1890 if (*got_packet_ptr) {
1905 if (user_pkt.
data) {
1906 if (user_pkt.
size >= avpkt->
size) {
1913 avpkt->
buf = user_pkt.
buf;
1923 if (needs_realloc && avpkt->
data) {
1932 if (ret < 0 || !*got_packet_ptr) {
1947 #if FF_API_AUDIOENC_DELAY
1957 int *got_packet_ptr)
1961 int needs_realloc = !user_pkt.
data;
1963 *got_packet_ptr = 0;
1966 av_log(avctx,
AV_LOG_ERROR,
"This encoder requires using the avcodec_send_frame() API.\n");
1970 if(CONFIG_FRAME_THREAD_ENCODER &&
1989 if (frame && (frame->
width == 0 || frame->
height == 0))
1994 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
2001 if (user_pkt.
data) {
2002 if (user_pkt.
size >= avpkt->
size) {
2009 avpkt->
buf = user_pkt.
buf;
2019 if (!*got_packet_ptr)
2024 if (needs_realloc && avpkt->
data) {
2033 if (ret < 0 || !*got_packet_ptr)
2064 int64_t reordered_pts, int64_t dts)
2082 pts = reordered_pts;
2102 "changes, but PARAM_CHANGE side data was sent to it.\n");
2110 flags = bytestream_get_le32(&data);
2116 val = bytestream_get_le32(&data);
2117 if (val <= 0 || val > INT_MAX) {
2134 val = bytestream_get_le32(&data);
2135 if (val <= 0 || val > INT_MAX) {
2146 avctx->
width = bytestream_get_le32(&data);
2147 avctx->
height = bytestream_get_le32(&data);
2214 int *got_picture_ptr,
2230 av_log(avctx,
AV_LOG_ERROR,
"This decoder requires using the avcodec_send_packet() API.\n");
2234 *got_picture_ptr = 0;
2257 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
2285 *got_picture_ptr = 0;
2287 if (*got_picture_ptr) {
2308 #if FF_API_AVCTX_TIMEBASE
2330 av_log(avctx,
AV_LOG_ERROR,
"This decoder requires using the avcodec_send_packet() API.\n");
2348 uint32_t discard_padding = 0;
2362 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, &tmp);
2366 if (ret >= 0 && *got_frame_ptr) {
2383 if(side && side_size>=10) {
2385 discard_padding =
AV_RL32(side + 4);
2388 skip_reason =
AV_RL8(side + 8);
2389 discard_reason =
AV_RL8(side + 9);
2413 frame->
pts += diff_ts;
2434 if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr &&
2456 AV_WL32(fside->
data, avctx->internal->skip_samples);
2460 avctx->internal->skip_samples = 0;
2464 avctx->internal->pkt =
NULL;
2471 if (ret >= 0 && *got_frame_ptr) {
2472 if (!avctx->refcounted_frames) {
2483 if (!avci->showed_multi_packet_warning &&
2486 avci->showed_multi_packet_warning = 1;
2492 #define UTF8_MAX_BYTES 4
2497 iconv_t cd = (iconv_t)-1;
2526 outb = outpkt->
data;
2527 outl = outpkt->
size;
2529 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
2530 iconv(cd,
NULL,
NULL, &outb, &outl) == (
size_t)-1 ||
2531 outl >= outpkt->
size || inl != 0) {
2538 outpkt->
size -= outl;
2539 memset(outpkt->
data + outpkt->
size, 0, outl);
2542 if (cd != (iconv_t)-1)
2554 uint32_t codepoint,
min;
2558 GET_UTF8(codepoint, *(byte++),
return 0;);
2559 min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
2560 1 << (5 * (byte - str) - 4);
2561 if (codepoint < min || codepoint >= 0x110000 ||
2562 codepoint == 0xFFFE ||
2563 codepoint >= 0xD800 && codepoint <= 0xDFFF )
2570 #if FF_API_ASS_TIMING
2578 h = ts/360000; ts -= 360000*
h;
2579 m = ts/ 6000; ts -= 6000*m;
2580 s = ts/ 100; ts -= 100*
s;
2581 av_bprintf(buf,
"%d:%02d:%02d.%02d,", h, m, s, ts);
2596 int ts_start, ts_duration = -1;
2605 dialog = strchr(rect->
ass,
',');
2611 layer = strtol(dialog, (
char**)&dialog, 10);
2625 insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration);
2635 rect->
ass = final_dialog;
2689 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, &pkt_recoded);
2693 #if FF_API_ASS_TIMING
2714 "Invalid UTF-8 in decoded subtitles text; "
2715 "maybe missing -sub_charenc option\n");
2721 if (tmp.
data != pkt_recoded.
data) {
2808 if (ret >= pkt->
size) {
2841 if (avpkt && !avpkt->
size && avpkt->
data)
2844 if (!avpkt || !avpkt->
size) {
2948 if (ret >= 0 && *got_packet) {
2988 return do_encode(avctx, frame, &(
int){0});
3014 if (ret >= 0 && !got_packet)
3032 if (CONFIG_FRAME_THREAD_ENCODER &&
3069 #if FF_API_CODED_FRAME
3086 default :
return id;
3105 return experimental;
3163 return "unknown_codec";
3168 int i,
len, ret = 0;
3170 #define TAG_PRINT(x) \
3171 (((x) >= '0' && (x) <= '9') || \
3172 ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
3173 ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
3175 for (i = 0; i < 4; i++) {
3177 TAG_PRINT(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
3179 buf_size = buf_size > len ? buf_size - len : 0;
3189 const char *codec_name;
3196 if (!buf || buf_size <= 0)
3202 snprintf(buf, buf_size,
"%s: %s", codec_type ? codec_type :
"unknown",
3204 buf[0] ^=
'a' ^
'A';
3210 snprintf(buf + strlen(buf), buf_size - strlen(buf),
" (%s)", profile);
3214 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3215 ", %d reference frame%s",
3216 enc->
refs, enc->
refs > 1 ?
"s" :
"");
3221 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3222 " (%s / 0x%04X)", tag_buf, enc->
codec_tag);
3228 char detail[256] =
"(";
3232 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3258 const char *field_order =
"progressive";
3260 field_order =
"top first";
3262 field_order =
"bottom first";
3264 field_order =
"top coded first (swapped)";
3266 field_order =
"bottom coded first (swapped)";
3268 av_strlcatf(detail,
sizeof(detail),
"%s, ", field_order);
3276 if (strlen(detail) > 1) {
3277 detail[strlen(detail) - 2] = 0;
3283 av_strlcat(buf, new_line ? separator :
", ", buf_size);
3285 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3292 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3300 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3301 " [SAR %d:%d DAR %d:%d]",
3303 display_aspect_ratio.
num, display_aspect_ratio.
den);
3307 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3313 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3314 ", q=%d-%d", enc->
qmin, enc->
qmax);
3317 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3318 ", Closed Captions");
3320 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3328 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3333 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3338 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3342 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3345 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3353 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3360 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3368 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3371 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3376 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3377 ", %"PRId64
" kb/s", bitrate / 1000);
3379 snprintf(buf + strlen(buf), buf_size - strlen(buf),
3380 ", max. %"PRId64
" kb/s", (int64_t)enc->
rc_max_rate / 1000);
3426 return FFMPEG_CONFIGURATION;
3431 #define LICENSE_PREFIX "libavcodec license: "
3530 if (be < 0 || be > 1)
3532 return map[
fmt][be];
3554 uint32_t
tag,
int bits_per_coded_sample, int64_t bitrate,
3558 int framecount = (ba > 0 && frame_bytes / ba > 0) ? frame_bytes / ba : 1;
3561 if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
3562 return (frame_bytes * 8LL) / (bps *
ch);
3563 bps = bits_per_coded_sample;
3589 return 256 * sr / 245;
3591 return 588 * sr / 44100;
3596 return (480 << (sr / 22050)) / ch;
3604 case 20:
return 160;
3605 case 19:
return 144;
3606 case 29:
return 288;
3607 case 37:
return 480;
3611 case 38:
return 160;
3612 case 50:
return 240;
3617 if (frame_bytes > 0) {
3620 return 240 * (frame_bytes / 32);
3622 return 256 * (frame_bytes / 64);
3624 return 160 * (frame_bytes / 20);
3626 return 240 * (frame_bytes / 24);
3631 return frame_bytes * 8 /
bps;
3634 if (ch > 0 && ch < INT_MAX/16) {
3638 return frame_bytes / (9 *
ch) * 16;
3641 return frame_bytes / (16 *
ch) * 28;
3645 return (frame_bytes - 4 * ch) * 2 /
ch;
3647 return (frame_bytes - 4) * 2 /
ch;
3649 return (frame_bytes - 8) * 2 /
ch;
3653 return frame_bytes * 14 / (8 *
ch);
3656 return (frame_bytes / 128) * 224 /
ch;
3658 return (frame_bytes - 6 - ch) /
ch;
3660 return (frame_bytes - 8) /
ch;
3662 return (frame_bytes - 2 * ch) /
ch;
3664 return 3 * frame_bytes /
ch;
3666 return 6 * frame_bytes /
ch;
3668 return 2 * (frame_bytes / (5 *
ch));
3671 return 4 * frame_bytes /
ch;
3678 return frame_bytes /
ch;
3680 return frame_bytes * 2 /
ch;
3686 int blocks = frame_bytes / ba;
3689 if (bps < 2 || bps > 5)
3691 return blocks * (1 + (ba - 4 *
ch) / (bps * ch) * 8);
3693 return blocks * (((ba - 16) * 2 / 3 * 4) /
ch);
3695 return blocks * (1 + (ba - 4 *
ch) * 2 / ch);
3697 return blocks * ((ba - 4 *
ch) * 2 / ch);
3699 return blocks * (2 + (ba - 7 *
ch) * 2 / ch);
3701 return blocks * (ba - 16) * 2 / ch;
3711 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
3715 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
3717 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
3724 if (frame_size > 1 && frame_bytes)
3729 if (bitrate > 0 && frame_bytes > 0 && sr > 0 && ba > 1) {
3731 return (frame_bytes * 8LL * sr) / bitrate;
3780 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
3784 #if FF_API_MISSING_SAMPLE
3789 "version to the newest one from Git. If the problem still "
3790 "occurs, it means that your file has a feature which has not "
3791 "been implemented.\n", feature);
3798 va_list argument_list;
3800 va_start(argument_list, msg);
3805 "of this file to ftp://upload.ffmpeg.org/incoming/ "
3806 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
3808 va_end(argument_list);
3822 last_hwaccel = &hwaccel->
next;
3843 void *new_codec_mutex =
NULL;
3844 void *new_avformat_mutex =
NULL;
3874 "Insufficient thread locking. At least %d threads are "
3875 "calling avcodec_open2() at the same time right now.\n",
3878 av_log(log_ctx,
AV_LOG_ERROR,
"No lock manager is set, please see av_lockmgr_register()\n");
3927 ((
unsigned)
av_toupper((x >> 24) & 0xFF) << 24);
4036 uint32_t *av_restrict
state)
4044 for (i = 0; i < 3; i++) {
4045 uint32_t
tmp = *state << 8;
4046 *state = tmp + *(p++);
4047 if (tmp == 0x100 || p == end)
4052 if (p[-1] > 1 ) p += 3;
4053 else if (p[-2] ) p += 2;
4054 else if (p[-3]|(p[-1]-1)) p++;
4061 p =
FFMIN(p, end) - 4;
4074 *size =
sizeof(*props);
4111 memset(par, 0,
sizeof(*par));
4151 memcpy(dst, src,
sizeof(*dst));
4281 void **
data,
size_t *sei_size)
4294 *sei_size = side_data->
size + 11;
4298 sei_data = (
uint8_t*)*data + prefix_len;
4313 sei_data[8] = ((side_data->
size/3) & 0x1f) | 0x40;
4316 memcpy(sei_data + 10, side_data->
data, side_data->
size);
4318 sei_data[side_data->
size+10] = 255;
#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)
enum AVChromaLocation chroma_location
#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
enum AVFieldOrder field_order
Video only.
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
enum AVColorTransferCharacteristic color_trc
#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
void av_bprintf(AVBPrint *buf, const char *fmt,...)
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.
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
int(* send_packet)(AVCodecContext *avctx, const AVPacket *avpkt)
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
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 LIBAVCODEC_VERSION_MICRO
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AVRational sample_aspect_ratio
Video only.
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
static int do_decode(AVCodecContext *avctx, AVPacket *pkt)
int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
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.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
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)
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
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.
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.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Mastering display metadata associated with a video frame.
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
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.
static int convert_sub_to_old_ass_form(AVSubtitle *sub, const AVPacket *pkt, AVRational tb)
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferPool * pools[4]
Pools for each data plane.
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
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.
int trailing_padding
Audio only.
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.
This struct describes the properties of an encoded stream.
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
enum AVColorSpace color_space
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
int frame_size
Audio only.
Mastering display metadata (based on SMPTE-2086:2014).
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)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
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.