58 #if FF_API_FAST_MALLOC && CONFIG_SHARED && HAVE_SYMVER
59 FF_SYMVER(
void*,
av_fast_realloc, (
void *ptr,
unsigned int *
size,
size_t min_size),
"LIBAVCODEC_55")
64 FF_SYMVER(
void,
av_fast_malloc, (
void *ptr,
unsigned int *
size,
size_t min_size),
"LIBAVCODEC_55")
96 static int initialized = 0;
113 return codec && codec->
decode;
137 #if FF_API_SET_DIMENSIONS
171 *data = matrix_encoding;
176 #if HAVE_NEON || ARCH_PPC || HAVE_MMX
177 # define STRIDE_ALIGN 16
179 # define STRIDE_ALIGN 8
266 *width =
FFALIGN(*width, w_align);
267 *height =
FFALIGN(*height, h_align);
272 for (i = 0; i < 4; i++)
284 align =
FFMAX(linesize_align[0], linesize_align[3]);
285 linesize_align[1] <<= chroma_shift;
286 linesize_align[2] <<= chroma_shift;
287 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
288 *width =
FFALIGN(*width, align);
293 int buf_size,
int align)
295 int ch, planar, needed_size, ret = 0;
300 if (buf_size < needed_size)
314 sample_fmt, align)) < 0) {
336 int w = frame->
width;
338 int tmpsize, unaligned;
359 for (i = 0; i < 4; i++)
368 for (i = 0; i < 3 && picture.
data[i + 1]; i++)
369 size[i] = picture.
data[i + 1] - picture.
data[i];
370 size[i] = tmpsize - (picture.
data[i] - picture.
data[0]);
372 for (i = 0; i < 4; i++) {
377 if (!pool->
pools[i]) {
392 int planes = planar ? ch : 1;
405 if (!pool->
pools[0]) {
420 for (i = 0; i < 4; i++)
431 int planes = pool->
planes;
476 int h_chroma_shift, v_chroma_shift;
484 memset(pic->
data, 0,
sizeof(pic->
data));
489 for (i = 0; i < 4 && pool->
pools[i]; i++) {
490 const int h_shift = i == 0 ? 0 : h_chroma_shift;
491 const int v_shift = i == 0 ? 0 : v_chroma_shift;
531 #if FF_API_GET_BUFFER
547 #if FF_API_GET_BUFFER
577 int override_dimensions = 1;
585 override_dimensions = 0;
623 default:
return AVERROR(EINVAL);
629 #if FF_API_GET_BUFFER
662 priv->
avctx = *avctx;
663 priv->
frame = *frame;
671 #define WRAP_PLANE(ref_out, data, data_size) \
673 AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
675 ret = AVERROR(ENOMEM); \
678 ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
681 av_frame_unref(frame); \
682 ret = AVERROR(ENOMEM); \
695 if (!desc || planes <= 0) {
700 for (i = 0; i < planes; i++) {
708 planes = planar ? avctx->
channels : 1;
787 #if FF_API_GET_BUFFER
804 for (i = 0; i < count; i++) {
805 int r = func(c, (
char *)arg + i * size);
816 for (i = 0; i < count; i++) {
817 int r = func(c, arg, i, 0);
837 #if FF_API_AVFRAME_LAVC
838 void avcodec_get_frame_defaults(
AVFrame *frame)
843 memset(frame, 0,
sizeof(
AVFrame));
852 AVFrame *avcodec_alloc_frame(
void)
860 avcodec_get_frame_defaults(frame);
866 void avcodec_free_frame(
AVFrame **frame)
880 if ((!codec && !avctx->
codec)) {
884 if ((codec && avctx->
codec && codec != avctx->
codec)) {
886 "but %s passed to avcodec_open2().\n", avctx->
codec->
name, codec->
name);
890 codec = avctx->
codec;
906 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
973 avctx->
codec = codec;
1088 else if (channels != avctx->
channels) {
1090 "channel layout does not match number of channels\n");
1132 #if FF_API_DESTRUCT_PACKET
1138 if (avpkt->
size < size)
1142 #if FF_API_DESTRUCT_PACKET
1197 int *got_packet_ptr)
1202 int user_packet = !!avpkt->
data;
1204 *got_packet_ptr = 0;
1217 "with more than %d channels, but extended_data is not set.\n",
1240 frame = padded_frame;
1251 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1253 if (*got_packet_ptr) {
1266 if (!user_packet && avpkt->
size) {
1275 if (ret < 0 || !*got_packet_ptr) {
1295 int *got_packet_ptr)
1298 int user_packet = !!avpkt->
data;
1300 *got_packet_ptr = 0;
1314 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1316 if (!*got_packet_ptr)
1321 if (!user_packet && avpkt->
size) {
1330 if (ret < 0 || !*got_packet_ptr)
1364 "changes, but PARAM_CHANGE side data was sent to it.\n");
1371 flags = bytestream_get_le32(&data);
1377 avctx->
channels = bytestream_get_le32(&data);
1395 avctx->
width = bytestream_get_le32(&data);
1396 avctx->
height = bytestream_get_le32(&data);
1455 int *got_picture_ptr,
1461 *got_picture_ptr = 0;
1480 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
1494 if (*got_picture_ptr) {
1537 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, avpkt);
1538 if (ret >= 0 && *got_frame_ptr) {
1565 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, avpkt);
1600 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
1651 return experimental;
1695 int bits_per_sample;
1717 int i,
len, ret = 0;
1719 #define TAG_PRINT(x) \
1720 (((x) >= '0' && (x) <= '9') || \
1721 ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
1722 ((x) == '.' || (x) == ' '))
1724 for (i = 0; i < 4; i++) {
1725 len = snprintf(buf, buf_size,
1726 TAG_PRINT(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
1728 buf_size = buf_size > len ? buf_size - len : 0;
1737 const char *codec_name;
1738 const char *profile =
NULL;
1752 codec_name = p->
name;
1757 codec_name =
"mpeg2ts";
1764 snprintf(buf1,
sizeof(buf1),
"%s / 0x%04X", tag_buf, enc->
codec_tag);
1770 snprintf(buf, buf_size,
1774 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1777 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1782 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1790 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1791 " [PAR %d:%d DAR %d:%d]",
1793 display_aspect_ratio.
num, display_aspect_ratio.
den);
1797 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1803 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1804 ", q=%d-%d", enc->
qmin, enc->
qmax);
1808 snprintf(buf, buf_size,
1812 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1815 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1821 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1826 snprintf(buf, buf_size,
"Data: %s", codec_name);
1829 snprintf(buf, buf_size,
"Subtitle: %s", codec_name);
1832 snprintf(buf, buf_size,
"Attachment: %s", codec_name);
1835 snprintf(buf, buf_size,
"Invalid Codec type %d", enc->
codec_type);
1840 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1843 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1848 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1849 ", %d kb/s", bitrate / 1000);
1878 #define LICENSE_PREFIX "libavcodec license: "
1968 if (bps > 0 && ch > 0 && frame_bytes > 0)
1969 return (frame_bytes * 8) / (bps * ch);
1996 return 256 * sr / 245;
2001 return (480 << (sr / 22050)) / ch;
2009 case 20:
return 160;
2010 case 19:
return 144;
2011 case 29:
return 288;
2012 case 37:
return 480;
2016 case 38:
return 160;
2017 case 50:
return 240;
2022 if (frame_bytes > 0) {
2025 return 240 * (frame_bytes / 32);
2027 return 256 * (frame_bytes / 64);
2032 return frame_bytes * 8 /
bps;
2040 return (frame_bytes - 4 * ch) * 2 / ch;
2042 return (frame_bytes - 4) * 2 / ch;
2044 return (frame_bytes - 8) * 2 / ch;
2046 return (frame_bytes / 128) * 224 / ch;
2048 return (frame_bytes - 6 - ch) / ch;
2050 return (frame_bytes - 8) / ch;
2052 return (frame_bytes - 2 * ch) / ch;
2054 return 3 * frame_bytes / ch;
2056 return 6 * frame_bytes / ch;
2058 return 2 * (frame_bytes / (5 * ch));
2065 return frame_bytes / ch;
2067 return frame_bytes * 2 / ch;
2073 int blocks = frame_bytes / ba;
2076 return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8);
2078 return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
2080 return blocks * (1 + (ba - 4 * ch) * 2 / ch);
2082 return blocks * (2 + (ba - 7 * ch) * 2 / ch);
2090 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
2092 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
2094 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
2128 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
2132 #if FF_API_MISSING_SAMPLE
2137 "version to the newest one from Git. If the problem still "
2138 "occurs, it means that your file has a feature which has not "
2139 "been implemented.\n", feature);
2146 va_list argument_list;
2148 va_start(argument_list, msg);
2153 "of this file to ftp://upload.libav.org/incoming/ "
2154 "and contact the libav-devel mailing list.\n");
2156 va_end(argument_list);
2185 if (hwaccel->
id == codec_id
2186 && hwaccel->
pix_fmt == pix_fmt)
2312 for (i = 0; i < 3; i++) {
2313 uint32_t tmp = *state << 8;
2314 *state = tmp + *(p++);
2315 if (tmp == 0x100 || p == end)
2320 if (p[-1] > 1 ) p += 3;
2321 else if (p[-2] ) p += 2;
2322 else if (p[-3]|(p[-1]-1)) p++;
2329 p =
FFMIN(p, end) - 4;