9 #include "interlacemodes.h"
12 #include "mwindow.inc"
14 #include "videodevice.inc"
21 FileMPEG::FileMPEG(Asset *asset, File *file)
22 : FileBase(asset, file)
25 // May also be VMPEG or AMPEG if write status.
26 if(asset->format == FILE_UNKNOWN) asset->format = FILE_MPEG;
27 asset->byte_order = 0;
35 void FileMPEG::get_parameters(BC_WindowBase *parent_window,
37 BC_WindowBase* &format_window,
41 if(audio_options && asset->format == FILE_AMPEG)
43 MPEGConfigAudio *window = new MPEGConfigAudio(parent_window, asset);
44 format_window = window;
45 window->create_objects();
50 if(video_options && asset->format == FILE_VMPEG)
52 MPEGConfigVideo *window = new MPEGConfigVideo(parent_window, asset);
53 format_window = window;
54 window->create_objects();
60 int FileMPEG::check_sig(Asset *asset)
62 return mpeg3_check_sig(asset->path);
65 int FileMPEG::reset_parameters_derived()
73 toolame_allocation = 0;
80 lame_output_allocation = 0;
86 // Just create the Quicktime objects since this routine is also called
88 int FileMPEG::open_file(int rd, int wr)
96 if(!(fd = mpeg3_open(asset->path)))
98 printf("FileMPEG::open_file %s\n", asset->path);
103 mpeg3_set_cpus(fd, file->cpus);
104 mpeg3_set_mmx(fd, 0);
106 asset->audio_data = mpeg3_has_audio(fd);
107 if(asset->audio_data)
110 for(int i = 0; i < mpeg3_total_astreams(fd); i++)
112 asset->channels += mpeg3_audio_channels(fd, i);
114 if(!asset->sample_rate)
115 asset->sample_rate = mpeg3_sample_rate(fd, 0);
116 asset->audio_length = mpeg3_audio_samples(fd, 0);
119 asset->video_data = mpeg3_has_video(fd);
120 if(asset->video_data)
122 asset->layers = mpeg3_total_vstreams(fd);
123 asset->width = mpeg3_video_width(fd, 0);
124 asset->height = mpeg3_video_height(fd, 0);
125 asset->interlace_mode = BC_ILACE_MODE_UNDETECTED; // TODO: (to do this, start at hvirtualcvs/libmpeg3/headers.c
126 // and find out how to decode info from the header)
127 asset->video_length = mpeg3_video_frames(fd, 0);
128 asset->vmpeg_cmodel = (mpeg3_colormodel(fd, 0) == MPEG3_YUV422P) ? 1 : 0;
129 if(!asset->frame_rate)
130 asset->frame_rate = mpeg3_frame_rate(fd, 0);
137 if(wr && asset->format == FILE_VMPEG)
139 char bitrate_string[BCTEXTLEN];
140 char quant_string[BCTEXTLEN];
141 char iframe_string[BCTEXTLEN];
143 sprintf(bitrate_string, "%d", asset->vmpeg_bitrate);
144 sprintf(quant_string, "%d", asset->vmpeg_quantization);
145 sprintf(iframe_string, "%d", asset->vmpeg_iframe_distance);
147 // Construct command line
150 append_vcommand_line("mpeg2enc");
153 if(asset->aspect_ratio > 0)
155 append_vcommand_line("-a");
156 if(EQUIV(asset->aspect_ratio, 1.333))
157 append_vcommand_line("2");
159 if(EQUIV(asset->aspect_ratio, 1.777))
160 append_vcommand_line("3");
162 if(EQUIV(asset->aspect_ratio, 2.11))
163 append_vcommand_line("4");
166 append_vcommand_line(asset->vmpeg_derivative == 1 ? "-1" : "");
167 append_vcommand_line(asset->vmpeg_cmodel == 1 ? "-422" : "");
168 if(asset->vmpeg_fix_bitrate)
170 append_vcommand_line("-b");
171 append_vcommand_line(bitrate_string);
175 append_vcommand_line("-q");
176 append_vcommand_line(quant_string);
178 append_vcommand_line(!asset->vmpeg_fix_bitrate ? quant_string : "");
179 append_vcommand_line("-n");
180 append_vcommand_line(iframe_string);
181 append_vcommand_line(asset->vmpeg_progressive ? "-p" : "");
182 append_vcommand_line(asset->vmpeg_denoise ? "-d" : "");
183 append_vcommand_line(file->cpus <= 1 ? "-u" : "");
184 append_vcommand_line(asset->vmpeg_seq_codes ? "-g" : "");
185 append_vcommand_line(asset->path);
187 video_out = new FileMPEGVideo(this);
192 if(wr && asset->format == FILE_AMPEG)
194 char command_line[BCTEXTLEN];
195 char encoder_string[BCTEXTLEN];
196 char argument_string[BCTEXTLEN];
198 //printf("FileMPEG::open_file 1 %d\n", asset->ampeg_derivative);
199 encoder_string[0] = 0;
201 if(asset->ampeg_derivative == 2)
203 char string[BCTEXTLEN];
204 append_acommand_line("toolame");
205 append_acommand_line("-m");
206 append_acommand_line((asset->channels >= 2) ? "j" : "m");
207 sprintf(string, "%f", (float)asset->sample_rate / 1000);
208 append_acommand_line("-s");
209 append_acommand_line(string);
210 sprintf(string, "%d", asset->ampeg_bitrate);
211 append_acommand_line("-b");
212 append_acommand_line(string);
213 append_acommand_line("-");
214 append_acommand_line(asset->path);
216 audio_out = new FileMPEGAudio(this);
220 if(asset->ampeg_derivative == 3)
222 lame_global = lame_init();
223 lame_set_brate(lame_global, asset->ampeg_bitrate / 1000);
224 lame_set_quality(lame_global, 0);
225 lame_set_in_samplerate(lame_global,
227 if((result = lame_init_params(lame_global)) < 0)
229 printf(_("encode: lame_init_params returned %d\n"), result);
230 lame_close(lame_global);
234 if(!(lame_fd = fopen(asset->path, "w")))
236 perror("FileMPEG::open_file");
237 lame_close(lame_global);
243 printf("FileMPEG::open_file: ampeg_derivative=%d\n", asset->ampeg_derivative);
249 //printf("FileMPEG::open_file 100\n");
253 void FileMPEG::append_vcommand_line(const char *string)
257 char *argv = strdup(string);
258 vcommand_line.append(argv);
262 void FileMPEG::append_acommand_line(const char *string)
266 char *argv = strdup(string);
267 acommand_line.append(argv);
272 int FileMPEG::close_file()
274 //printf("FileMPEG::close_file 1\n");
282 // End of sequence signal
283 mpeg2enc_set_input_buffers(1, 0, 0, 0);
288 vcommand_line.remove_all_objects();
289 acommand_line.remove_all_objects();
293 toolame_send_buffer(0, 0);
299 lame_close(lame_global);
301 if(temp_frame) delete temp_frame;
302 if(toolame_temp) delete [] toolame_temp;
304 if(lame_temp[0]) delete [] lame_temp[0];
305 if(lame_temp[1]) delete [] lame_temp[1];
306 if(lame_output) delete [] lame_output;
307 if(lame_fd) fclose(lame_fd);
310 FileBase::close_file();
311 //printf("FileMPEG::close_file 100\n");
315 int FileMPEG::get_best_colormodel(Asset *asset, int driver)
317 //printf("FileMPEG::get_best_colormodel 1\n");
322 if(asset->vmpeg_cmodel == 0) return BC_YUV420P;
323 if(asset->vmpeg_cmodel == 1) return BC_YUV422P;
325 case PLAYBACK_X11_XV:
326 if(asset->vmpeg_cmodel == 0) return BC_YUV420P;
327 if(asset->vmpeg_cmodel == 1) return BC_YUV422P;
333 case PLAYBACK_DV1394:
334 case PLAYBACK_FIREWIRE:
339 if(asset->vmpeg_cmodel == 0) return BC_YUV420P;
340 if(asset->vmpeg_cmodel == 1) return BC_YUV422P;
346 case CAPTURE_FIREWIRE:
350 //printf("FileMPEG::get_best_colormodel 100\n");
353 int FileMPEG::colormodel_supported(int colormodel)
359 int FileMPEG::can_copy_from(Edit *edit, int64_t position)
365 int FileMPEG::set_audio_position(int64_t sample)
371 to_streamchannel(file->current_channel, stream, channel);
373 //printf("FileMPEG::set_audio_position %d %d %d\n", sample, mpeg3_get_sample(fd, stream), last_sample);
374 if(sample != mpeg3_get_sample(fd, stream) &&
375 sample != last_sample)
377 if(sample >= 0 && sample < asset->audio_length)
379 //printf("FileMPEG::set_audio_position seeking stream %d\n", sample);
380 return mpeg3_set_sample(fd, sample, stream);
389 int FileMPEG::set_video_position(int64_t x)
392 if(x >= 0 && x < asset->video_length)
394 mpeg3_set_frame(fd, x, file->current_layer);
401 int FileMPEG::write_samples(double **buffer, int64_t len)
405 //printf("FileMPEG::write_samples 1\n");
406 if(asset->ampeg_derivative == 2)
409 int channels = MIN(asset->channels, 2);
410 int64_t audio_size = len * channels * 2;
411 if(toolame_allocation < audio_size)
413 if(toolame_temp) delete [] toolame_temp;
414 toolame_temp = new unsigned char[audio_size];
415 toolame_allocation = audio_size;
418 for(int i = 0; i < channels; i++)
420 int16_t *output = ((int16_t*)toolame_temp) + i;
421 double *input = buffer[i];
422 for(int j = 0; j < len; j++)
424 int sample = (int)(*input * 0x7fff);
425 *output = (int16_t)(CLIP(sample, -0x8000, 0x7fff));
430 result = toolame_send_buffer((char*)toolame_temp, audio_size);
433 if(asset->ampeg_derivative == 3)
435 int channels = MIN(asset->channels, 2);
436 int64_t audio_size = len * channels;
437 if(!lame_global) return 1;
438 if(!lame_fd) return 1;
439 if(lame_allocation < audio_size)
441 if(lame_temp[0]) delete [] lame_temp[0];
442 if(lame_temp[1]) delete [] lame_temp[1];
443 lame_temp[0] = new float[audio_size];
444 lame_temp[1] = new float[audio_size];
445 lame_allocation = audio_size;
448 if(lame_output_allocation < audio_size * 4)
450 if(lame_output) delete [] lame_output;
451 lame_output_allocation = audio_size * 4;
452 lame_output = new char[lame_output_allocation];
455 for(int i = 0; i < channels; i++)
457 float *output = lame_temp[i];
458 double *input = buffer[i];
459 for(int j = 0; j < len; j++)
461 *output++ = *input++ * (float)32768;
465 result = lame_encode_buffer_float(lame_global,
467 (channels > 1) ? lame_temp[1] : lame_temp[0],
469 (unsigned char*)lame_output,
470 lame_output_allocation);
473 char *real_output = lame_output;
477 for(int i = 0; i < bytes; i++)
480 real_output = &lame_output[i];
486 if(bytes > 0 && lame_started)
488 result = !fwrite(real_output, 1, bytes, lame_fd);
490 perror("FileMPEG::write_samples");
502 int FileMPEG::write_frames(VFrame ***frames, int len)
508 int temp_w = (int)((asset->width + 15) / 16) * 16;
511 (asset->vmpeg_cmodel == 0) ? BC_YUV420P : BC_YUV422P;
514 // Height depends on progressiveness
515 if(asset->vmpeg_progressive || asset->vmpeg_derivative == 1)
516 temp_h = (int)((asset->height + 15) / 16) * 16;
518 temp_h = (int)((asset->height + 31) / 32) * 32;
520 //printf("FileMPEG::write_frames 1\n");
522 // Only 1 layer is supported in MPEG output
523 for(int i = 0; i < 1; i++)
525 for(int j = 0; j < len; j++)
527 VFrame *frame = frames[i][j];
531 if(frame->get_w() == temp_w &&
532 frame->get_h() == temp_h &&
533 frame->get_color_model() == output_cmodel)
535 mpeg2enc_set_input_buffers(0,
536 (char*)frame->get_y(),
537 (char*)frame->get_u(),
538 (char*)frame->get_v());
542 //printf("FileMPEG::write_frames 2\n");
544 (temp_frame->get_w() != temp_w ||
545 temp_frame->get_h() != temp_h ||
546 temp_frame->get_color_model() || output_cmodel))
551 //printf("FileMPEG::write_frames 3\n");
556 temp_frame = new VFrame(0,
562 cmodel_transfer(temp_frame->get_rows(),
578 frame->get_color_model(),
579 temp_frame->get_color_model(),
584 mpeg2enc_set_input_buffers(0,
585 (char*)temp_frame->get_y(),
586 (char*)temp_frame->get_u(),
587 (char*)temp_frame->get_v());
593 //printf("FileMPEG::write_frames 100\n");
599 int FileMPEG::read_frame(VFrame *frame)
605 //printf("FileMPEG::read_frame 1\n");
606 if(mpeg3_colormodel(fd, 0) == MPEG3_YUV420P)
607 src_cmodel = BC_YUV420P;
609 if(mpeg3_colormodel(fd, 0) == MPEG3_YUV422P)
610 src_cmodel = BC_YUV422P;
612 //printf("FileMPEG::read_frame 1 %p %d\n", frame, frame->get_color_model());
613 switch(frame->get_color_model())
620 case MPEG3_RGBA16161616:
622 frame->get_rows(), /* Array of pointers to the start of each output row */
623 0, /* Location in input frame to take picture */
627 asset->width, /* Dimensions of output_rows */
629 frame->get_color_model(), /* One of the color model #defines */
630 file->current_layer);
635 // Read these directly
636 if(frame->get_color_model() == src_cmodel)
638 mpeg3_read_yuvframe(fd,
639 (char*)frame->get_y(),
640 (char*)frame->get_u(),
641 (char*)frame->get_v(),
646 file->current_layer);
648 // Test composite something
649 // static VFrame *test_frame = 0;
652 // FILE *test_fd = 0;
653 // mjpeg_t *test_mjpeg = 0;
654 // test_frame = new VFrame(0, 1920, 1080, BC_YUV420P);
655 // test_mjpeg = mjpeg_new(1920, 1080, 1);
656 // test_fd = fopen("/mov/test.jpg", "r");
657 // fseek(test_fd, 0, SEEK_END);
658 // int test_size = ftell(test_fd);
659 // fseek(test_fd, 0, SEEK_SET);
660 // unsigned char *test_buffer = new unsigned char[test_size];
661 // fread(test_buffer, test_size, 1, test_fd);
662 // mjpeg_decompress(test_mjpeg,
667 // test_frame->get_y(),
668 // test_frame->get_u(),
669 // test_frame->get_v(),
673 // int test_bytes = 1920 * 1080;
674 // unsigned char *output_byte = frame->get_data();
675 // unsigned char *input_byte = test_frame->get_data();
676 // for(int i = 0; i < test_bytes; i++)
678 // *output_byte = (*input_byte * 0x80 + *output_byte * 0x80) >> 8;
683 // for(int i = 0; i < test_bytes / 2; i++)
685 // *output_byte = (*input_byte * 0x80 + *output_byte * 0x80) >> 8;
688 // *output_byte = (*input_byte * 0x80 + *output_byte * 0x80) >> 8;
694 // Process through temp frame
697 mpeg3_read_yuvframe_ptr(fd,
701 file->current_layer);
704 cmodel_transfer(frame->get_rows(),
721 frame->get_color_model(),
727 //printf("FileMPEG::read_frame 2\n");
730 //for(int i = 0; i < frame->get_w() * 3 * 20; i++)
731 // ((u_int16_t*)frame->get_rows()[0])[i] = 0xffff;
732 //printf("FileMPEG::read_frame 100\n");
736 void FileMPEG::to_streamchannel(int channel, int &stream_out, int &channel_out)
738 for(stream_out = 0, channel_out = file->current_channel;
739 stream_out < mpeg3_total_astreams(fd) &&
740 channel_out >= mpeg3_audio_channels(fd, stream_out);
741 channel_out -= mpeg3_audio_channels(fd, stream_out), stream_out++)
745 int FileMPEG::read_samples(double *buffer, int64_t len)
749 // This is directed to a FileMPEGBuffer
750 float *temp_float = new float[len];
751 // Translate pure channel to a stream and a channel in the mpeg stream
753 to_streamchannel(file->current_channel, stream, channel);
757 //printf("FileMPEG::read_samples 1 current_sample=%ld len=%ld channel=%d\n", file->current_sample, len, channel);
760 file->current_sample,
763 temp_float, /* Pointer to pre-allocated buffer of floats */
764 0, /* Pointer to pre-allocated buffer of int16's */
765 channel, /* Channel to decode */
766 len, /* Number of samples to decode */
767 stream); /* Stream containing the channel */
770 // last_sample = file->current_sample;
771 for(int i = 0; i < len; i++) buffer[i] = temp_float[i];
773 delete [] temp_float;
774 //printf("FileMPEG::read_samples 100\n");
778 int FileMPEG::prefer_samples_float()
783 int FileMPEG::read_samples_float(float *buffer, int64_t len)
787 // Translate pure channel to a stream and a channel in the mpeg stream
789 to_streamchannel(file->current_channel, stream, channel);
792 //printf("FileMPEG::read_samples 1 current_sample=%ld len=%ld channel=%d\n", file->current_sample, len, channel);
795 file->current_sample,
798 buffer, /* Pointer to pre-allocated buffer of floats */
799 0, /* Pointer to pre-allocated buffer of int16's */
800 channel, /* Channel to decode */
801 len, /* Number of samples to decode */
802 stream); /* Stream containing the channel */
805 // last_sample = file->current_sample;
807 //printf("FileMPEG::read_samples 100\n");
813 char* FileMPEG::strtocompression(char *string)
818 char* FileMPEG::compressiontostr(char *string)
829 FileMPEGVideo::FileMPEGVideo(FileMPEG *file)
833 mpeg2enc_init_buffers();
834 mpeg2enc_set_w(file->asset->width);
835 mpeg2enc_set_h(file->asset->height);
836 mpeg2enc_set_rate(file->asset->frame_rate);
839 FileMPEGVideo::~FileMPEGVideo()
844 void FileMPEGVideo::run()
846 printf("FileMPEGVideo::run ");
847 for(int i = 0; i < file->vcommand_line.total; i++)
848 printf("%s ", file->vcommand_line.values[i]);
850 mpeg2enc(file->vcommand_line.total, file->vcommand_line.values);
860 FileMPEGAudio::FileMPEGAudio(FileMPEG *file)
864 toolame_init_buffers();
867 FileMPEGAudio::~FileMPEGAudio()
872 void FileMPEGAudio::run()
874 file->toolame_result = toolame(file->acommand_line.total, file->acommand_line.values);
884 MPEGConfigAudio::MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset)
885 : BC_Window(PROGRAM_NAME ": Audio Compression",
886 parent_window->get_abs_cursor_x(1),
887 parent_window->get_abs_cursor_y(1),
896 this->parent_window = parent_window;
900 MPEGConfigAudio::~MPEGConfigAudio()
904 int MPEGConfigAudio::create_objects()
910 add_tool(new BC_Title(x, y, _("Layer:")));
911 add_tool(layer = new MPEGLayer(x1, y, this));
912 layer->create_objects();
915 add_tool(new BC_Title(x, y, _("Kbits per second:")));
916 add_tool(bitrate = new MPEGABitrate(x1, y, this));
917 bitrate->create_objects();
920 add_subwindow(new BC_OKButton(this));
926 int MPEGConfigAudio::close_event()
938 MPEGLayer::MPEGLayer(int x, int y, MPEGConfigAudio *gui)
939 : BC_PopupMenu(x, y, 150, layer_to_string(gui->asset->ampeg_derivative))
944 void MPEGLayer::create_objects()
946 add_item(new BC_MenuItem(layer_to_string(2)));
947 add_item(new BC_MenuItem(layer_to_string(3)));
950 int MPEGLayer::handle_event()
952 gui->asset->ampeg_derivative = string_to_layer(get_text());
953 gui->bitrate->set_layer(gui->asset->ampeg_derivative);
957 int MPEGLayer::string_to_layer(char *string)
959 if(!strcasecmp(layer_to_string(2), string))
961 if(!strcasecmp(layer_to_string(3), string))
967 char* MPEGLayer::layer_to_string(int layer)
991 MPEGABitrate::MPEGABitrate(int x, int y, MPEGConfigAudio *gui)
995 bitrate_to_string(gui->string, gui->asset->ampeg_bitrate))
1000 void MPEGABitrate::create_objects()
1002 set_layer(gui->asset->ampeg_derivative);
1005 void MPEGABitrate::set_layer(int layer)
1007 while(total_items())
1014 add_item(new BC_MenuItem("160"));
1015 add_item(new BC_MenuItem("192"));
1016 add_item(new BC_MenuItem("224"));
1017 add_item(new BC_MenuItem("256"));
1018 add_item(new BC_MenuItem("320"));
1019 add_item(new BC_MenuItem("384"));
1023 add_item(new BC_MenuItem("8"));
1024 add_item(new BC_MenuItem("16"));
1025 add_item(new BC_MenuItem("24"));
1026 add_item(new BC_MenuItem("32"));
1027 add_item(new BC_MenuItem("40"));
1028 add_item(new BC_MenuItem("48"));
1029 add_item(new BC_MenuItem("56"));
1030 add_item(new BC_MenuItem("64"));
1031 add_item(new BC_MenuItem("80"));
1032 add_item(new BC_MenuItem("96"));
1033 add_item(new BC_MenuItem("112"));
1034 add_item(new BC_MenuItem("128"));
1035 add_item(new BC_MenuItem("144"));
1036 add_item(new BC_MenuItem("160"));
1037 add_item(new BC_MenuItem("192"));
1038 add_item(new BC_MenuItem("224"));
1039 add_item(new BC_MenuItem("256"));
1040 add_item(new BC_MenuItem("320"));
1044 int MPEGABitrate::handle_event()
1046 gui->asset->ampeg_bitrate = string_to_bitrate(get_text());
1050 int MPEGABitrate::string_to_bitrate(char *string)
1052 return atol(string);
1056 char* MPEGABitrate::bitrate_to_string(char *string, int bitrate)
1058 sprintf(string, "%d", bitrate);
1070 MPEGConfigVideo::MPEGConfigVideo(BC_WindowBase *parent_window,
1072 : BC_Window(PROGRAM_NAME ": Video Compression",
1073 parent_window->get_abs_cursor_x(1),
1074 parent_window->get_abs_cursor_y(1),
1083 this->parent_window = parent_window;
1084 this->asset = asset;
1087 MPEGConfigVideo::~MPEGConfigVideo()
1091 int MPEGConfigVideo::create_objects()
1096 MPEGDerivative *derivative;
1097 MPEGColorModel *cmodel;
1099 add_subwindow(new BC_Title(x, y + 5, _("Derivative:")));
1100 add_subwindow(derivative = new MPEGDerivative(x1, y, this));
1101 derivative->create_objects();
1104 add_subwindow(new BC_Title(x, y + 5, _("Bitrate:")));
1105 add_subwindow(new MPEGBitrate(x1, y, this));
1106 add_subwindow(fixed_bitrate = new MPEGFixedBitrate(x2, y, this));
1109 add_subwindow(new BC_Title(x, y, _("Quantization:")));
1110 MPEGQuant *quant = new MPEGQuant(x1, y, this);
1111 quant->create_objects();
1112 add_subwindow(fixed_quant = new MPEGFixedQuant(x2, y, this));
1115 add_subwindow(new BC_Title(x, y, _("I frame distance:")));
1116 MPEGIFrameDistance *iframe_distance =
1117 new MPEGIFrameDistance(x1, y, this);
1118 iframe_distance->create_objects();
1121 add_subwindow(new BC_Title(x, y, _("Color model:")));
1122 add_subwindow(cmodel = new MPEGColorModel(x1, y, this));
1123 cmodel->create_objects();
1126 // add_subwindow(new BC_Title(x, y, _("P frame distance:")));
1130 add_subwindow(new BC_CheckBox(x, y, &asset->vmpeg_progressive, _("Progressive frames")));
1132 add_subwindow(new BC_CheckBox(x, y, &asset->vmpeg_denoise, _("Denoise")));
1134 add_subwindow(new BC_CheckBox(x, y, &asset->vmpeg_seq_codes, _("Sequence start codes in every GOP")));
1136 add_subwindow(new BC_OKButton(this));
1142 int MPEGConfigVideo::close_event()
1150 MPEGDerivative::MPEGDerivative(int x, int y, MPEGConfigVideo *gui)
1151 : BC_PopupMenu(x, y, 150, derivative_to_string(gui->asset->vmpeg_derivative))
1156 void MPEGDerivative::create_objects()
1158 add_item(new BC_MenuItem(derivative_to_string(1)));
1159 add_item(new BC_MenuItem(derivative_to_string(2)));
1162 int MPEGDerivative::handle_event()
1164 gui->asset->vmpeg_derivative = string_to_derivative(get_text());
1168 int MPEGDerivative::string_to_derivative(char *string)
1170 if(!strcasecmp(derivative_to_string(1), string))
1172 if(!strcasecmp(derivative_to_string(2), string))
1178 char* MPEGDerivative::derivative_to_string(int derivative)
1199 MPEGBitrate::MPEGBitrate(int x, int y, MPEGConfigVideo *gui)
1200 : BC_TextBox(x, y, 100, 1, gui->asset->vmpeg_bitrate)
1206 int MPEGBitrate::handle_event()
1208 gui->asset->vmpeg_bitrate = atol(get_text());
1216 MPEGQuant::MPEGQuant(int x, int y, MPEGConfigVideo *gui)
1217 : BC_TumbleTextBox(gui,
1218 (int64_t)gui->asset->vmpeg_quantization,
1228 int MPEGQuant::handle_event()
1230 gui->asset->vmpeg_quantization = atol(get_text());
1234 MPEGFixedBitrate::MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui)
1235 : BC_Radial(x, y, gui->asset->vmpeg_fix_bitrate, _("Fixed bitrate"))
1240 int MPEGFixedBitrate::handle_event()
1243 gui->asset->vmpeg_fix_bitrate = 1;
1244 gui->fixed_quant->update(0);
1248 MPEGFixedQuant::MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui)
1249 : BC_Radial(x, y, !gui->asset->vmpeg_fix_bitrate, _("Fixed quantization"))
1254 int MPEGFixedQuant::handle_event()
1257 gui->asset->vmpeg_fix_bitrate = 0;
1258 gui->fixed_bitrate->update(0);
1262 MPEGIFrameDistance::MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui)
1263 : BC_TumbleTextBox(gui,
1264 (int64_t)gui->asset->vmpeg_iframe_distance,
1274 int MPEGIFrameDistance::handle_event()
1276 gui->asset->vmpeg_iframe_distance = atol(get_text());
1281 MPEGColorModel::MPEGColorModel(int x, int y, MPEGConfigVideo *gui)
1282 : BC_PopupMenu(x, y, 150, cmodel_to_string(gui->asset->vmpeg_cmodel))
1287 void MPEGColorModel::create_objects()
1289 add_item(new BC_MenuItem(cmodel_to_string(0)));
1290 add_item(new BC_MenuItem(cmodel_to_string(1)));
1293 int MPEGColorModel::handle_event()
1295 gui->asset->vmpeg_cmodel = string_to_cmodel(get_text());
1299 int MPEGColorModel::string_to_cmodel(char *string)
1301 if(!strcasecmp(cmodel_to_string(0), string))
1303 if(!strcasecmp(cmodel_to_string(1), string))
1309 char* MPEGColorModel::cmodel_to_string(int cmodel)
1314 return _("YUV 4:2:0");
1318 return _("YUV 4:2:2");
1322 return _("YUV 4:2:0");