58 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
77 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
111 static int initialized = 0;
113 if (initialized != 0)
127 return codec && codec->
decode;
157 #define INTERNAL_BUFFER_SIZE (32 + 1)
160 int linesize_align[AV_NUM_DATA_POINTERS])
239 *width =
FFALIGN(*width, w_align);
240 *height =
FFALIGN(*height, h_align);
245 for (i = 0; i < 4; i++)
257 align =
FFMAX(linesize_align[0], linesize_align[3]);
258 linesize_align[1] <<= chroma_shift;
259 linesize_align[2] <<= chroma_shift;
260 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
261 *width =
FFALIGN(*width, align);
266 int buf_size,
int align)
268 int ch, planar, needed_size, ret = 0;
273 if (buf_size < needed_size)
287 sample_fmt, align)) < 0) {
317 frame->
data[0], buf_size, 0);
326 "internal audio buffer used\n", frame);
366 int h_chroma_shift, v_chroma_shift;
393 for (i = 0; i < 4; i++)
394 unaligned |= picture.
linesize[i] % stride_align[i];
401 for (i = 0; i < 3 && picture.
data[i + 1]; i++)
402 size[i] = picture.
data[i + 1] - picture.
data[i];
403 size[i] = tmpsize - (picture.
data[i] - picture.
data[0]);
405 memset(buf->
base, 0,
sizeof(buf->
base));
406 memset(buf->
data, 0,
sizeof(buf->
data));
408 for (i = 0; i < 4 && size[i]; i++) {
409 const int h_shift = i == 0 ? 0 : h_chroma_shift;
410 const int v_shift = i == 0 ? 0 : v_chroma_shift;
417 memset(buf->
base[i], 128, size[i]);
429 if (size[1] && !size[2])
478 default:
return AVERROR(EINVAL);
505 assert(i < avci->buffer_count);
569 for (i = 0; i < count; i++) {
570 int r = func(c, (
char *)arg + i * size);
581 for (i = 0; i < count; i++) {
582 int r = func(c, arg, i, 0);
607 memset(frame, 0,
sizeof(
AVFrame));
632 if (!frame || !*frame)
651 if ((!codec && !avctx->
codec)) {
655 if ((codec && avctx->
codec && codec != avctx->
codec)) {
657 "but %s passed to avcodec_open2().\n", avctx->
codec->
name, codec->
name);
661 codec = avctx->
codec;
677 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
730 avctx->
codec = codec;
845 else if (channels != avctx->
channels) {
847 "channel layout does not match number of channels\n");
886 if (avpkt->
size < size)
952 int user_packet = !!avpkt->
data;
967 "with more than %d channels, but extended_data is not set.\n",
990 frame = padded_frame;
1001 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1003 if (*got_packet_ptr) {
1016 if (!user_packet && avpkt->
size) {
1019 avpkt->
data = new_data;
1025 if (ret < 0 || !*got_packet_ptr) {
1047 #if FF_API_OLD_ENCODE_AUDIO
1055 int ret, samples_size, got_packet;
1059 pkt.
size = buf_size;
1072 av_log(avctx, AV_LOG_ERROR,
"avcodec_encode_audio() does not "
1073 "support this codec\n");
1076 nb_samples = (int64_t)buf_size * 8 /
1079 if (nb_samples >= INT_MAX)
1123 return ret ? ret : pkt.
size;
1128 #if FF_API_OLD_ENCODE_VIDEO
1133 int ret, got_packet = 0;
1135 if (buf_size < FF_MIN_BUFFER_SIZE) {
1136 av_log(avctx, AV_LOG_ERROR,
"buffer smaller than minimum size\n");
1142 pkt.
size = buf_size;
1159 return ret ? ret : pkt.
size;
1167 int *got_packet_ptr)
1170 int user_packet = !!avpkt->
data;
1172 *got_packet_ptr = 0;
1186 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
1188 if (!*got_packet_ptr)
1193 if (!user_packet && avpkt->
size) {
1196 avpkt->
data = new_data;
1202 if (ret < 0 || !*got_packet_ptr)
1234 if (!data || size < 4)
1236 flags = bytestream_get_le32(&data);
1241 avctx->
channels = bytestream_get_le32(&data);
1259 avctx->
width = bytestream_get_le32(&data);
1260 avctx->
height = bytestream_get_le32(&data);
1267 int *got_picture_ptr,
1272 *got_picture_ptr = 0;
1286 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
1300 if (*got_picture_ptr)
1312 #if FF_API_OLD_DECODE_AUDIO
1314 int *frame_size_ptr,
1318 int ret, got_frame = 0;
1321 av_log(avctx, AV_LOG_ERROR,
"Custom get_buffer() for use with"
1322 "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
1323 av_log(avctx, AV_LOG_ERROR,
"Please port your application to "
1324 "avcodec_decode_audio4()\n");
1330 if (ret >= 0 && got_frame) {
1336 if (*frame_size_ptr < data_size) {
1337 av_log(avctx, AV_LOG_ERROR,
"output buffer size is too small for "
1338 "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
1344 if (planar && avctx->
channels > 1) {
1346 for (ch = 1; ch < avctx->
channels; ch++) {
1351 *frame_size_ptr = data_size;
1353 *frame_size_ptr = 0;
1365 int planar, channels;
1382 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, avpkt);
1383 if (ret >= 0 && *got_frame_ptr) {
1410 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, avpkt);
1445 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
1491 return experimental;
1535 int bits_per_sample;
1557 int i,
len, ret = 0;
1559 for (i = 0; i < 4; i++) {
1560 len = snprintf(buf, buf_size,
1561 isprint(codec_tag & 0xFF) ?
"%c" :
"[%d]", codec_tag & 0xFF);
1563 buf_size = buf_size > len ? buf_size - len : 0;
1572 const char *codec_name;
1573 const char *profile =
NULL;
1587 codec_name = p->
name;
1592 codec_name =
"mpeg2ts";
1599 snprintf(buf1,
sizeof(buf1),
"%s / 0x%04X", tag_buf, enc->
codec_tag);
1605 snprintf(buf, buf_size,
1609 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1612 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1617 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1625 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1626 " [PAR %d:%d DAR %d:%d]",
1628 display_aspect_ratio.
num, display_aspect_ratio.
den);
1632 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1638 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1639 ", q=%d-%d", enc->
qmin, enc->
qmax);
1643 snprintf(buf, buf_size,
1647 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1650 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1656 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1661 snprintf(buf, buf_size,
"Data: %s", codec_name);
1664 snprintf(buf, buf_size,
"Subtitle: %s", codec_name);
1667 snprintf(buf, buf_size,
"Attachment: %s", codec_name);
1670 snprintf(buf, buf_size,
"Invalid Codec type %d", enc->
codec_type);
1675 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1678 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1683 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1684 ", %d kb/s", bitrate / 1000);
1713 #define LICENSE_PREFIX "libavcodec license: "
1738 for (j = 0; j < 4; j++) {
1841 if (bps > 0 && ch > 0 && frame_bytes > 0)
1842 return (frame_bytes * 8) / (bps * ch);
1869 return 256 * sr / 245;
1874 return (480 << (sr / 22050)) / ch;
1882 case 20:
return 160;
1883 case 19:
return 144;
1884 case 29:
return 288;
1885 case 37:
return 480;
1889 case 38:
return 160;
1890 case 50:
return 240;
1895 if (frame_bytes > 0) {
1898 return 240 * (frame_bytes / 32);
1900 return 256 * (frame_bytes / 64);
1905 return frame_bytes * 8 /
bps;
1913 return (frame_bytes - 4 * ch) * 2 / ch;
1915 return (frame_bytes - 4) * 2 / ch;
1917 return (frame_bytes - 8) * 2 / ch;
1919 return (frame_bytes / 128) * 224 / ch;
1921 return (frame_bytes - 6 - ch) / ch;
1923 return (frame_bytes - 8) / ch;
1925 return (frame_bytes - 2 * ch) / ch;
1927 return 3 * frame_bytes / ch;
1929 return 6 * frame_bytes / ch;
1931 return 2 * (frame_bytes / (5 * ch));
1938 return frame_bytes / ch;
1940 return frame_bytes * 2 / ch;
1946 int blocks = frame_bytes / ba;
1949 return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8);
1951 return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
1953 return blocks * (1 + (ba - 4 * ch) * 2 / ch);
1955 return blocks * (2 + (ba - 7 * ch) * 2 / ch);
1963 return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
1965 return frame_bytes / ((
FFALIGN(ch, 2) *
bps) / 8);
1967 return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
2001 for (i = 0; i < size && !(
tab[i][0] == a &&
tab[i][1] ==
b); i++) ;
2008 "version to the newest one from Git. If the problem still "
2009 "occurs, it means that your file has a feature which has not "
2010 "been implemented.\n", feature);
2017 va_list argument_list;
2019 va_start(argument_list, msg);
2024 "of this file to ftp://upload.libav.org/incoming/ "
2025 "and contact the libav-devel mailing list.\n");
2027 va_end(argument_list);
2051 if (hwaccel->
id == codec_id
2052 && hwaccel->
pix_fmt == pix_fmt)
2097 return toupper(x & 0xFF)
2098 + (toupper((x >> 8) & 0xFF) << 8)
2099 + (toupper((x >> 16) & 0xFF) << 16)
2100 + (toupper((x >> 24) & 0xFF) << 24);