]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/truemotion2.c
dsputil: Move RV40-specific bits into rv40dsp
[ffmpeg] / libavcodec / truemotion2.c
index 5d9408d1667163c266eea7779a7746f042999cd7..888692435bff85ed3910bf9598b8fde531f23dd2 100644 (file)
@@ -24,6 +24,8 @@
  * Duck TrueMotion2 decoder.
  */
 
+#include <inttypes.h>
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "get_bits.h"
@@ -58,7 +60,7 @@ enum TM2_BLOCKS {
 
 typedef struct TM2Context {
     AVCodecContext *avctx;
-    AVFrame pic;
+    AVFrame *pic;
 
     GetBitContext gb;
     DSPContext dsp;
@@ -231,7 +233,8 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
     case TM2_NEW_HEADER_MAGIC:
         return 0;
     default:
-        av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic);
+        av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08"PRIX32"\n",
+               magic);
         return AVERROR_INVALIDDATA;
     }
 }
@@ -838,7 +841,7 @@ static int decode_frame(AVCodecContext *avctx,
     TM2Context * const l = avctx->priv_data;
     const uint8_t *buf   = avpkt->data;
     int buf_size         = avpkt->size & ~3;
-    AVFrame * const p    = &l->pic;
+    AVFrame * const p    = l->pic;
     int offset           = TM2_HEADER_SIZE;
     int i, t, ret;
     uint8_t *swbuf;
@@ -883,7 +886,7 @@ static int decode_frame(AVCodecContext *avctx,
 
     l->cur = !l->cur;
     *got_frame      = 1;
-    ret = av_frame_ref(data, &l->pic);
+    ret = av_frame_ref(data, l->pic);
     av_free(swbuf);
 
     return (ret < 0) ? ret : buf_size;
@@ -900,9 +903,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
     }
 
     l->avctx       = avctx;
-    avcodec_get_frame_defaults(&l->pic);
     avctx->pix_fmt = AV_PIX_FMT_BGR24;
 
+    l->pic = av_frame_alloc();
+    if (!l->pic)
+        return AVERROR(ENOMEM);
+
     ff_dsputil_init(&l->dsp, avctx);
 
     l->last  = av_malloc(4 * sizeof(*l->last)  * (w >> 2));
@@ -952,7 +958,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 static av_cold int decode_end(AVCodecContext *avctx)
 {
     TM2Context * const l = avctx->priv_data;
-    AVFrame *pic = &l->pic;
     int i;
 
     av_free(l->last);
@@ -968,7 +973,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
         av_free(l->V2_base);
     }
 
-    av_frame_unref(pic);
+    av_frame_free(&l->pic);
 
     return 0;
 }