*/
typedef struct Msvideo1EncContext {
AVCodecContext *avctx;
- AVFrame pic;
AVLFG rnd;
uint8_t *prev;
const AVFrame *pict, int *got_packet)
{
Msvideo1EncContext * const c = avctx->priv_data;
- AVFrame * const p = &c->pic;
+ const AVFrame *p = pict;
uint16_t *src;
uint8_t *prevptr;
uint8_t *dst, *buf;
int no_skips = 1;
int i, j, k, x, y, ret;
int skips = 0;
+ int quality = 24;
if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0)
return ret;
dst= buf= pkt->data;
- *p = *pict;
if(!c->prev)
c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
if(c->keyint >= avctx->keyint_min)
keyframe = 1;
- p->quality = 24;
for(y = 0; y < avctx->height; y += 4){
for(x = 0; x < avctx->width; x += 4){
bestscore += t*t;
}
}
- bestscore /= p->quality;
+ bestscore /= quality;
}
// try to find optimal value to fill whole 4x4 block
score = 0;
}
}
}
- score /= p->quality;
+ score /= quality;
score += 2;
if(score < bestscore){
bestscore = score;
}
}
}
- score /= p->quality;
+ score /= quality;
score += 6;
if(score < bestscore){
bestscore = score;
}
}
}
- score /= p->quality;
+ score /= quality;
score += 18;
if(score < bestscore){
bestscore = score;
c->keyint = 0;
else
c->keyint++;
- p->pict_type= keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
- p->key_frame= keyframe;
if (keyframe) pkt->flags |= AV_PKT_FLAG_KEY;
pkt->size = dst - buf;
*got_packet = 1;
return -1;
}
- avcodec_get_frame_defaults(&c->pic);
- avctx->coded_frame = (AVFrame*)&c->pic;
avctx->bits_per_coded_sample = 16;
c->keyint = avctx->keyint_min;