PyMODINIT_FUNC ATTK_INIT_FUNC(void) { PyObject *m; #ifdef DEBUG printf("ATTK_INIT_FUNC (%s) START\n", MAKE_STR(ATTK_INIT_FUNC)); #endif if (PyType_Ready(&AttackClass) < 0) return; m = Py_InitModule3(ATTK_MODULE_NAME, attk_plug_methods, ATTK_MODULE_DOC); build_dict(m, "init_args", attk_data_init_args_d); build_dict(m, "start_args", attk_start_args_d); Py_INCREF(&AttackClass); PyModule_AddObject(m, "attack_class", (PyObject *)&AttackClass); }
int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *audio_data_conf) { AVDictionary *opts = NULL; audio_output_file->fifo = av_fifo_alloc(2 * MAX_AUDIO_PACKET_SIZE); audio_output_file->aframe = FF_ALLOC_FRAME(); audio_output_file->adata_buf = (uint8_t*) av_malloc(2 * MAX_AUDIO_PACKET_SIZE); #ifndef GPAC_USE_LIBAV audio_output_file->aframe->channels = -1; #endif #ifndef LIBAV_FRAME_OLD audio_output_file->aframe->channel_layout = 0; audio_output_file->aframe->sample_rate = -1; #endif audio_output_file->aframe->format = -1; audio_output_file->codec = avcodec_find_encoder_by_name(audio_data_conf->codec); if (audio_output_file->codec == NULL) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Output audio codec not found\n")); return -1; } audio_output_file->codec_ctx = avcodec_alloc_context3(audio_output_file->codec); audio_output_file->codec_ctx->codec_id = audio_output_file->codec->id; audio_output_file->codec_ctx->codec_type = AVMEDIA_TYPE_AUDIO; audio_output_file->codec_ctx->bit_rate = audio_data_conf->bitrate; audio_output_file->codec_ctx->sample_rate = DC_AUDIO_SAMPLE_RATE /*audio_data_conf->samplerate*/; { AVRational time_base; time_base.num = 1; time_base.den = audio_output_file->codec_ctx->sample_rate; audio_output_file->codec_ctx->time_base = time_base; } audio_output_file->codec_ctx->channels = audio_data_conf->channels; audio_output_file->codec_ctx->channel_layout = AV_CH_LAYOUT_STEREO; /*FIXME: depends on channels -> http://ffmpeg.org/doxygen/trunk/channel__layout_8c_source.html#l00074*/ audio_output_file->codec_ctx->sample_fmt = audio_output_file->codec->sample_fmts[0]; #ifdef DC_AUDIO_RESAMPLER audio_output_file->aresampler = NULL; #endif if (audio_data_conf->custom) { build_dict(audio_output_file->codec_ctx->priv_data, audio_data_conf->custom); } audio_output_file->astream_idx = 0; /* open the audio codec */ av_dict_set(&opts, "strict", "experimental", 0); if (avcodec_open2(audio_output_file->codec_ctx, audio_output_file->codec, &opts) < 0) { /*FIXME: if we enter here (set "mp2" as a codec and "200000" as a bitrate -> deadlock*/ GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output audio codec\n")); av_dict_free(&opts); return -1; } av_dict_free(&opts); audio_output_file->frame_bytes = audio_output_file->codec_ctx->frame_size * av_get_bytes_per_sample(DC_AUDIO_SAMPLE_FORMAT) * DC_AUDIO_NUM_CHANNELS; #ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(audio_output_file->aframe); #else av_frame_unref(audio_output_file->aframe); #endif audio_output_file->aframe->nb_samples = audio_output_file->codec_ctx->frame_size; if (avcodec_fill_audio_frame(audio_output_file->aframe, audio_output_file->codec_ctx->channels, audio_output_file->codec_ctx->sample_fmt, audio_output_file->adata_buf, audio_output_file->codec_ctx->frame_size * av_get_bytes_per_sample(audio_output_file->codec_ctx->sample_fmt) * audio_output_file->codec_ctx->channels, 1) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Fill audio frame failed\n")); return -1; } //audio_output_file->acc_samples = 0; return 0; }
int dc_video_encoder_open(VideoOutputFile *video_output_file, VideoDataConf *video_data_conf, Bool use_source_timing) { video_output_file->vbuf_size = 9 * video_data_conf->width * video_data_conf->height + 10000; video_output_file->vbuf = (uint8_t *) av_malloc(video_output_file->vbuf_size); // video_output_file->codec = avcodec_find_encoder_by_name("libx264"/*video_data_conf->codec*/); video_output_file->codec = avcodec_find_encoder(CODEC_ID_H264); if (video_output_file->codec == NULL) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Output video codec %d not found\n", CODEC_ID_H264)); return -1; } video_output_file->codec_ctx = avcodec_alloc_context3(video_output_file->codec); //Create new video stream // video_stream = avformat_new_stream(video_output_file->av_fmt_ctx, video_codec); // if (!video_stream) { // GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create output video stream\n")); // return -1; // } video_output_file->codec_ctx->codec_id = video_output_file->codec->id; video_output_file->codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; video_output_file->codec_ctx->bit_rate = video_data_conf->bitrate; video_output_file->codec_ctx->width = video_data_conf->width; video_output_file->codec_ctx->height = video_data_conf->height; video_output_file->codec_ctx->time_base.num = 1; video_output_file->codec_ctx->time_base.den = video_output_file->gop_size ? video_output_file->gop_size : video_data_conf->framerate; video_output_file->use_source_timing = use_source_timing; if (use_source_timing) { //for avcodec to do rate allcoation, we need to have ctx->timebase == 1/framerate video_output_file->codec_ctx->time_base.den = video_data_conf->time_base.den; video_output_file->codec_ctx->time_base.num = video_data_conf->time_base.num * video_data_conf->time_base.den / video_data_conf->framerate; } video_output_file->codec_ctx->pix_fmt = PIX_FMT_YUV420P; video_output_file->codec_ctx->gop_size = video_data_conf->framerate; // video_output_file->codec_ctx->codec_id = video_codec->id; // video_output_file->codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; // video_output_file->codec_ctx->bit_rate = video_data_conf->bitrate; // video_output_file->codec_ctx->width = video_data_conf->width; // video_output_file->codec_ctx->height = video_data_conf->height; // video_output_file->codec_ctx->time_base = (AVRational) {1 , // video_output_file->video_data_conf->framerate}; // video_output_file->codec_ctx->codec->pix_fmt = PIX_FMT_YUV420P; video_output_file->codec_ctx->gop_size = video_data_conf->framerate; // // av_opt_set(video_output_file->codec_ctx->priv_data, "preset", "ultrafast", 0); // av_opt_set(video_output_file->codec_ctx->priv_data, "tune", "zerolatency", 0); /* video_output_file->codec_ctx->max_b_frames = 0; video_output_file->codec_ctx->thread_count = 1; video_output_file->codec_ctx->delay = 0; video_output_file->codec_ctx->rc_lookahead = 0; */ /* * video_stream->codec->gosize = video_output_file->vfr; * videoStream->codec->gosize = 1; * video_stream->codec->rc_lookahead = 0; * videoStream->time_base = (AVRational) {1 , 1000000}; * videoStream->r_frame_rate = (AVRational) {outVideoCtx->video_framerate, 1}; * av_opt_set(videoStream->codec->priv_data, "preset", "slow", 0); * videoStream->codec->me_range = 16; * videoStream->codec->max_qdiff = 4; * videoStream->codec->qmin = 10; * videoStream->codec->qmax = 51; * videoStream->codec->qcompress = 0.6; * videoStream->codec->profile = FF_PROFILE_H264_BASELINE; * videoStream->codec->level = 10; * */ if (video_data_conf->custom) { build_dict(video_output_file->codec_ctx->priv_data, video_data_conf->custom); gf_free(video_data_conf->custom); video_data_conf->custom = NULL; } else { GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("Video Encoder: applying default options (preset=ultrafast tune=zerolatency)\n")); av_opt_set(video_output_file->codec_ctx->priv_data, "preset", "ultrafast", 0); av_opt_set(video_output_file->codec_ctx->priv_data, "tune", "zerolatency", 0); } if (video_output_file->gdr) { av_opt_set_int(video_output_file->codec_ctx->priv_data, "intra-refresh", 1, 0); av_opt_set_int(video_output_file->codec_ctx->priv_data, "key-int", video_output_file->gdr, 0); } // if (video_output_file->av_fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) //the global header gives access to the extradata (SPS/PPS) video_output_file->codec_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; // if (video_output_file->av_fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) // video_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; video_output_file->vstream_idx = 0;//video_stream->index; /* open the video codec - options are passed thru video_output_file->codec_ctx->priv_data */ if (avcodec_open2(video_output_file->codec_ctx, video_output_file->codec, NULL) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video codec\n")); return -1; } // /* open the video codec */ // if (avcodec_open2(video_stream->codec, video_codec, NULL) < 0) { // GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video codec\n")); // return -1; // } video_output_file->rep_id = video_data_conf->filename; return 0; }
void menu_enter(){ ///\fn void menu_enter() ///\brief Selectarea optiunii. /// ///Implementarea selectarii dorite in cadrul unei optiunilor din menu. system("cls"); // se ia fiecare caz de meniu si fiecare caz de element de meniu in parte. switch(current_menu){ // main menu case 0 : { switch (highlighted_item){ case 0 : {//input one word one_word(); break; } case 1 : {//From file from_file(); break; } case 2 : {//Live live_input(); break; } case 3 : {//options-menu current_menu = 1; highlighted_item = 0; break; } case 4 : {//Exit printf("\n\n\tGood bye!"); Sleep(750); exit(0); break; } } break; } //options-menu case 1 : { switch (highlighted_item){ case 0 : {//Update words apparitions update_app_words(); break; } case 1 : {//Insert an word to dictionary insert_word(); break; } case 2 : {//Delete an word from dictionary delete_word(); break; } case 3 : {//Reset dictionary reset_dict(); break; } case 4 : {//Build dictionary from file build_dict(); break; } case 5 : {//Add words to dictionary from file update_words(); break; } case 6 : {//select_suggestions_funcition current_menu = 2; highlighted_item = sugg_funct; break; } case 7 : {//back current_menu = 0; highlighted_item = 0; break; } } break; } //select suggestion functions case 2 : { switch (highlighted_item){ case 0 : {//leven sugg_funct = 0; break; } case 1 : {//leven 2.0 sugg_funct = 1; break; } case 2 : {//back current_menu = 1; highlighted_item = 0; break; } } } } print_menu(); Sleep(50); }