[Libva] [PATCH] test/encode/avcenc:fix the bug of wrong encoded frame number

Hai Lan hai.lan at intel.com
Thu Dec 1 09:00:39 PST 2011


If we use i_p_b_frame to encode a yuv file with 500 frames, it will produce a 264 file with
502 frames. This patch can fix it.

Signed-off-by: Hai Lan <hai.lan at intel.com>
---
 test/encode/avcenc.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c
index f3ba2b1..1eae208 100644
--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -1401,7 +1401,18 @@ int main(int argc, char *argv[])
             
             fcurrent = fcurrent % (sizeof(frame_type_pattern)/sizeof(int[2]));
             fnext = (fcurrent+1) % (sizeof(frame_type_pattern)/sizeof(int[2]));
-            
+			if(f+frame_type_pattern[fnext][1]>frame_number) {
+                if ( (f % intra_period) == 0 ) {
+					encode_picture(yuv_fp, avc_fp,enc_frame_number, f, f==0, SLICE_TYPE_I, 0, f+1);
+					f++;
+					enc_frame_number++;
+				} else {
+				encode_picture(yuv_fp, avc_fp,enc_frame_number, f, f==0, SLICE_TYPE_P, 0, f+1);
+				f++;
+				enc_frame_number++;
+				}
+		} else
+		{
             if ( frame_type_pattern[fcurrent][0] == SLICE_TYPE_I ) {
                 encode_picture(yuv_fp, avc_fp,enc_frame_number, f, f==0, SLICE_TYPE_I, 0, 
                         f+frame_type_pattern[fnext][1]);
@@ -1415,8 +1426,9 @@ int main(int argc, char *argv[])
             }
  
             fcurrent++;
+		}
         }
-        printf("\r %d/%d ...", f+1, frame_number);
+        printf("\r %d/%d ...", f, frame_number);
         fflush(stdout);
     }
 
-- 
1.7.6.4



More information about the Libva mailing list