#include "avcodec.h"
#include "dsputil.h"
-#include "mpegvideo.h"
#include "integer.h"
#include "opt.h"
#include "crc.h"
+#include "imgconvert.h"
#include <stdarg.h>
#include <limits.h>
#include <float.h>
*size= FFMAX(17*min_size/16 + 32, min_size);
- return av_realloc(ptr, *size);
+ ptr= av_realloc(ptr, *size);
+ if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now
+ *size= 0;
+
+ return ptr;
}
static unsigned int last_static = 0;
buf->last_pic_num= *picture_number;
}else{
int h_chroma_shift, v_chroma_shift;
- int pixel_size, size[4];
+ int size[4] = {0};
+ int tmpsize;
AVPicture picture;
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
}
avcodec_align_dimensions(s, &w, &h);
- avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
- pixel_size= picture.linesize[0]*8 / w;
-//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", (int)picture.data[1], w, h, s->pix_fmt);
- assert(pixel_size>=1);
- //FIXME next ensures that linesize= 2^x uvlinesize, that is needed because some MC code assumes it
- if(pixel_size == 3*8)
- w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift);
- else
- w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size;
- size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
- size[0] = picture.linesize[0] * h;
- size[1] -= size[0];
- size[2] = size[3] = 0;
- if(picture.data[2])
- size[1]= size[2]= size[1]/2;
- if(picture.data[3])
- size[3] = picture.linesize[3] * h;
+ ff_fill_linesize(&picture, s->pix_fmt, w);
+
+ for (i=0; i<4; i++)
+ picture.linesize[i] = ALIGN(picture.linesize[i], STRIDE_ALIGN);
+
+ tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
+
+ for (i=0; i<3 && picture.data[i+1]; i++)
+ size[i] = picture.data[i+1] - picture.data[i];
+ size[i] = tmpsize - (picture.data[i] - picture.data[0]);
buf->last_pic_num= -256*256*256*64;
memset(buf->base, 0, sizeof(buf->base));
{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|E},
{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, 64*1000, INT_MIN, INT_MAX, A|E},
{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, 1, INT_MAX, V|E},
-{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|A|E|D, "flags"},
+{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, 0, UINT_MAX, V|A|E|D, "flags"},
{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_OBMC, INT_MIN, INT_MAX, V|E, "flags"},
{"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QPEL, INT_MIN, INT_MAX, V|E, "flags"},
{"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
{"inofficial", "allow inofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
{"experimental", "allow non standardized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"b_qoffset", "qp offset between p and b frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
+{"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
{"er", "set error resilience strategy", OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, A|V|D, "er"},
{"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
{"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|E},
{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E},
-{"i_qfactor", "qp factor between p and i frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
-{"i_qoffset", "qp offset between p and i frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
+{"i_qfactor", "qp factor between P and I frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
+{"i_qoffset", "qp offset between P and I frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
{"dct", "DCT algorithm", OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
{"auto", "autoselect a good one (default)", 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
{"vp3", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_VP3, INT_MIN, INT_MAX, V|E|D, "idct"},
{"ipp", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_IPP, INT_MIN, INT_MAX, V|E|D, "idct"},
{"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_XVIDMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
+{"faani", "floating point AAN IDCT", 0, FF_OPT_TYPE_CONST, FF_IDCT_FAAN, INT_MIN, INT_MAX, V|D|E, "idct"},
{"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"ec", "set error concealment strategy", OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, 3, INT_MIN, INT_MAX, V|D, "ec"},
{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
{"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|A|E|D, "flags2"},
+{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR, 0, UINT_MAX, V|A|E|D, "flags2"},
{"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
+{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
{NULL},
};
#undef D
#undef DEFAULT
-static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
+static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType codec_type){
int flags=0;
int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
int ret;
int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
int ret;
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
- uint8_t *buf, int buf_size){
+ const uint8_t *buf, int buf_size){
*frame_size_ptr= AVCODEC_MAX_AUDIO_FRAME_SIZE;
return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size);
}
*got_sub_ptr = 0;
ret = avctx->codec->decode(avctx, sub, got_sub_ptr,
- (uint8_t *)buf, buf_size);
+ buf, buf_size);
if (*got_sub_ptr)
avctx->frame_number++;
return ret;
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %dx%d",
enc->width, enc->height);
- av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
- enc->width*enc->sample_aspect_ratio.num,
- enc->height*enc->sample_aspect_ratio.den,
- 1024*1024);
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- " [PAR %d:%d DAR %d:%d]",
- enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
- display_aspect_ratio.num, display_aspect_ratio.den);
+ if (enc->sample_aspect_ratio.num) {
+ av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
+ enc->width*enc->sample_aspect_ratio.num,
+ enc->height*enc->sample_aspect_ratio.den,
+ 1024*1024);
+ snprintf(buf + strlen(buf), buf_size - strlen(buf),
+ " [PAR %d:%d DAR %d:%d]",
+ enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
+ display_aspect_ratio.num, display_aspect_ratio.den);
+ }
if(av_log_get_level() >= AV_LOG_DEBUG){
int g= ff_gcd(enc->time_base.num, enc->time_base.den);
snprintf(buf + strlen(buf), buf_size - strlen(buf),
snprintf(buf, buf_size, "Subtitle: %s", codec_name);
bitrate = enc->bit_rate;
break;
+ case CODEC_TYPE_ATTACHMENT:
+ snprintf(buf, buf_size, "Attachment: %s", codec_name);
+ bitrate = enc->bit_rate;
+ break;
default:
snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
return;
void avcodec_init(void)
{
- static int inited = 0;
+ static int initialized = 0;
- if (inited != 0)
+ if (initialized != 0)
return;
- inited = 1;
+ initialized = 1;
dsputil_static_init();
}
char av_get_pict_type_char(int pict_type){
switch(pict_type){
- case I_TYPE: return 'I';
- case P_TYPE: return 'P';
- case B_TYPE: return 'B';
- case S_TYPE: return 'S';
- case SI_TYPE:return 'i';
- case SP_TYPE:return 'p';
- default: return '?';
+ case FF_I_TYPE: return 'I';
+ case FF_P_TYPE: return 'P';
+ case FF_B_TYPE: return 'B';
+ case FF_S_TYPE: return 'S';
+ case FF_SI_TYPE:return 'i';
+ case FF_SP_TYPE:return 'p';
+ case FF_BI_TYPE:return 'b';
+ default: return '?';
}
}