Beispiel #1
0
static int enc_set_br(MSFilter *f, void*data){
	int br=*(int*)data;
	EncState *s=(EncState*)f->data;
	MSVideoSize vsize;
	float fps;
	float codecbr=(float)br;
	vsize.width=s->tinfo.width;
	vsize.height=s->tinfo.height;
	fps=s->tinfo.fps_numerator;
	s->tinfo.target_bitrate=codecbr*0.9;
	s->tinfo.keyframe_data_target_bitrate=codecbr;
	/*those default settings would need to be affined*/
	if (br>=1024000){
		vsize.width = MS_VIDEO_SIZE_4CIF_W;
		vsize.height = MS_VIDEO_SIZE_4CIF_H;
		s->tinfo.quality=15;
		fps=30;
	}else if (br>=512000){
		vsize.width = MS_VIDEO_SIZE_CIF_W;
		vsize.height = MS_VIDEO_SIZE_CIF_H;
		s->tinfo.quality=15;
		fps=15;
	}else if (br>=256000){
		vsize.width = MS_VIDEO_SIZE_CIF_W;
		vsize.height = MS_VIDEO_SIZE_CIF_H;
		s->tinfo.quality=5;
		fps=15;
	}else if(br>=128000){
		vsize.width=MS_VIDEO_SIZE_QCIF_W;
		vsize.height=MS_VIDEO_SIZE_QCIF_H;
		s->tinfo.quality=20;
		fps=10;
	}else if(br>=64000){
		vsize.width=MS_VIDEO_SIZE_QCIF_W;
		vsize.height=MS_VIDEO_SIZE_QCIF_H;
		s->tinfo.quality=7;
		fps=7;
	}
	enc_set_vsize(f,&vsize);
	enc_set_fps(f,&fps);
	return 0;
}
Beispiel #2
0
void app_mp_video_control()
{
	if(g_video_control_handle == NULL) {
		ERR_PRN("g_video_control_handle is not init\n");
		return ;
	}

	int channel = 0;
	int enc_chid = 0;
	VideoEnodeInfo *info = NULL;
	int scale, outwidth, outheight, width, height, input, high_stream;

	input = high_stream = outwidth = outheight = scale = width = height = -1;


	for(channel = CHANNEL_INPUT_MP; channel < MAX_CHANNEL; channel++) {
		channel_get_input_info(channel, &input, &high_stream);
		PRINTF("channel = %d \n", channel);
		mid_mutex_lock(g_video_control_handle->mutex[channel]);
		info = &(g_video_control_handle->info[channel]);
		enc_chid = channel_get_enc_chid(channel);

		if(enc_chid < 0) {
			ERR_PRN("enc_chid = %d is invaid\n", enc_chid);
			mid_mutex_unlock(g_video_control_handle->mutex[channel]);
			return ;
		}

		PRINTF("info->scbr=%d,fps=%d,bitrate=%d\n", info->scbr, info->framerate, info->bitrate);

		int framerate = check_video_fps(input, (info->framerate));

		if(info->scbr == 0) {
			PRINTF("WARNING ... \n");
			enc_set_fps(gEnc2000.encLink.link_id, enc_chid,
			            (framerate), (info->quality) * 100 * 1100);
		} else {
			enc_set_fps(gEnc2000.encLink.link_id, enc_chid,
			            (framerate) , (info->bitrate) * 1100);
		}

		//set gop
		enc_set_interval(gEnc2000.encLink.link_id, enc_chid, (info->gop));
		mid_mutex_unlock(g_video_control_handle->mutex[channel]);

		//---------
		outwidth = outheight = scale = width = height = -1;
		app_get_scale_status(channel, &scale, &outwidth, &outheight);

		if(scale == LOCK_SCALE) {
			capture_get_input_hw(input, &width, &height);

			if(height == 540 && width == 1920) {
				height = height * 2;
			}

			PRINTF("the %d channel is lock scale ,scale widht=%d,hight=%d\n", channel, outwidth, outheight);
			mp_set_resolution(input, high_stream, outwidth, outheight, width, height);
		} else {
			if(CHANNEL_INPUT_MP == channel) {
				mp_set_resolution(input, high_stream, 1920, 1080, 1920, 1080);
			} else {
				mp_set_resolution(input, high_stream, 352, 288, 1920, 1080);
			}

			PRINTF("the %d channle is not lock scale\n", channel);
		}
	}

	return ;
}