changeset 2009:b13a25ac9f0c libavcodec

buffer hints, use reget_buffer, removed copy from previous frame
author rtognimp
date Fri, 07 May 2004 21:34:33 +0000
parents fc54b7be8448
children ad1a92c2db48
files cinepak.c
diffstat 1 files changed, 9 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/cinepak.c	Fri May 07 21:10:52 2004 +0000
+++ b/cinepak.c	Fri May 07 21:34:33 2004 +0000
@@ -57,7 +57,6 @@
     AVCodecContext *avctx;
     DSPContext dsp;
     AVFrame frame;
-    AVFrame prev_frame;
 
     unsigned char *data;
     int size;
@@ -125,7 +124,7 @@
     uint8_t         *eod = (data + size);
     uint32_t         flag, mask;
     cvid_codebook_t *codebook;
-    unsigned int     i, j, x, y;
+    unsigned int     x, y;
     uint32_t         iy[4];
     uint32_t         iu[2];
     uint32_t         iv[2];
@@ -250,22 +249,6 @@
                     }
 
                 }
-            } else {
-                /* copy from the previous frame */
-                for (i = 0; i < 4; i++) {
-                    for (j = 0; j < 4; j++) {
-                        s->frame.data[0][iy[i] + j] =
-                            s->prev_frame.data[0][iy[i] + j];
-                    }
-                }
-                for (i = 0; i < 2; i++) {
-                    for (j = 0; j < 2; j++) {
-                        s->frame.data[1][iu[i] + j] =
-                            s->prev_frame.data[1][iu[i] + j];
-                        s->frame.data[2][iv[i] + j] =
-                            s->prev_frame.data[2][iv[i] + j];
-                    }
-                }
             }
 
             iy[0] += 4;  iy[1] += 4;
@@ -397,7 +380,7 @@
     avctx->has_b_frames = 0;
     dsputil_init(&s->dsp, avctx);
 
-    s->frame.data[0] = s->prev_frame.data[0] = NULL;
+    s->frame.data[0] = NULL;
 
     return 0;
 }
@@ -411,19 +394,16 @@
     s->data = buf;
     s->size = buf_size;
 
-    if (avctx->get_buffer(avctx, &s->frame)) {
-        av_log(avctx, AV_LOG_ERROR, "  Cinepak: get_buffer() failed\n");
+    s->frame.reference = 1;
+    s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
+                            FF_BUFFER_HINTS_REUSABLE;
+    if (avctx->reget_buffer(avctx, &s->frame)) {
+        av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
         return -1;
     }
 
     cinepak_decode(s);
 
-    if (s->prev_frame.data[0])
-        avctx->release_buffer(avctx, &s->prev_frame);
-
-    /* shuffle frames */
-    s->prev_frame = s->frame;
-
     *data_size = sizeof(AVFrame);
     *(AVFrame*)data = s->frame;
 
@@ -435,8 +415,8 @@
 {
     CinepakContext *s = (CinepakContext *)avctx->priv_data;
 
-    if (s->prev_frame.data[0])
-        avctx->release_buffer(avctx, &s->prev_frame);
+    if (s->frame.data[0])
+        avctx->release_buffer(avctx, &s->frame);
 
     return 0;
 }