#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>
/* encoder management */
AVCodec *first_avcodec = NULL;
+AVCodec *av_codec_next(AVCodec *c){
+ if(c) return c->next;
+ else return first_avcodec;
+}
+
void register_avcodec(AVCodec *format)
{
AVCodec **p;
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ444P:
+ case PIX_FMT_YUVA420P:
w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
h_align= 16;
break;
buf->last_pic_num= *picture_number;
}else{
int h_chroma_shift, v_chroma_shift;
- int pixel_size, size[3];
+ 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];
- if(picture.data[2])
- size[1]= size[2]= size[1]/2;
- else
- size[2]= 0;
+ 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));
memset(buf->data, 0, sizeof(buf->data));
- for(i=0; i<3 && size[i]; i++){
+ for(i=0; i<4 && size[i]; i++){
const int h_shift= i==0 ? 0 : h_chroma_shift;
const int v_shift= i==0 ? 0 : v_chroma_shift;
FFSWAP(InternalBuffer, *buf, *last);
- for(i=0; i<3; i++){
+ for(i=0; i<4; i++){
pic->data[i]=NULL;
// pic->base[i]=NULL;
}
{"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"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, 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},
{"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, INT_MIN, INT_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"},
{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
{"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;
goto end;
}
- if(avctx->codec)
+ if(avctx->codec || !codec)
goto end;
if (codec->priv_data_size > 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;
return -1;
}
if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
- *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
- *frame_size_ptr < buf_size){
+ *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){
av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
return -1;
}
#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;
char buf1[32];
char channels_str[100];
int bitrate;
+ AVRational display_aspect_ratio;
if (encode)
p = avcodec_find_encoder(enc->codec_id);
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %dx%d",
enc->width, enc->height);
- if(av_log_level >= AV_LOG_DEBUG){
+ 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),
", %d/%d",
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
+ case CODEC_ID_PCM_S16LE_PLANAR:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
bitrate = enc->sample_rate * enc->channels * 16;
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;
return LIBAVCODEC_BUILD;
}
-static void init_crcs(void){
-#if LIBAVUTIL_VERSION_INT < (50<<16)
- av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257);
- av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257);
- av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257);
-#endif
- av_crc_init(av_crc04C11DB7, 0, 32, 0x04c11db7, sizeof(AVCRC)*257);
- av_crc_init(av_crc8005 , 0, 16, 0x8005 , sizeof(AVCRC)*257);
- av_crc_init(av_crc07 , 0, 8, 0x07 , sizeof(AVCRC)*257);
-}
-
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();
- init_crcs();
}
void avcodec_flush_buffers(AVCodecContext *avctx)
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 '?';
}
}
return 8;
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_S16LE_PLANAR:
case CODEC_ID_PCM_U16BE:
case CODEC_ID_PCM_U16LE:
return 16;