#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>
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));
{"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"},
{"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;
#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);
+ 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,
" [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;
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, AV_CRC_32_IEEE, sizeof(AVCRC)*257);
- av_crc_init(av_crc8005 , 0, 16, AV_CRC_16 , sizeof(AVCRC)*257);
- av_crc_init(av_crc07 , 0, 8, AV_CRC_8_ATM , 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 '?';
}
}