#include "mpegvideo.h"
#include "h263.h"
+#define FF_ME_ITER 50
+
static av_cold int encode_init(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
int i;
if(avctx->prediction_method == DWT_97
- && (avctx->flags & CODEC_FLAG_QSCALE)
+ && (avctx->flags & AV_CODEC_FLAG_QSCALE)
&& avctx->global_quality == 0){
av_log(avctx, AV_LOG_ERROR, "The 9/7 wavelet is incompatible with lossless mode.\n");
return -1;
}
+#if FF_API_MOTION_EST
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->me_method == ME_ITER)
+ s->motion_est = FF_ME_ITER;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type
- s->mv_scale = (avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4;
- s->block_max_depth= (avctx->flags & CODEC_FLAG_4MV ) ? 1 : 0;
+ s->mv_scale = (avctx->flags & AV_CODEC_FLAG_QPEL) ? 2 : 4;
+ s->block_max_depth= (avctx->flags & AV_CODEC_FLAG_4MV ) ? 1 : 0;
for(plane_index=0; plane_index<3; plane_index++){
s->plane[plane_index].diag_mc= 1;
s->max_ref_frames = av_clip(avctx->refs, 1, MAX_REF_FRAMES);
- if(avctx->flags&CODEC_FLAG_PASS1){
+ if(avctx->flags&AV_CODEC_FLAG_PASS1){
if(!avctx->stats_out)
avctx->stats_out = av_mallocz(256);
if (!avctx->stats_out)
return AVERROR(ENOMEM);
}
- if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){
+ if((avctx->flags&AV_CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){
if(ff_rate_control_init(&s->m) < 0)
return -1;
}
- s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2));
+ s->pass1_rc= !(avctx->flags & (AV_CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2));
switch(avctx->pix_fmt){
case AV_PIX_FMT_YUV444P:
if ((ret = ff_snow_get_buffer(s, s->input_picture)) < 0)
return ret;
- if(s->avctx->me_method == ME_ITER){
+ if(s->motion_est == FF_ME_ITER){
int size= s->b_width * s->b_height << 2*s->block_max_depth;
for(i=0; i<s->max_ref_frames; i++){
s->ref_mvs[i]= av_mallocz_array(size, sizeof(int16_t[2]));
s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)};
int P[10][2];
int16_t last_mv[3][2];
- int qpel= !!(s->avctx->flags & CODEC_FLAG_QPEL); //unused
+ int qpel= !!(s->avctx->flags & AV_CODEC_FLAG_QPEL); //unused
const int shift= 1+qpel;
MotionEstContext *c= &s->m.me;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int w= s->b_width;
int h= s->b_height;
- if(s->avctx->me_method == ME_ITER && !s->keyframe && search)
+ if(s->motion_est == FF_ME_ITER && !s->keyframe && search)
iterative_me(s);
for(y=0; y<h; y++){
return;
}
for(x=0; x<w; x++){
- if(s->avctx->me_method == ME_ITER || !search)
+ if(s->motion_est == FF_ME_ITER || !search)
encode_q_branch2(s, 0, x, y);
else
encode_q_branch (s, 0, x, y);
uint8_t rc_header_bak[sizeof(s->header_state)];
uint8_t rc_block_bak[sizeof(s->block_state)];
- if ((ret = ff_alloc_packet2(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + FF_MIN_BUFFER_SIZE)) < 0)
+ if ((ret = ff_alloc_packet2(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0)
return ret;
ff_init_range_encoder(c, pkt->data, pkt->size);
s->new_picture = pict;
s->m.picture_number= avctx->frame_number;
- if(avctx->flags&CODEC_FLAG_PASS2){
+ if(avctx->flags&AV_CODEC_FLAG_PASS2){
s->m.pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_number].new_pict_type;
s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I;
- if(!(avctx->flags&CODEC_FLAG_QSCALE)) {
+ if(!(avctx->flags&AV_CODEC_FLAG_QSCALE)) {
pic->quality = ff_rate_estimate_qscale(&s->m, 0);
if (pic->quality < 0)
return -1;
s->qlog = qscale2qlog(pic->quality);
s->lambda = pic->quality * 3/2;
}
- if (s->qlog < 0 || (!pic->quality && (avctx->flags & CODEC_FLAG_QSCALE))) {
+ if (s->qlog < 0 || (!pic->quality && (avctx->flags & AV_CODEC_FLAG_QSCALE))) {
s->qlog= LOSSLESS_QLOG;
s->lambda = 0;
}//else keep previous frame's qlog until after motion estimation
s->m.b8_stride= 2*s->m.mb_width+1;
s->m.f_code=1;
s->m.pict_type = pic->pict_type;
+#if FF_API_MOTION_EST
s->m.me_method= s->avctx->me_method;
+#endif
+ s->m.motion_est= s->motion_est;
s->m.me.scene_change_score=0;
s->m.me.dia_size = avctx->dia_size;
- s->m.quarter_sample= (s->avctx->flags & CODEC_FLAG_QPEL)!=0;
+ s->m.quarter_sample= (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0;
s->m.out_format= FMT_H263;
s->m.unrestricted_mv= 1;
if( plane_index==0
&& pic->pict_type == AV_PICTURE_TYPE_P
- && !(avctx->flags&CODEC_FLAG_PASS2)
+ && !(avctx->flags&AV_CODEC_FLAG_PASS2)
&& s->m.me.scene_change_score > s->avctx->scenechange_threshold){
ff_init_range_encoder(c, pkt->data, pkt->size);
ff_build_rac_states(c, (1LL<<32)/20, 256-8);
predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
}
}
- if(s->avctx->flags&CODEC_FLAG_PSNR){
+ if(s->avctx->flags&AV_CODEC_FLAG_PSNR){
int64_t error= 0;
if(pict->data[plane_index]) //FIXME gray hack
if(s->pass1_rc)
if (ff_rate_estimate_qscale(&s->m, 0) < 0)
return -1;
- if(avctx->flags&CODEC_FLAG_PASS1)
+ if(avctx->flags&AV_CODEC_FLAG_PASS1)
ff_write_pass1_stats(&s->m);
s->m.last_pict_type = s->m.pict_type;
avctx->frame_bits = s->m.frame_bits;
emms_c();
+ ff_side_data_set_encoder_stats(pkt, s->current_picture->quality,
+ s->current_picture->error,
+ (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 4 : 0,
+ s->current_picture->pict_type);
+
pkt->size = ff_rac_terminate(c);
if (s->current_picture->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
FF_MPV_COMMON_OPTS
+ { "iter", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ITER }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" },
{ "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "no_bitstream", "Skip final bitstream writeout.", OFFSET(no_bitstream), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "intra_penalty", "Penalty for intra blocks in block decission", OFFSET(intra_penalty), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },