Example #1
0
void add_text_to_book(char *filename,int odst)
  {
  FILE *txt;
  ENCFILE fl;

  set_font(H_FKNIHA,NOSHADOW(0));
  if (all_text == NULL) all_text = create_list(256);
  txt = enc_open(filename,&fl);
  if (txt == NULL) return;
  seek_section(txt,odst);
  read_text(txt);
  next_line(1000);
  enc_close(&fl);
  }
int32_t CEncoder::Initialize()
{
	if (g_enc_opt.m_VideoDisable == 0)
	{
		sprintf(video_codec_name, "%ls", g_enc_opt.m_VideoCodec);
		video_bit_rate = g_enc_opt.m_VideoBitrate;
		video_width = g_enc_opt.m_VideoWidth;
		video_height = g_enc_opt.m_VideoHeight;
	}

	if (g_enc_opt.m_AudioDisable == 0)
	{
		sprintf(audio_codec_name, "%ls", g_enc_opt.m_AudioCodec);
		audio_bit_rate = g_enc_opt.m_AudioBitrate;
		audio_sample_rate = g_enc_opt.m_AudioSampleRate;
		audio_channels = g_enc_opt.m_AudioChannels;
	}

	check_options();

	if (enc_open() != 0) return -1;

	if (InterlockedCompareExchange(&g_enc_opt.m_EncInfo, 1, 0) == 0)
	{
		if (g_enc_opt.m_VideoDisable == 0)
		{
			switch(frame_pix_fmt)
			{
			case AV_PIX_FMT_BGR0:
				g_enc_opt.m_EncPixFormat = AV_PIX_FMT_BGRA;
				break;

			default:
				g_enc_opt.m_EncPixFormat = frame_pix_fmt;
				break;
			}
			
			g_enc_opt.m_EncVideoPlanes = av_pix_fmt_count_planes(frame_pix_fmt);
			av_image_fill_linesizes(g_enc_opt.m_EncVideoStride, frame_pix_fmt, g_enc_opt.m_VideoWidth);

			const AVPixFmtDescriptor *dsc = av_pix_fmt_desc_get(frame_pix_fmt);
			g_enc_opt.m_EncVideoHeight[0] = g_enc_opt.m_VideoHeight;
			g_enc_opt.m_EncVideoChromaH = dsc->log2_chroma_h;
			for(int i = 1; i < g_enc_opt.m_EncVideoPlanes; i++)
			{
				g_enc_opt.m_EncVideoHeight[i] = g_enc_opt.m_VideoHeight >> dsc->log2_chroma_h;
			}
		}
		else
		{
			g_enc_opt.m_EncPixFormat = 0;
		}
		if (g_enc_opt.m_AudioDisable == 0)
		{
			g_enc_opt.m_EncAudioFormat = audio_sample_fmt;
			g_enc_opt.m_EncAudioSampleRate = audio_sample_rate;
			g_enc_opt.m_EncAudioChannels = audio_channels;
			g_enc_opt.m_EncAudioChannelLayout = audio_channel_layout;
			if (audio_channels > 1)
			{
				g_enc_opt.m_EncAudioIsPlanar = av_sample_fmt_is_planar(audio_sample_fmt);
			}
			else
			{

				g_enc_opt.m_EncAudioIsPlanar = 0;
			}

			if (g_enc_opt.m_EncAudioIsPlanar)
			{
				g_enc_opt.m_EncAudioPacketBytes = av_get_bytes_per_sample(audio_sample_fmt);
			}
			else
			{
				g_enc_opt.m_EncAudioPacketBytes = av_get_bytes_per_sample(audio_sample_fmt) * g_enc_opt.m_EncAudioChannels;
			}
		}
		else
		{
			g_enc_opt.m_EncAudioFormat = 0;
		}
	}