]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/zmbvenc.c
avcodec/zmbvenc: Simplify setting keyframe flag
[ffmpeg] / libavcodec / zmbvenc.c
index 48871758e0a488e0b14ded59b0f1df669a74dfc7..68618f77e9412141d9dcc57f2e5bf6db3d88b826 100644 (file)
@@ -180,12 +180,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     c->curfrm++;
     if(c->curfrm == c->keyint)
         c->curfrm = 0;
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
-    avctx->coded_frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
-    avctx->coded_frame->key_frame = keyframe;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 
     palptr = (avctx->pix_fmt == AV_PIX_FMT_PAL8) ? (uint32_t *)p->data[1] : NULL;
     chpal = !keyframe && palptr && memcmp(palptr, c->pal2, 1024);
@@ -240,8 +234,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 tprev = prev + x * c->bypp;
 
                 zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored);
-                mv[0] = (mx << 1) | !!xored;
-                mv[1] = my << 1;
+                mv[0] = (mx * 2) | !!xored;
+                mv[1] = my * 2;
                 tprev += mx * c->bypp + my * c->pstride;
                 if(xored){
                     for(j = 0; j < bh2; j++){
@@ -294,10 +288,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
         *buf++ = c->fmt; // format
         *buf++ = ZMBV_BLOCK; // block width
         *buf++ = ZMBV_BLOCK; // block height
+        pkt->flags |= AV_PKT_FLAG_KEY;
     }
     memcpy(buf, c->comp_buf, c->zstream.total_out);
 
-    pkt->flags |= AV_PKT_FLAG_KEY*keyframe;
     *got_packet = 1;
 
     return 0;
@@ -409,7 +403,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
      */
     c->pstride = FFALIGN((avctx->width + c->lrange) * c->bypp, 16);
     prev_size = FFALIGN(c->lrange * c->bypp, 16) + c->pstride * (c->lrange + avctx->height + c->urange);
-    prev_offset = FFALIGN(c->lrange, 16) + c->pstride * c->lrange;
+    prev_offset = FFALIGN(c->lrange * c->bypp, 16) + c->pstride * c->lrange;
     if (!(c->prev_buf = av_mallocz(prev_size))) {
         av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
         return AVERROR(ENOMEM);
@@ -428,7 +422,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec ff_zmbv_encoder = {
+const AVCodec ff_zmbv_encoder = {
     .name           = "zmbv",
     .long_name      = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
     .type           = AVMEDIA_TYPE_VIDEO,