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 <[email protected]>
---
 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

_______________________________________________
Libva mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to