test/encode/avcenc: bug fixed: B frame stream can't be decoded by JM.
authorZhou Chang <chang.zhou@intel.com>
Tue, 7 Jun 2011 02:41:38 +0000 (10:41 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Tue, 28 May 2013 08:46:47 +0000 (16:46 +0800)
Signed-off-by: Zhou Chang <chang.zhou@intel.com>
test/encode/avcenc.c

index eb6c018..0ceb303 100644 (file)
@@ -174,6 +174,8 @@ static VABufferID coded_buf;                                    /*Output buffer,
 #define SID_NUMBER                              SID_RECON_PICTURE + 1
 static  VASurfaceID surface_ids[SID_NUMBER];
 
+static int enc_frame_number;
+
 /***************************************************/
 
 static void alloc_encode_resource()
@@ -841,7 +843,7 @@ static void encode_intra_slices(FILE *yuv_fp, FILE *avc_fp, int f, int is_idr)
         begin_picture();
         prepare_input_ip(yuv_fp, 1);
         end_picture();
-        store_coded_buffer(avc_fp, f, f, SLICE_TYPE_I, is_idr);
+        store_coded_buffer(avc_fp, enc_frame_number, f, SLICE_TYPE_I, is_idr);
 }
 
 static void encode_p_slices(FILE *yuv_fp, FILE *avc_fp, int f)
@@ -849,7 +851,7 @@ static void encode_p_slices(FILE *yuv_fp, FILE *avc_fp, int f)
         begin_picture();
         prepare_input_ip(yuv_fp, 0);
         end_picture();
-        store_coded_buffer(avc_fp, f, f, SLICE_TYPE_P, 0);
+        store_coded_buffer(avc_fp, enc_frame_number, f, SLICE_TYPE_P, 0);
 }
 
 static void encode_pb_slices(FILE *yuv_fp, FILE *avc_fp, int f)
@@ -857,12 +859,12 @@ static void encode_pb_slices(FILE *yuv_fp, FILE *avc_fp, int f)
        begin_picture();
        prepare_input_pb(yuv_fp, 0);
        end_picture();
-       store_coded_buffer(avc_fp, f, f+1, SLICE_TYPE_P, 0);
+       store_coded_buffer(avc_fp, enc_frame_number, f+1, SLICE_TYPE_P, 0);
 
        begin_picture();
        prepare_input_pb(yuv_fp, 1);
        end_picture();
-       store_coded_buffer(avc_fp, f+1, f, SLICE_TYPE_B, 0);
+       store_coded_buffer(avc_fp, enc_frame_number + 1, f, SLICE_TYPE_B, 0);
 }
 
 int main(int argc, char *argv[])
@@ -919,7 +921,8 @@ int main(int argc, char *argv[])
 
     create_encode_pipe();
     alloc_encode_resource();
-
+       
+       enc_frame_number = 0;
     for ( f = 0; f < frame_number; ) {         //picture level loop
         int is_intra = (f % 30 == 0);
         int is_idr = (f == 0);
@@ -932,12 +935,15 @@ int main(int argc, char *argv[])
                if ( is_intra ) {
                        encode_intra_slices(yuv_fp, avc_fp, f, is_idr);
                        f++;
+                       enc_frame_number++;
                } else if ( is_bslice) {
                        encode_pb_slices(yuv_fp, avc_fp, f);
                        f+=2;
+                       enc_frame_number++;
                } else {
                        encode_p_slices(yuv_fp, avc_fp, f);
                        f++;
+                       enc_frame_number++;
                }
        
         printf("\r %d/%d ...", f+1, frame_number);