]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/jvdec.c
vdpau: add a constructor for AVVDPAUContext.
[ffmpeg] / libavcodec / jvdec.c
index 2a7b52cd627744acd44fcf9a5b2300659c653fb2..6b82c6a45bd419c6d2cf7a924c644b332862003d 100644 (file)
@@ -28,6 +28,7 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "get_bits.h"
+#include "internal.h"
 #include "libavutil/intreadwrite.h"
 
 typedef struct JvContext {
@@ -40,7 +41,7 @@ typedef struct JvContext {
 static av_cold int decode_init(AVCodecContext *avctx)
 {
     JvContext *s = avctx->priv_data;
-    avctx->pix_fmt = PIX_FMT_PAL8;
+    avctx->pix_fmt = AV_PIX_FMT_PAL8;
     ff_dsputil_init(&s->dsp, avctx);
     return 0;
 }
@@ -129,23 +130,23 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC
 }
 
 static int decode_frame(AVCodecContext *avctx,
-                        void *data, int *data_size,
+                        void *data, int *got_frame,
                         AVPacket *avpkt)
 {
     JvContext *s           = avctx->priv_data;
     int buf_size           = avpkt->size;
     const uint8_t *buf     = avpkt->data;
     const uint8_t *buf_end = buf + buf_size;
-    int video_size, video_type, i, j;
+    int video_size, video_type, i, j, ret;
 
     video_size = AV_RL32(buf);
     video_type = buf[4];
     buf += 5;
 
     if (video_size) {
-        if (avctx->reget_buffer(avctx, &s->frame) < 0) {
+        if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) {
             av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-            return -1;
+            return ret;
         }
 
         if (video_type == 0 || video_type == 1) {
@@ -185,8 +186,9 @@ static int decode_frame(AVCodecContext *avctx,
         s->palette_has_changed       = 0;
         memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
 
-        *data_size      = sizeof(AVFrame);
-        *(AVFrame*)data = s->frame;
+        if ((ret = av_frame_ref(data, &s->frame)) < 0)
+            return ret;
+        *got_frame = 1;
     }
 
     return buf_size;
@@ -196,8 +198,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 {
     JvContext *s = avctx->priv_data;
 
-    if(s->frame.data[0])
-        avctx->release_buffer(avctx, &s->frame);
+    av_frame_unref(&s->frame);
 
     return 0;
 }