Browse code

rpza: use the AVFrame API properly.

Anton Khirnov authored on 2013/11/09 18:14:46
Showing 1 changed files
... ...
@@ -46,7 +46,7 @@
46 46
 typedef struct RpzaContext {
47 47
 
48 48
     AVCodecContext *avctx;
49
-    AVFrame frame;
49
+    AVFrame *frame;
50 50
 
51 51
     const unsigned char *buf;
52 52
     int size;
... ...
@@ -72,7 +72,7 @@ typedef struct RpzaContext {
72 72
 static void rpza_decode_stream(RpzaContext *s)
73 73
 {
74 74
     int width = s->avctx->width;
75
-    int stride = s->frame.linesize[0] / 2;
75
+    int stride = s->frame->linesize[0] / 2;
76 76
     int row_inc = stride - 4;
77 77
     int stream_ptr = 0;
78 78
     int chunk_size;
... ...
@@ -82,7 +82,7 @@ static void rpza_decode_stream(RpzaContext *s)
82 82
     unsigned short color4[4];
83 83
     unsigned char index, idx;
84 84
     unsigned short ta, tb;
85
-    unsigned short *pixels = (unsigned short *)s->frame.data[0];
85
+    unsigned short *pixels = (unsigned short *)s->frame->data[0];
86 86
 
87 87
     int row_ptr = 0;
88 88
     int pixel_ptr = 0;
... ...
@@ -239,7 +239,9 @@ static av_cold int rpza_decode_init(AVCodecContext *avctx)
239 239
     s->avctx = avctx;
240 240
     avctx->pix_fmt = AV_PIX_FMT_RGB555;
241 241
 
242
-    avcodec_get_frame_defaults(&s->frame);
242
+    s->frame = av_frame_alloc();
243
+    if (!s->frame)
244
+        return AVERROR(ENOMEM);
243 245
 
244 246
     return 0;
245 247
 }
... ...
@@ -256,14 +258,14 @@ static int rpza_decode_frame(AVCodecContext *avctx,
256 256
     s->buf = buf;
257 257
     s->size = buf_size;
258 258
 
259
-    if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) {
259
+    if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
260 260
         av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
261 261
         return ret;
262 262
     }
263 263
 
264 264
     rpza_decode_stream(s);
265 265
 
266
-    if ((ret = av_frame_ref(data, &s->frame)) < 0)
266
+    if ((ret = av_frame_ref(data, s->frame)) < 0)
267 267
         return ret;
268 268
 
269 269
     *got_frame      = 1;
... ...
@@ -276,7 +278,7 @@ static av_cold int rpza_decode_end(AVCodecContext *avctx)
276 276
 {
277 277
     RpzaContext *s = avctx->priv_data;
278 278
 
279
-    av_frame_unref(&s->frame);
279
+    av_frame_free(&s->frame);
280 280
 
281 281
     return 0;
282 282
 }