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",
854 if (avpkt->
size < size)
857 pkt_data = avpkt->
data;
858 pkt_size = avpkt->
size;
860 avpkt->
data = pkt_data;
861 avpkt->
size = pkt_size;
874 int user_packet = !!avpkt->
data;
899 ret = avctx->
codec->
encode2(avctx, avpkt, frame, got_packet_ptr);
900 if (!ret && *got_packet_ptr &&
912 int buf_size = avpkt->size;
916 buf_size = nb_samples * avctx->channels *
922 buf_size = 2 * avctx->frame_size * avctx->channels *
936 nb_samples < avctx->frame_size) {
937 fs_tmp = avctx->frame_size;
938 avctx->frame_size = nb_samples;
942 ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size,
943 frame ? frame->data[0] :
NULL);
951 if (avctx->coded_frame)
952 avpkt->pts = avctx->coded_frame->pts;
963 *got_packet_ptr = (ret > 0);
968 avctx->frame_size = fs_tmp;
971 avctx->frame_number++;
981 #if FF_API_OLD_DECODE_AUDIO
983 uint8_t *buf,
int buf_size,
989 int ret, samples_size, got_packet;
1007 "support this codec\n");
1010 nb_samples = (int64_t)buf_size * 8 /
1013 if (nb_samples >= INT_MAX)
1025 samples, samples_size, 1)))
1057 return ret ? ret : pkt.
size;
1071 int ret = avctx->
codec->
encode(avctx, buf, buf_size, pict);
1090 ret = avctx->
codec->
encode(avctx, buf, buf_size, sub);
1098 const uint8_t *
data;
1105 if (!data || size < 4)
1107 flags = bytestream_get_le32(&data);
1112 avctx->
channels = bytestream_get_le32(&data);
1130 avctx->
width = bytestream_get_le32(&data);
1131 avctx->
height = bytestream_get_le32(&data);
1138 int *got_picture_ptr,
1143 *got_picture_ptr= 0;
1155 ret = avctx->
codec->
decode(avctx, picture, got_picture_ptr,
1166 if (*got_picture_ptr)
1174 #if FF_API_OLD_DECODE_AUDIO
1176 int *frame_size_ptr,
1180 int ret, got_frame = 0;
1184 "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
1186 "avcodec_decode_audio4()\n");
1192 if (ret >= 0 && got_frame) {
1198 if (*frame_size_ptr < data_size) {
1200 "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
1206 if (planar && avctx->
channels > 1) {
1207 uint8_t *out = ((uint8_t *)samples) + plane_size;
1208 for (ch = 1; ch < avctx->
channels; ch++) {
1213 *frame_size_ptr = data_size;
1215 *frame_size_ptr = 0;
1240 ret = avctx->
codec->
decode(avctx, frame, got_frame_ptr, avpkt);
1241 if (ret >= 0 && *got_frame_ptr) {
1259 ret = avctx->
codec->
decode(avctx, sub, got_sub_ptr, avpkt);
1295 av_log(avctx,
AV_LOG_ERROR,
"insufficient thread locking around avcodec_open/close()\n");
1340 return experimental;
1386 int bits_per_sample;
1408 int i,
len, ret = 0;
1410 for (i = 0; i < 4; i++) {
1411 len = snprintf(buf, buf_size,
1412 isprint(codec_tag&0xFF) ?
"%c" :
"[%d]", codec_tag&0xFF);
1414 buf_size = buf_size > len ? buf_size - len : 0;
1423 const char *codec_name;
1424 const char *profile =
NULL;
1436 codec_name = p->
name;
1441 codec_name =
"mpeg2ts";
1448 snprintf(buf1,
sizeof(buf1),
"%s / 0x%04X", tag_buf, enc->
codec_tag);
1454 snprintf(buf, buf_size,
1458 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1461 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1466 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1474 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1475 " [PAR %d:%d DAR %d:%d]",
1477 display_aspect_ratio.
num, display_aspect_ratio.
den);
1481 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1487 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1488 ", q=%d-%d", enc->
qmin, enc->
qmax);
1492 snprintf(buf, buf_size,
1496 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1499 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1505 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1510 snprintf(buf, buf_size,
"Data: %s", codec_name);
1513 snprintf(buf, buf_size,
"Subtitle: %s", codec_name);
1516 snprintf(buf, buf_size,
"Attachment: %s", codec_name);
1519 snprintf(buf, buf_size,
"Invalid Codec type %d", enc->
codec_type);
1524 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1527 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1532 snprintf(buf + strlen(buf), buf_size - strlen(buf),
1533 ", %d kb/s", bitrate / 1000);
1562 #define LICENSE_PREFIX "libavcodec license: "
1628 #if FF_API_OLD_FF_PICT_TYPES
1629 char av_get_pict_type_char(
int pict_type){
1682 #if FF_API_OLD_SAMPLE_FMT
1683 int av_get_bits_per_sample_format(
enum AVSampleFormat sample_fmt) {
1710 for(i=0; i<size && !(
tab[i][0]==a &&
tab[i][1]==
b); i++);
1717 "version to the newest one from Git. If the problem still "
1718 "occurs, it means that your file has a feature which has not "
1719 "been implemented.\n", feature);
1726 va_list argument_list;
1728 va_start(argument_list, msg);
1733 "of this file to ftp://upload.libav.org/incoming/ "
1734 "and contact the libav-devel mailing list.\n");
1736 va_end(argument_list);
1760 if ( hwaccel->
id == codec_id
1761 && hwaccel->
pix_fmt == pix_fmt)
1807 return toupper( x &0xFF)
1808 + (toupper((x>>8 )&0xFF)<<8 )
1809 + (toupper((x>>16)&0xFF)<<16)
1810 + (toupper((x>>24)&0xFF)<<24);
1840 #if FF_API_THREAD_INIT