From 6168962660c1183244cf3c5377c969181669119a Mon Sep 17 00:00:00 2001 From: Zhou Chang Date: Tue, 7 Jun 2011 10:41:38 +0800 Subject: [PATCH] test/encode/avcenc: bug fixed: B frame stream can't be decoded by JM. Signed-off-by: Zhou Chang --- test/encode/avcenc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c index eb6c018..0ceb303 100644 --- a/test/encode/avcenc.c +++ b/test/encode/avcenc.c @@ -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); -- 2.7.4