#define QUALITY_THRESHOLD 100
#define THRESHOLD_MULTIPLIER 0.6
-#if HAVE_ALTIVEC
-#undef vector
-#endif
-
static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *decoded, int stride, int level, int threshold, int lambda, int intra){
int count, y, x, i, j, split, best_mean, best_score, best_count;
int best_vector[6];
}
best_count=0;
- best_score -= ((block_sum[0]*block_sum[0])>>(level+3));
+ best_score -= (int)(((unsigned)block_sum[0]*block_sum[0])>>(level+3));
best_mean= (block_sum[0] + (size>>1)) >> (level+3);
if(level<4){
int mx, my, pred_x, pred_y, dxy;
int16_t *motion_ptr;
- motion_ptr= h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y);
+ motion_ptr= ff_h263_pred_motion(&s->m, 0, 0, &pred_x, &pred_y);
if(s->m.mb_type[x + y*s->m.mb_stride]&CANDIDATE_MB_TYPE_INTER){
for(i=0; i<6; i++)
init_put_bits(&s->reorder_pb[i], reorder_buffer[1][i], 7*32);
s->rd_total += score[best];
for(i=5; i>=0; i--){
- ff_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]);
+ avpriv_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]);
}
if(best==0){
s->dsp.put_pixels_tab[0][0](decoded, temp, stride, 16);
{
SVQ1Context * const s = avctx->priv_data;
- dsputil_init(&s->dsp, avctx);
- avctx->coded_frame= (AVFrame*)&s->picture;
+ ff_dsputil_init(&s->dsp, avctx);
+ avctx->coded_frame = &s->picture;
s->frame_width = avctx->width;
s->frame_height = avctx->height;
s->avctx= avctx;
s->m.avctx= avctx;
+ s->m.picture_structure = PICT_FRAME;
s->m.me.temp =
s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->mb_type = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int16_t));
s->dummy = av_mallocz((s->y_block_width+1)*s->y_block_height*sizeof(int32_t));
- h263_encode_init(&s->m); //mv_penalty
+ ff_h263_encode_init(&s->m); //mv_penalty
return 0;
}
-static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf,
- int buf_size, void *data)
+static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pict, int *got_packet)
{
SVQ1Context * const s = avctx->priv_data;
- AVFrame *pict = data;
- AVFrame * const p= (AVFrame*)&s->picture;
+ AVFrame * const p = &s->picture;
AVFrame temp;
- int i;
+ int i, ret;
+
+ if (!pkt->data &&
+ (ret = av_new_packet(pkt, s->y_block_width*s->y_block_height*MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE) < 0)) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+ return ret;
+ }
if(avctx->pix_fmt != PIX_FMT_YUV410P){
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
s->current_picture= s->last_picture;
s->last_picture= temp;
- init_put_bits(&s->pb, buf, buf_size);
+ init_put_bits(&s->pb, pkt->data, pkt->size);
*p = *pict;
p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
return -1;
}
-// align_put_bits(&s->pb);
+// avpriv_align_put_bits(&s->pb);
while(put_bits_count(&s->pb) & 31)
put_bits(&s->pb, 1, 0);
flush_put_bits(&s->pb);
- return put_bits_count(&s->pb) / 8;
+ pkt->size = put_bits_count(&s->pb) / 8;
+ if (p->pict_type == AV_PICTURE_TYPE_I)
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
}
static av_cold int svq1_encode_end(AVCodecContext *avctx)
AVCodec ff_svq1_encoder = {
- "svq1",
- AVMEDIA_TYPE_VIDEO,
- CODEC_ID_SVQ1,
- sizeof(SVQ1Context),
- svq1_encode_init,
- svq1_encode_frame,
- svq1_encode_end,
- .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV410P, PIX_FMT_NONE},
- .long_name= NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
+ .name = "svq1",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_SVQ1,
+ .priv_data_size = sizeof(SVQ1Context),
+ .init = svq1_encode_init,
+ .encode2 = svq1_encode_frame,
+ .close = svq1_encode_end,
+ .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV410P, PIX_FMT_NONE },
+ .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
};