static avc_video_profile_t avc_video_get_profile (AVFormatContext *ctx, AVStream *vs, AVCodecContext *vc) { if (!vs || !vc) return AVC_VIDEO_PROFILE_INVALID; /* stupid exception to CIF15 */ if (vc->bit_rate <= 384000 && ctx->bit_rate <= 600000 && vc->width == 320 && vc->height == 240) return AVC_VIDEO_PROFILE_BL_L12_CIF15; /* CIF */ if (is_valid_video_profile (profile_cif_res, sizeof (profile_cif_res), vc)) { /* QCIF */ if (vc->bit_rate <= 128000 && ctx->bit_rate <= 256000) { if (vs->r_frame_rate.num == 15 && vs->r_frame_rate.num == 1) return AVC_VIDEO_PROFILE_BL_QCIF15; else return AVC_VIDEO_PROFILE_BL_L1B_QCIF; } /* CIF15 */ if (ctx->bit_rate <= 520000) /* 520 kbps max system bitrate */ return AVC_VIDEO_PROFILE_BL_CIF15_520; if (ctx->bit_rate <= 540000) /* 540 kbps max system bitrate */ return AVC_VIDEO_PROFILE_BL_CIF15_540; /* 384 kbps max video bitrate */ if (vc->bit_rate <= 384000 && ctx->bit_rate <= 600000) return AVC_VIDEO_PROFILE_BL_CIF15; /* CIF30 */ if (ctx->bit_rate <= 940000) /* 940 kbps max system bitrate */ return AVC_VIDEO_PROFILE_BL_CIF30_940; if (ctx->bit_rate <= 1300000) /* 1.3 Mbps kbps max system bitrate */ return AVC_VIDEO_PROFILE_BL_L2_CIF30; /* 2 Mbps max video bitrate */ if (vc->bit_rate <= 2000000 && ctx->bit_rate <= 3000000) return AVC_VIDEO_PROFILE_BL_CIF30; } /* SD */ if (vc->bit_rate <= 4000000 /* 4 Mbps max */ && is_valid_video_profile (profile_mp_l3_sd_res, sizeof (profile_mp_l3_sd_res), vc)) return AVC_VIDEO_PROFILE_BL_L3_SD; /* what is BL_L3L ?? */ if (vc->bit_rate <= 10000000 /* 10 Mbps max */ && is_valid_video_profile (profile_mp_sd_res, sizeof (profile_mp_sd_res), vc)) return AVC_VIDEO_PROFILE_MP_SD; /* HD */ if (vc->bit_rate <= 20000000) /* 20 Mbps max */ { if (is_valid_video_profile (profile_mp_hd_res, sizeof (profile_mp_hd_res), vc)) return AVC_VIDEO_PROFILE_MP_HD; /* dirty hack to support some excentric 480/720/1080(i,p) files where only one of the size is correct */ if (vc->width == 1920 || vc->width == 1280 || vc->width == 720) return AVC_VIDEO_PROFILE_MP_HD; if (vc->height == 1080 || vc->height == 720 || vc->height == 480) return AVC_VIDEO_PROFILE_MP_HD; } return AVC_VIDEO_PROFILE_INVALID; }
static mpeg4_video_profile_t mpeg4_video_get_profile (mpeg4_vcodec_type_t vctype, AVStream *vs, AVCodecContext *vc) { if (!vs || !vc) return MPEG4_VIDEO_PROFILE_INVALID; if (vctype == MPEG4_VCODEC_H263) { if (vc->bit_rate > 64000) /* max bitrate is 64 kbps */ return MPEG4_VIDEO_PROFILE_INVALID; if (is_valid_video_profile (profile_h263_res, sizeof (profile_h263_res), vs, vc)) return MPEG4_VIDEO_PROFILE_H263; return MPEG4_VIDEO_PROFILE_INVALID; } else if (vctype == MPEG4_VCODEC_P2) { if (vc->bit_rate <= 128000) /* SP_L2 and SP_L0B */ { if (is_valid_video_profile (profile_p2_sp_l0b_res, sizeof (profile_p2_sp_l0b_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_SP_L0B; if (is_valid_video_profile (profile_p2_sp_l2_res, sizeof (profile_p2_sp_l2_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_SP_L2; return MPEG4_VIDEO_PROFILE_INVALID; } else if (vc->bit_rate <= 384000) /* SP_L3 */ { if (is_valid_video_profile (profile_p2_sp_l3_co_res, sizeof (profile_p2_sp_l3_co_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_SP_L3; return MPEG4_VIDEO_PROFILE_INVALID; } else if (vc->bit_rate <= 2000000) /* CO and ASP_L4 */ { if (is_valid_video_profile (profile_p2_sp_l3_co_res, sizeof (profile_p2_sp_l3_co_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_ASP_L4; if (is_valid_video_profile (profile_p2_asp_l4_res, sizeof (profile_p2_asp_l4_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_ASP_L4; return MPEG4_VIDEO_PROFILE_INVALID; } else if (vc->bit_rate <= 3000000) /* SP_L3_VGA */ { if (is_valid_video_profile (profile_p2_sp_l3_vga_res, sizeof (profile_p2_sp_l3_vga_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_SP_L3_VGA; return MPEG4_VIDEO_PROFILE_INVALID; } else if (vc->bit_rate <= 8000000) /* ASP_L5 */ { if (is_valid_video_profile (profile_p2_asp_l5_res, sizeof (profile_p2_asp_l5_res), vs, vc)) return MPEG4_VIDEO_PROFILE_P2_ASP_L5; return MPEG4_VIDEO_PROFILE_INVALID; } return MPEG4_VIDEO_PROFILE_INVALID; } return MPEG4_VIDEO_PROFILE_INVALID; }