[FFmpeg-cvslog] FRAPS: Do not needlessly use reget_buffer.

Reimar Döffinger git at videolan.org
Sun Jan 29 14:17:41 CET 2012


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sat Jan 28 23:07:54 2012 +0100| [6a9b565e0a238b475e036c2e0a77b991cb0a3efb] | committer: Reimar Döffinger

FRAPS: Do not needlessly use reget_buffer.

Codec has only I- and skip-frames, so there is no
need for reget_buffer, change it so it works with
get_buffer.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a9b565e0a238b475e036c2e0a77b991cb0a3efb
---

 libavcodec/fraps.c      |   61 +++++++++++++---------------------------------
 tests/ref/fate/fraps-v2 |    8 ------
 tests/ref/fate/fraps-v3 |    2 -
 3 files changed, 17 insertions(+), 54 deletions(-)

diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index db0e85f..d674d8e 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -167,14 +167,27 @@ static int decode_frame(AVCodecContext *avctx,
                    buf_size, needed_size);
             return -1;
         }
+        /* bit 31 means same as previous pic */
+        if (header & (1U<<31)) {
+            *data_size = 0;
+            return buf_size;
+        }
+    } else {
+        /* skip frame */
+        if (buf_size == 8) {
+            *data_size = 0;
+            return buf_size;
+        }
     }
 
     f->pict_type = AV_PICTURE_TYPE_I;
     f->key_frame = 1;
-    f->reference = 3;
-    f->buffer_hints = FF_BUFFER_HINTS_VALID |
-                      FF_BUFFER_HINTS_PRESERVE |
-                      FF_BUFFER_HINTS_REUSABLE;
+    f->reference = 0;
+    f->buffer_hints = FF_BUFFER_HINTS_VALID;
+    if (avctx->get_buffer(avctx, f)) {
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+        return -1;
+    }
 
     switch(version) {
     case 0:
@@ -186,15 +199,6 @@ static int decode_frame(AVCodecContext *avctx,
             return -1;
         }
 
-        if (avctx->reget_buffer(avctx, f)) {
-            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
-            return -1;
-        }
-        /* bit 31 means same as previous pic */
-        if (header & (1U<<31)) {
-            f->pict_type = AV_PICTURE_TYPE_P;
-            f->key_frame = 0;
-        } else {
             buf32=(const uint32_t*)buf;
             for(y=0; y<avctx->height/2; y++){
                 luma1=(uint32_t*)&f->data[0][ y*2*f->linesize[0] ];
@@ -210,25 +214,14 @@ static int decode_frame(AVCodecContext *avctx,
                     *cb++    = *buf32++;
                 }
             }
-        }
         break;
 
     case 1:
         /* Fraps v1 is an upside-down BGR24 */
-        if (avctx->reget_buffer(avctx, f)) {
-            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
-            return -1;
-        }
-        /* bit 31 means same as previous pic */
-        if (header & (1U<<31)) {
-            f->pict_type = AV_PICTURE_TYPE_P;
-            f->key_frame = 0;
-        } else {
             for(y=0; y<avctx->height; y++)
                 memcpy(&f->data[0][ (avctx->height-y)*f->linesize[0] ],
                        &buf[y*avctx->width*3],
                        3*avctx->width);
-        }
         break;
 
     case 2:
@@ -237,16 +230,6 @@ static int decode_frame(AVCodecContext *avctx,
          * Fraps v2 is Huffman-coded YUV420 planes
          * Fraps v4 is virtually the same
          */
-        if (avctx->reget_buffer(avctx, f)) {
-            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
-            return -1;
-        }
-        /* skip frame */
-        if(buf_size == 8) {
-            f->pict_type = AV_PICTURE_TYPE_P;
-            f->key_frame = 0;
-            break;
-        }
         if (AV_RL32(buf) != FPS_TAG || buf_size < planes*1024 + 24) {
             av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
             return -1;
@@ -274,16 +257,6 @@ static int decode_frame(AVCodecContext *avctx,
     case 3:
     case 5:
         /* Virtually the same as version 4, but is for RGB24 */
-        if (avctx->reget_buffer(avctx, f)) {
-            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
-            return -1;
-        }
-        /* skip frame */
-        if(buf_size == 8) {
-            f->pict_type = AV_PICTURE_TYPE_P;
-            f->key_frame = 0;
-            break;
-        }
         if (AV_RL32(buf) != FPS_TAG || buf_size < planes*1024 + 24) {
             av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
             return -1;
diff --git a/tests/ref/fate/fraps-v2 b/tests/ref/fate/fraps-v2
index 63a01f2..cbd2519 100644
--- a/tests/ref/fate/fraps-v2
+++ b/tests/ref/fate/fraps-v2
@@ -1,10 +1,2 @@
 0, 0, 1179648, 0x99f80436
-0, 3000, 1179648, 0x99f80436
-0, 6000, 1179648, 0x99f80436
-0, 9000, 1179648, 0x99f80436
-0, 12000, 1179648, 0x99f80436
 0, 15000, 1179648, 0xe8ae7a30
-0, 18000, 1179648, 0xe8ae7a30
-0, 21000, 1179648, 0xe8ae7a30
-0, 24000, 1179648, 0xe8ae7a30
-0, 27000, 1179648, 0xe8ae7a30
diff --git a/tests/ref/fate/fraps-v3 b/tests/ref/fate/fraps-v3
index ba66206..95b4454 100644
--- a/tests/ref/fate/fraps-v3
+++ b/tests/ref/fate/fraps-v3
@@ -2,8 +2,6 @@
 0, 3000, 589824, 0xcd740f79
 0, 6000, 589824, 0x16f8f90e
 0, 9000, 589824, 0x1aaaceba
-0, 12000, 589824, 0x1aaaceba
 0, 15000, 589824, 0x902e8fe4
 0, 18000, 589824, 0x019a4443
-0, 21000, 589824, 0x019a4443
 0, 24000, 589824, 0x04eff6c6



More information about the ffmpeg-cvslog mailing list