30 #include "libavutil/attributes.h"
31 #include "libavutil/avassert.h"
32 #include "libavutil/avstring.h"
33 #include "libavutil/bprint.h"
34 #include "libavutil/channel_layout.h"
35 #include "libavutil/crc.h"
36 #include "libavutil/frame.h"
38 #include "libavutil/mathematics.h"
39 #include "libavutil/pixdesc.h"
40 #include "libavutil/imgutils.h"
41 #include "libavutil/samplefmt.h"
42 #include "libavutil/dict.h"
45 #include "libavutil/opt.h"
67 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
122 if (min_size < *size)
125 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
142 if (min_size < *size)
144 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
195 static int initialized = 0;
197 if (initialized != 0)
212 return codec && codec->
decode;
241 #if HAVE_NEON || ARCH_PPC || HAVE_MMX
242 # define STRIDE_ALIGN 16
244 # define STRIDE_ALIGN 8
379 w_align =
FFMAX(w_align, 8);
382 *width =
FFALIGN(*width, w_align);
383 *height =
FFALIGN(*height, h_align);
389 for (i = 0; i < 4; i++)
401 align =
FFMAX(linesize_align[0], linesize_align[3]);
402 linesize_align[1] <<= chroma_shift;
403 linesize_align[2] <<= chroma_shift;
404 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
405 *width =
FFALIGN(*width, align);
414 *xpos = (pos&1) * 128;
415 *ypos = ((pos>>1)^(pos<4)) * 128;
433 int buf_size,
int align)
435 int ch, planar, needed_size,
ret = 0;
440 if (buf_size < needed_size)
454 sample_fmt, align)) < 0) {
476 int w = frame->
width;
478 int tmpsize, unaligned;
499 for (i = 0; i < 4; i++)
508 for (i = 0; i < 3 && picture.
data[i + 1]; i++)
509 size[i] = picture.
data[i + 1] - picture.
data[i];
510 size[i] = tmpsize - (picture.
data[i] - picture.
data[0]);
512 for (i = 0; i < 4; i++) {
520 if (!pool->
pools[i]) {
535 int planes = planar ? ch : 1;
548 if (!pool->
pools[0]) {
563 for (i = 0; i < 4; i++)
574 int planes = pool->
planes;
621 int h_chroma_shift, v_chroma_shift;
624 if (pic->
data[0] != NULL) {
629 memset(pic->
data, 0,
sizeof(pic->
data));
634 for (i = 0; i < 4 && pool->
pools[i]; i++) {
635 const int h_shift = i == 0 ? 0 : h_chroma_shift;
636 const int v_shift = i == 0 ? 0 : v_chroma_shift;
679 int is_chroma = p == 1 || p == 2;
682 for (y = 0; y <
height; y++) {
684 for (x = 0; x<bytes; x++)
685 ((uint16_t*)dst)[x] = c[p];
687 memset(dst, c[p], bytes);
700 #if FF_API_GET_BUFFER
773 #if FF_API_GET_BUFFER
780 typedef struct CompatReleaseBufPriv {
783 } CompatReleaseBufPriv;
785 static void compat_free_buffer(
void *opaque,
uint8_t *
data)
787 CompatReleaseBufPriv *priv = opaque;
788 if (priv->avctx.release_buffer)
789 priv->avctx.release_buffer(&priv->avctx, &priv->frame);
793 static void compat_release_buffer(
void *opaque,
uint8_t *data)
814 #if FF_API_GET_BUFFER
824 CompatReleaseBufPriv *priv = NULL;
847 priv->avctx = *avctx;
848 priv->frame = *
frame;
856 #define WRAP_PLANE(ref_out, data, data_size) \
858 AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
860 ret = AVERROR(ENOMEM); \
863 ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
866 av_frame_unref(frame); \
867 ret = AVERROR(ENOMEM); \
880 if (!desc || planes <= 0) {
885 for (i = 0; i < planes; i++) {
889 WRAP_PLANE(frame->
buf[i], frame->
data[i], plane_size);
893 planes = planar ? avctx->
channels : 1;
957 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
994 #if FF_API_GET_BUFFER
1013 for (i = 0; i <
count; i++) {
1014 int r =
func(c, (
char *)arg + i * size);
1025 for (i = 0; i <
count; i++) {
1026 int r =
func(c, arg, i, 0);
1048 #if LIBAVCODEC_VERSION_MAJOR >= 55
1055 memset(frame, 0,
sizeof(
AVFrame));
1088 if (!frame || !*frame)
1106 return codec->max_lowres;
1111 memset(sub, 0,
sizeof(*sub));
1118 int bits_per_sample;
1138 #if FF_API_AVCODEC_OPEN
1165 if ((!codec && !avctx->
codec)) {
1169 if ((codec && avctx->
codec && codec != avctx->
codec)) {
1171 "but %s passed to avcodec_open2()\n", avctx->
codec->
name, codec->
name);
1175 codec = avctx->
codec;
1245 avctx->
codec = codec;
1265 "The %s '%s' is experimental but experimental codecs are not enabled, "
1266 "add '-strict %d' if you want to use it.\n",
1271 codec_string, codec2->
name);
1283 av_log(avctx,
AV_LOG_WARNING,
"Warning: not compiled with thread support, using thread emulation\n");
1304 av_log(avctx,
AV_LOG_ERROR,
"The maximum value for lowres supported by the decoder is %d\n",
1326 av_log(avctx,
AV_LOG_ERROR,
"Specified sample format %s is invalid or not supported\n",
1341 av_log(avctx,
AV_LOG_ERROR,
"Specified pixel format %s is invalid or not supported\n",
1368 av_log(avctx,
AV_LOG_ERROR,
"Specified channel layout '%s' is not supported\n", buf);
1380 "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
1429 else if (channels != avctx->
channels) {
1433 "Channel layout '%s' with %d channels does not match specified number of channels %d: "
1434 "ignoring specified channel layout\n",
1447 "supported with subtitles codecs\n");
1452 "subtitles character encoding will be ignored\n",
1463 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1464 if (cd == (iconv_t)-1) {
1466 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1473 "conversion needs a libavcodec built with iconv support "
1474 "for this codec\n");
1496 avctx->
codec = NULL;
1502 if (avpkt->
size < 0) {
1507 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
1514 if (!avpkt->
data || avpkt->
size < size) {
1524 #if FF_API_DESTRUCT_PACKET
1530 if (avpkt->
size < size) {
1536 #if FF_API_DESTRUCT_PACKET
1600 int *got_packet_ptr)
1606 int needs_realloc = !user_pkt.
data;
1608 *got_packet_ptr = 0;
1621 "with more than %d channels, but extended_data is not set.\n",
1636 av_log(avctx,
AV_LOG_ERROR,
"more samples than frame size (avcodec_encode_audio2)\n");
1646 frame = padded_frame;
1658 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1660 if (*got_packet_ptr) {
1675 if (user_pkt.
data) {
1676 if (user_pkt.
size >= avpkt->
size) {
1683 avpkt->
buf = user_pkt.
buf;
1694 if (needs_realloc && avpkt->
data) {
1703 if (ret < 0 || !*got_packet_ptr) {
1720 #if FF_API_OLD_ENCODE_AUDIO
1723 const short *samples)
1728 int ret, samples_size, got_packet;
1732 pkt.
size = buf_size;
1746 "support this codec\n");
1749 nb_samples = (int64_t)buf_size * 8 /
1752 if (nb_samples >= INT_MAX)
1765 samples_size, 1)) < 0)
1793 return ret ? ret : pkt.
size;
1798 #if FF_API_OLD_ENCODE_VIDEO
1803 int ret, got_packet = 0;
1812 pkt.
size = buf_size;
1829 return ret ? ret : pkt.
size;
1837 int *got_packet_ptr)
1841 int needs_realloc = !user_pkt.
data;
1843 *got_packet_ptr = 0;
1864 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1869 if (user_pkt.
data) {
1870 if (user_pkt.
size >= avpkt->
size) {
1877 avpkt->
buf = user_pkt.
buf;
1888 if (!*got_packet_ptr)
1893 if (needs_realloc && avpkt->
data) {
1902 if (ret < 0 || !*got_packet_ptr)
1936 int64_t reordered_pts, int64_t dts)
1950 pts = reordered_pts;
1967 if (!data || size < 4)
1969 flags = bytestream_get_le32(&data);
1974 avctx->
channels = bytestream_get_le32(&data);
1992 avctx->
width = bytestream_get_le32(&data);
1993 avctx->
height = bytestream_get_le32(&data);
2009 end = side_metadata +
size;
2010 if (size && end[-1])
2012 while (side_metadata < end) {
2013 const uint8_t *key = side_metadata;
2014 const uint8_t *
val = side_metadata + strlen(key) + 1;
2023 side_metadata = val + strlen(val) + 1;
2030 int *got_picture_ptr,
2045 *got_picture_ptr = 0;
2062 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
2089 if (ret < 0 && picture->data[0])
2092 if (*got_picture_ptr) {
2096 memset(picture->
buf, 0,
sizeof(picture->
buf));
2115 #if FF_API_OLD_DECODE_AUDIO
2117 int *frame_size_ptr,
2121 int ret, got_frame = 0;
2125 "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
2127 "avcodec_decode_audio4()\n");
2134 if (ret >= 0 && got_frame) {
2140 if (*frame_size_ptr < data_size) {
2142 "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
2148 if (planar && avctx->
channels > 1) {
2150 for (ch = 1; ch < avctx->
channels; ch++) {
2155 *frame_size_ptr = data_size;
2157 *frame_size_ptr = 0;
2170 int planar, channels;
2194 uint32_t discard_padding = 0;
2204 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, &tmp);
2207 if (ret >= 0 && *got_frame_ptr) {
2225 if(side && side_size>=10) {
2229 discard_padding =
AV_RL32(side + 4);
2260 if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr) {
2286 if (ret >= 0 && *got_frame_ptr) {
2288 avci->to_free = *
frame;
2290 memset(frame->
buf, 0,
sizeof(frame->
buf));
2294 }
else if (frame->
data[0])
2301 if (*got_frame_ptr) {
2313 #define UTF8_MAX_BYTES 4
2318 iconv_t cd = (iconv_t)-1;
2347 outb = outpkt->
data;
2348 outl = outpkt->
size;
2350 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
2351 iconv(cd, NULL, NULL, &outb, &outl) == (
size_t)-1 ||
2352 outl >= outpkt->
size || inl != 0) {
2359 outpkt->
size -= outl;
2360 memset(outpkt->
data + outpkt->
size, 0, outl);
2363 if (cd != (iconv_t)-1)
2367 av_assert0(!
"requesting subtitles recoding without iconv");
2374 uint32_t codepoint,
min;
2378 GET_UTF8(codepoint, *(byte++),
return 0;);
2379 min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
2380 1 << (5 * (byte - str) - 4);
2381 if (codepoint < min || codepoint >= 0x110000 ||
2382 codepoint == 0xFFFE ||
2383 codepoint >= 0xD800 && codepoint <= 0xDFFF )
2421 avctx->
pkt = &pkt_recoded;
2426 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, &pkt_recoded);
2440 "Invalid UTF-8 in decoded subtitles text; "
2441 "maybe missing -sub_charenc option\n");
2447 if (tmp.
data != pkt_recoded.
data) {
2546 avctx->
codec = NULL;
2566 default :
return id;
2572 AVCodec *p, *experimental = NULL;
2585 return experimental;
2643 return "unknown_codec";
2648 int i,
len, ret = 0;
2650 #define TAG_PRINT(x) \
2651 (((x) >= '0' && (x) <= '9') || \
2652 ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
2653 ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
2655 for (i = 0; i < 4; i++) {
2657 TAG_PRINT(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
2659 buf_size = buf_size > len ? buf_size - len : 0;
2669 const char *codec_name;
2670 const char *profile = NULL;
2675 if (!buf || buf_size <= 0)
2689 snprintf(buf, buf_size,
"%s: %s", codec_type ? codec_type :
"unknown",
2691 buf[0] ^=
'a' ^
'A';
2697 snprintf(buf + strlen(buf), buf_size - strlen(buf),
" (%s)", profile);
2701 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2702 " (%s / 0x%04X)", tag_buf, enc->
codec_tag);
2708 char detail[256] =
"(";
2709 const char *colorspace_name;
2710 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2721 if (colorspace_name)
2722 av_strlcatf(detail,
sizeof(detail),
"%s, ", colorspace_name);
2724 if (strlen(detail) > 1) {
2725 detail[strlen(detail) - 2] = 0;
2730 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2738 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2739 " [SAR %d:%d DAR %d:%d]",
2741 display_aspect_ratio.
num, display_aspect_ratio.
den);
2745 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2751 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2752 ", q=%d-%d", enc->
qmin, enc->
qmax);
2757 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2763 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2771 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2778 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2786 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2789 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2794 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2795 ", %d kb/s", bitrate / 1000);
2797 snprintf(buf + strlen(buf), buf_size - strlen(buf),
2839 #define LICENSE_PREFIX "libavcodec license: "
2923 if (be < 0 || be > 1)
2925 return map[
fmt][be];
2958 if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
2959 return (frame_bytes * 8LL) / (bps * ch);
2985 return 256 * sr / 245;
2990 return (480 << (sr / 22050)) / ch;
2998 case 20:
return 160;
2999 case 19:
return 144;
3000 case 29:
return 288;
3001 case 37:
return 480;
3005 case 38:
return 160;
3006 case 50:
return 240;
3011 if (frame_bytes > 0) {
3014 return 240 * (frame_bytes / 32);
3016 return 256 * (frame_bytes / 64);
3018 return 160 * (frame_bytes / 20);
3020 return 240 * (frame_bytes / 24);
3025 return frame_bytes * 8 /
bps;
3032 return frame_bytes / (9 * ch) * 16;
3034 return frame_bytes / (16 * ch) * 28;
3037 return (frame_bytes - 4 * ch) * 2 / ch;
3039 return (frame_bytes - 4) * 2 / ch;
3041 return (frame_bytes - 8) * 2 / ch;
3043 return (frame_bytes / 128) * 224 / ch;
3045 return (frame_bytes - 6 - ch) / ch;
3047 return (frame_bytes - 8) / ch;
3049 return (frame_bytes - 2 * ch) / ch;
3051 return 3 * frame_bytes / ch;
3053 return 6 * frame_bytes / ch;
3055 return 2 * (frame_bytes / (5 * ch));
3058 return 4 * frame_bytes / ch;
3065 return frame_bytes / ch;
3067 return frame_bytes * 2 / ch;
3073 int blocks = frame_bytes / ba;
3076 if (bps < 2 || bps > 5)
3078 return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8);
3080 return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
3082 return blocks * (1 + (ba - 4 * ch) * 2 / ch);
3084 return blocks * ((ba - 4 * ch) * 2 / ch);
3086 return blocks * (2 + (ba - 7 * ch) * 2 / ch);
3096 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
3100 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
3102 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
3136 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
3140 #if FF_API_MISSING_SAMPLE
3145 "version to the newest one from Git. If the problem still "
3146 "occurs, it means that your file has a feature which has not "
3147 "been implemented.\n", feature);
3154 va_list argument_list;
3156 va_start(argument_list, msg);
3161 "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
3162 "and contact the ffmpeg-devel mailing list.\n");
3164 va_end(argument_list);
3174 hwaccel->
next = NULL;
3189 if (hwaccel->
id == codec_id
3190 && hwaccel->
pix_fmt == pix_fmt)
3221 entangled_thread_counter++;
3222 if (entangled_thread_counter != 1) {
3223 av_log(log_ctx,
AV_LOG_ERROR,
"Insufficient thread locking around avcodec_open/close()\n");
3225 av_log(log_ctx,
AV_LOG_ERROR,
"No lock manager is set, please see av_lockmgr_register()\n");
3226 ff_avcodec_locked = 1;
3231 ff_avcodec_locked = 1;
3238 ff_avcodec_locked = 0;
3239 entangled_thread_counter--;
3399 for (i = 0; i < 3; i++) {
3400 uint32_t tmp = *state << 8;
3401 *state = tmp + *(p++);
3402 if (tmp == 0x100 || p == end)
3407 if (p[-1] > 1 ) p += 3;
3408 else if (p[-2] ) p += 2;
3409 else if (p[-3]|(p[-1]-1)) p++;
3416 p =
FFMIN(p, end) - 4;
#define FF_SANE_NB_CHANNELS
int ff_unlock_avcodec(void)
#define CONFIG_FRAME_THREAD_ENCODER
int ff_thread_can_start_frame(AVCodecContext *avctx)
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)
const char const char void * val
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
static AVCodec * find_encdec(enum AVCodecID id, int encoder)
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr)
static int shift(int a, int b)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
const char * avcodec_license(void)
Return the libavcodec license.
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int, int), void *arg, int *ret, int count)
int avpriv_unlock_avformat(void)
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 stride_align[AV_NUM_DATA_POINTERS]
A dummy id pointing at the start of audio codecs.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
#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.
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
#define AV_LOG_WARNING
Something somehow does not look correct.
planar GBR 4:4:4 27bpp, big-endian
Number of sample formats. DO NOT USE if linking dynamically.
int64_t pos
byte position in stream, -1 if unknown
uint8_t * subtitle_header
Header containing style information for text subtitles.
int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Submit a new frame to a decoding thread.
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
const char * name
Name of the codec described by this descriptor.
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
AVFrame * avcodec_alloc_frame(void)
Allocate an AVFrame and set its fields to default values.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
packed RGB 8:8:8, 24bpp, RGBRGB...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int nb_extended_buf
Number of elements in extended_buf.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
uint8_t ** extended_data
pointers to the data planes/channels.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
enum AVPixelFormat pix_fmt
Supported pixel format.
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
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.
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.
enum AVMediaType codec_type
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
os2threads to pthreads wrapper
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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...
A dummy ID pointing at the start of various fake codecs.
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
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)
AVChromaLocation
X X 3 4 X X are luma samples, 1 2 1-6 are possible chroma positions X X 5 6 X 0 is undefined/unknown ...
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
int 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.
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
void av_frame_set_pkt_duration(AVFrame *frame, int64_t val)
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
attribute_deprecated void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)
int av_dup_packet(AVPacket *pkt)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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_channels(AVFrame *frame, int val)
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.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
attribute_deprecated void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
attribute_deprecated 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
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int av_codec_is_decoder(const AVCodec *codec)
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.
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
int av_codec_is_encoder(const AVCodec *codec)
packed RGB 8:8:8, 24bpp, BGRBGR...
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...
static int volatile entangled_thread_counter
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static double cb(void *priv, double x, double y)
#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...
enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
enum AVSampleFormat sample_fmt
audio sample format
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#define AV_PIX_FMT_RGB555
attribute_deprecated void(* destruct)(struct AVPacket *)
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static av_cold int end(AVCodecContext *avctx)
static AVCodec * first_avcodec
Multithreading support functions.
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
#define FF_CEIL_RSHIFT(a, b)
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.
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.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
void * frame_thread_encoder
attribute_deprecated void void av_register_hwaccel(AVHWAccel *hwaccel)
Register the hardware accelerator hwaccel.
static int(* lockmgr_cb)(void **mutex, enum AVLockOp op)
struct AVCodecInternal * internal
Private context used for internal data.
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
int ff_thread_init(AVCodecContext *avctx)
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.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
enum AVPixelFormat pix_fmt
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_NUM_DATA_POINTERS
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
struct AVPacket::@25 * side_data
Additional packet data that can be provided by the container.
AVHWAccel * av_hwaccel_next(AVHWAccel *hwaccel)
If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL...
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
#define AVERROR_EXPERIMENTAL
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
#define FF_BUFFER_TYPE_INTERNAL
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Libavcodec version macros.
int(* close)(AVCodecContext *)
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.
static AVHWAccel * first_hwaccel
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
uint16_t depth_minus1
number of bits in the component minus 1
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
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.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define avpriv_atomic_ptr_cas
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int 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 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...
#define CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
#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)
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
planar GBRA 4:4:4:4 32bpp
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int qmax
maximum quantizer
#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)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int rc_max_rate
maximum bitrate
int64_t av_const 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.
int av_frame_get_channels(const AVFrame *frame)
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val)
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int av_buffer_realloc(AVBufferRef **buf, int size)
Reallocate a given buffer.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
void ff_thread_free(AVCodecContext *avctx)
int avpriv_lock_avformat(void)
Libavcodec external API header.
void * thread_opaque
thread opaque Can be used by execute() to store some per AVCodecContext stuff.
AVPixelFormat
Pixel format.
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.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
#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 ...
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val)
int flags
A combination of AV_PKT_FLAG values.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
uint64_t channel_layout
Audio channel layout.
uint32_t end_display_time
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.
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
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)
int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options)
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.
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.
#define FF_ARRAY_ELEMS(a)
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)
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...
Buffer to print data progressively.
static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
int bit_rate
the average bitrate
attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)
Wrapper function which calls avcodec_decode_audio4.
uint8_t * data
The data buffer.
Opaque data information usually continuous.
AVPicture pict
data+linesize for the bitmap of this subtitle.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val)
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int width
picture width / height.
attribute_deprecated int reference
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define LIBAVCODEC_VERSION_MICRO
#define CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
planar GBR 4:4:4 27bpp, little-endian
planar GBR 4:4:4 36bpp, little-endian
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
int ff_alloc_packet(AVPacket *avpkt, int size)
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
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)
int refcounted_frames
If non-zero, the decoded audio and video frames returned from avcodec_decode_video2() and avcodec_dec...
int ff_alloc_entries(AVCodecContext *avctx, int count)
#define FF_PROFILE_UNKNOWN
char * ass
0 terminated ASS/SSA compatible event line.
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.
#define LIBAVCODEC_VERSION_INT
char * stats_out
pass1 encoding statistics output buffer
static pthread_mutex_t * mutex
static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
static int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
void ff_reset_entries(AVCodecContext *avctx)
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
int sub_charenc_mode
Subtitles character encoding mode.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
int av_packet_split_side_data(AVPacket *pkt)
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
int av_codec_get_max_lowres(const AVCodec *codec)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal decoder state / flush internal buffers.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
const AVS_VideoInfo int align
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...
int frame_size
Number of samples per channel in an audio frame.
#define attribute_align_arg
AVSampleFormat
Audio Sample Formats.
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor Code outside libavcodec should access this field using: av_codec_{get,set}_codec_descriptor(avctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
planar GBR 4:4:4 42bpp, big-endian
char * sub_charenc
DTS of the last frame.
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
attribute_deprecated void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
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.
static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
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.
attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic)
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_set_dict(void *obj, struct AVDictionary **options)
Set all the options from a given dictionary on an object.
int sample_rate
samples per second
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
void avpriv_color_frame(AVFrame *frame, const int color[4])
unsigned avcodec_get_edge_width(void)
Return the amount of padding in pixels which the get_buffer callback must provide around the edge of ...
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
const char * name
short name for the profile
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
main external API structure.
static int recode_subtitle(AVCodecContext *avctx, AVPacket *outpkt, const AVPacket *inpkt)
#define FF_THREAD_FRAME
Decode more than one frame at once.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig contained in src to dst and reset src.
planar GBR 4:4:4 36bpp, big-endian
int qmin
minimum quantizer
volatile int ff_avcodec_locked
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.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
void av_frame_set_pkt_pos(AVFrame *frame, int64_t val)
attribute_deprecated int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
does needed setup of pkt_pts/pos and such for (re)get_buffer();
BYTE int const BYTE int int int height
static int utf8_check(const uint8_t *str)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
int64_t reordered_opaque
reordered opaque 64bit (generally an integer or a double precision float PTS but can be anything)...
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
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.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
av_cold void ff_dsputil_static_init(void)
void av_buffer_pool_uninit(AVBufferPool **pool)
Mark the pool as being available for freeing.
unsigned int avpriv_toupper4(unsigned int x)
enum AVColorSpace colorspace
YUV colorspace type.
rational number numerator/denominator
#define CONFIG_MEMORY_POISONING
AVFrame * coded_frame
the picture in the bitstream
Recommmends skipping the specified number of samples.
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1.
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
void 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)
AVHWAccel * ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
const int * supported_samplerates
array of supported audio samplerates, or NULL if unknown, array is terminated by 0 ...
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
const char * av_get_colorspace_name(enum AVColorSpace val)
Get the name of a colorspace.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
Usually treated as AVMEDIA_TYPE_DATA.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
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...
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.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
planar GBR 4:4:4 30bpp, big-endian
int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)
Encode an audio frame from samples into buf.
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.
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
enum AVColorRange av_frame_get_color_range(const AVFrame *frame)
Y , 16bpp, little-endian.
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
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.
#define CODEC_FLAG_EMU_EDGE
Don't draw edges.
void av_opt_free(void *obj)
Free all string and binary options in obj.
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define FF_DISABLE_DEPRECATION_WARNINGS
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
common internal api header.
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
Converts swscale x/y chroma position to AVChromaLocation.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
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...
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...
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
enum AVCodecID id
Codec implemented by the hardware accelerator.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
#define FFMPEG_CONFIGURATION
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_INVALIDDATA
#define FF_ENABLE_DEPRECATION_WARNINGS
as in Berlin toast format
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int channels
number of audio channels
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
const AVClass * priv_class
AVClass for the private context.
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
static void * avformat_mutex
int key_frame
1 -> keyframe, 0-> not
static int get_bit_rate(AVCodecContext *ctx)
Opaque data information usually sparse.
planar GBR 4:4:4 42bpp, little-endian
w32threads to pthreads wrapper
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
static struct twinvq_data tab
unsigned int byte_buffer_size
void avcodec_free_frame(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
void avcodec_register(AVCodec *codec)
Register the codec codec and initialize libavcodec.
int64_t pts_correction_last_dts
PTS of the last frame.
int frame_number
Frame counter, set by libavcodec.
void ff_frame_thread_encoder_free(AVCodecContext *avctx)
the normal 219*2^(n-8) "MPEG" YUV ranges
int64_t pts_correction_num_faulty_pts
Current statistics for PTS correction.
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
int ff_codec_close_recursive(AVCodecContext *avctx)
Call avcodec_close recursively, counterpart to avcodec_open2_recursive.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void av_frame_set_pkt_size(AVFrame *frame, int val)
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
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...
char * text
0 terminated plain UTF-8 text
8 bit with PIX_FMT_RGB32 palette
planar GBR 4:4:4 30bpp, little-endian
AVPacket * pkt
Current packet as passed into the decoder, to avoid having to pass the packet into every function...
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int(* init)(AVCodecContext *)
attribute_deprecated int type
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
#define GET_UTF8(val, GET_BYTE, ERROR)
This structure stores compressed data.
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
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.
#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
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const uint64_t * channel_layouts
array of support channel layouts, or NULL if unknown. array is terminated by 0
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...) av_printf_format(3
Append output to a string, according to a format.
A dummy ID pointing at the start of subtitle codecs.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
const AVProfile * profiles
array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} ...
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
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.
int last_audio_frame
An audio frame with less than required samples has been submitted and padded with silence...
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
attribute_deprecated int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic)
int ff_lock_avcodec(AVCodecContext *log_ctx)