From d446db390a91ddbc87f9c448611fbc2df76e31ca Mon Sep 17 00:00:00 2001 From: Zhou Chang Date: Thu, 30 Jun 2011 16:15:52 +0800 Subject: [PATCH] test/encode/avcenc: Support continue B frames in test code. Signed-off-by: Zhou Chang --- test/encode/avcenc.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c index e4046f1..7f75216 100644 --- a/test/encode/avcenc.c +++ b/test/encode/avcenc.c @@ -469,9 +469,11 @@ static void end_picture(int slice_type, int next_is_bpic) surface_ids[SID_REFERENCE_PICTURE_L0] = tempID; } } else { - surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE_L0]; - surface_ids[SID_REFERENCE_PICTURE_L0] = surface_ids[SID_REFERENCE_PICTURE_L1]; - surface_ids[SID_REFERENCE_PICTURE_L1] = tempID; + if (!next_is_bpic) { + surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE_L0]; + surface_ids[SID_REFERENCE_PICTURE_L0] = surface_ids[SID_REFERENCE_PICTURE_L1]; + surface_ids[SID_REFERENCE_PICTURE_L1] = tempID; + } } avcenc_destroy_buffers(&avcenc_context.seq_param_buf_id, 1); @@ -1013,15 +1015,23 @@ static void encode_p_picture(FILE *yuv_fp, FILE *avc_fp, int f) SLICE_TYPE_P, 0); } -static void encode_pb_pictures(FILE *yuv_fp, FILE *avc_fp, int f) +static void encode_pb_pictures(FILE *yuv_fp, FILE *avc_fp, int f, int nbframes) { + int i; encode_picture(yuv_fp, avc_fp, - enc_frame_number, f + 1, + enc_frame_number, f + nbframes, 0, SLICE_TYPE_P, 1); + for( i = 0; i < nbframes - 1; i++) { + encode_picture(yuv_fp, avc_fp, + enc_frame_number + 1, f + i, + 0, + SLICE_TYPE_B, 1); + } + encode_picture(yuv_fp, avc_fp, - enc_frame_number + 1, f, + enc_frame_number + 1, f + nbframes - 1, 0, SLICE_TYPE_B, 0); } @@ -1223,8 +1233,8 @@ int main(int argc, char *argv[]) f++; enc_frame_number++; } else if ( is_bslice) { - encode_pb_pictures(yuv_fp, avc_fp, f); - f+=2; + encode_pb_pictures(yuv_fp, avc_fp, f, 2); //last parameter is continue B frames number + f += (1 + 2); enc_frame_number++; } else { encode_p_picture(yuv_fp, avc_fp, f); -- 2.7.4