60 min_size=
FFMAX(17*min_size/16 + 32, min_size);
76 min_size=
FFMAX(17*min_size/16 + 32, min_size);
79 if (!*p) min_size = 0;
91 #if !FF_API_AVCODEC_INIT
96 static int initialized = 0;
112 return codec && codec->
decode;
140 #define INTERNAL_BUFFER_SIZE (32+1)
219 *width =
FFALIGN(*width , w_align);
220 *height=
FFALIGN(*height, h_align);
236 linesize_align[i] = 16;
246 align =
FFMAX(linesize_align[0], linesize_align[3]);
247 linesize_align[1] <<= chroma_shift;
248 linesize_align[2] <<= chroma_shift;
249 align =
FFMAX3(align, linesize_align[1], linesize_align[2]);
255 int buf_size,
int align)
257 int ch, planar, needed_size, ret = 0;
262 if (buf_size < needed_size)
276 sample_fmt, align)) < 0) {
364 "internal audio buffer used\n", frame);
409 int h_chroma_shift, v_chroma_shift;
435 unaligned |= picture.
linesize[i] % stride_align[i];
443 for (i=0; i<3 && picture.
data[i+1]; i++)
444 size[i] = picture.
data[i+1] - picture.
data[i];
445 size[i] = tmpsize - (picture.
data[i] - picture.
data[0]);
447 memset(buf->
base, 0,
sizeof(buf->
base));
448 memset(buf->
data, 0,
sizeof(buf->
data));
450 for(i=0; i<4 && size[i]; i++){
451 const int h_shift= i==0 ? 0 : h_chroma_shift;
452 const int v_shift= i==0 ? 0 : v_chroma_shift;
458 memset(buf->
base[i], 128, size[i]);
470 if(size[1] && !size[2])
526 assert(i < avci->buffer_count);
586 for(i=0; i<count; i++){
587 int r= func(c, (
char*)arg + i*size);
596 for(i=0; i<count; i++){
597 int r= func(c, arg, i, 0);
610 memset(pic, 0,
sizeof(
AVFrame));
628 #if FF_API_AVCODEC_OPEN
643 if ((!codec && !avctx->
codec)) {
647 if ((codec && avctx->
codec && codec != avctx->
codec)) {
649 "but %s passed to avcodec_open2().\n", avctx->
codec->
name, codec->
name);
653 codec = avctx->
codec;
669 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
717 #define SANE_NB_CHANNELS 128U
723 avctx->
codec = codec;
742 avctx->
err_recognition |= (1<<(avctx->error_recognition-(avctx->error_recognition>=FF_ER_VERY_AGGRESSIVE))) - 1;
763 av_log(avctx,
AV_LOG_ERROR,
"The maximum value for lowres supported by the decoder is %d\n",
851 if (avpkt->
size < size)
854 pkt_data = avpkt->
data;
855 pkt_size = avpkt->
size;
857 avpkt->
data = pkt_data;
858 avpkt->
size = pkt_size;
871 int user_packet = !!avpkt->
data;
896 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
897 if (!ret && *got_packet_ptr &&
909 int buf_size = avpkt->size;
913 buf_size = nb_samples * avctx->channels *
919 buf_size = 2 * avctx->frame_size * avctx->channels *
933 nb_samples < avctx->frame_size) {
934 fs_tmp = avctx->frame_size;
935 avctx->frame_size = nb_samples;
939 ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size,
940 frame ? frame->data[0] :
NULL);
948 if (avctx->coded_frame)
949 avpkt->pts = avctx->coded_frame->pts;
960 *got_packet_ptr = (ret > 0);
965 avctx->frame_size = fs_tmp;
968 avctx->frame_number++;
978 #if FF_API_OLD_DECODE_AUDIO
980 uint8_t *buf,
int buf_size,
986 int ret, samples_size, got_packet;
1004 "support this codec\n");
1007 nb_samples = (int64_t)buf_size * 8 /
1010 if (nb_samples >= INT_MAX)
1022 samples, samples_size, 1)))
1054 return ret ? ret : pkt.
size;
1068 int ret = avctx->
codec->
encode(avctx, buf, buf_size, pict);
1087 ret = avctx->
codec->
encode(avctx, buf, buf_size, sub);
1095 const uint8_t *
data;
1102 if (!data || size < 4)
1104 flags = bytestream_get_le32(&data);
1109 avctx->
channels = bytestream_get_le32(&data);
1127 avctx->
width = bytestream_get_le32(&data);
1128 avctx->
height = bytestream_get_le32(&data);
1135 int *got_picture_ptr,
1140 *got_picture_ptr= 0;
1152 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
1163 if (*got_picture_ptr)
1171 #if FF_API_OLD_DECODE_AUDIO
1173 int *frame_size_ptr,
1177 int ret, got_frame = 0;
1181 "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
1183 "avcodec_decode_audio4()\n");
1189 if (ret >= 0 && got_frame) {
1195 if (*frame_size_ptr < data_size) {
1197 "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
1203 if (planar && avctx->
channels > 1) {
1204 uint8_t *out = ((uint8_t *)samples) + plane_size;
1205 for (ch = 1; ch < avctx->
channels; ch++) {
1210 *frame_size_ptr = data_size;
1212 *frame_size_ptr = 0;
1237 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, avpkt);
1238 if (ret >= 0 && *got_frame_ptr) {
1256 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, avpkt);
1292 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
1337 return experimental;
1383 int bits_per_sample;
1405 int i,
len, ret = 0;
1407 for (i = 0; i < 4; i++) {
1408 len = snprintf(buf, buf_size,
1409 isprint(codec_tag&0xFF) ?
"%c" :
"[%d]", codec_tag&0xFF);
1411 buf_size = buf_size > len ? buf_size - len : 0;
1420 const char *codec_name;
1421 const char *profile =
NULL;
1433 codec_name = p->
name;
1438 codec_name =
"mpeg2ts";
1445 snprintf(buf1,
sizeof(buf1),
"%s / 0x%04X", tag_buf, enc->
codec_tag);
1451 snprintf(buf, buf_size,
1455 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1458 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1463 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1471 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1472 " [PAR %d:%d DAR %d:%d]",
1474 display_aspect_ratio.
num, display_aspect_ratio.
den);
1478 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1484 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1485 ", q=%d-%d", enc->
qmin, enc->
qmax);
1489 snprintf(buf, buf_size,
1493 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1496 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1502 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1507 snprintf(buf, buf_size,
"Data: %s", codec_name);
1510 snprintf(buf, buf_size,
"Subtitle: %s", codec_name);
1513 snprintf(buf, buf_size,
"Attachment: %s", codec_name);
1516 snprintf(buf, buf_size,
"Invalid Codec type %d", enc->
codec_type);
1521 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1524 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1529 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1530 ", %d kb/s", bitrate / 1000);
1559 #define LICENSE_PREFIX "libavcodec license: "
1625 #if FF_API_OLD_FF_PICT_TYPES
1626 char av_get_pict_type_char(
int pict_type){
1679 #if FF_API_OLD_SAMPLE_FMT
1680 int av_get_bits_per_sample_format(
enum AVSampleFormat sample_fmt) {
1707 for(i=0; i<size && !(
tab[i][0]==a &&
tab[i][1]==
b); i++);
1714 "version to the newest one from Git. If the problem still "
1715 "occurs, it means that your file has a feature which has not "
1716 "been implemented.\n", feature);
1723 va_list argument_list;
1725 va_start(argument_list, msg);
1730 "of this file to ftp://upload.libav.org/incoming/ "
1731 "and contact the libav-devel mailing list.\n");
1733 va_end(argument_list);
1757 if ( hwaccel->
id == codec_id
1758 && hwaccel->
pix_fmt == pix_fmt)
1804 return toupper( x &0xFF)
1805 + (toupper((x>>8 )&0xFF)<<8 )
1806 + (toupper((x>>16)&0xFF)<<16)
1807 + (toupper((x>>24)&0xFF)<<24);
1837 #if FF_API_THREAD_INIT