int result = 0;
if( ff ) return 1;
ff = new FFMPEG(this);
-
+
if( rd ) {
result = ff->init_decoder(asset->path);
if( !result ) result = ff->open_decoder();
int video_layers = ff->ff_total_video_layers();
if( video_layers > 0 ) {
asset->video_data = 1;
+ asset->aspect_ratio = ff->ff_aspect_ratio(0);
+ printf("ff_aspect_ratio, %f \n", asset->aspect_ratio);
+ if (!asset->interlace_mode) asset->interlace_mode = ff->ff_interlace(0);
+ if ( ff->ff_video_frames(0) > 1 ) {
+ ff->video_probe(1);
+ if (!asset->interlace_mode && (ff->interlace_from_codec) ) asset->interlace_mode = ff->video_probe(1);
+ }
if( !asset->layers ) asset->layers = video_layers;
asset->actual_width = ff->ff_video_width(0);
asset->actual_height = ff->ff_video_height(0);
asset->ff_color_range = ff->ff_color_range(0);
if( asset->ff_color_space < 0 )
asset->ff_color_space = ff->ff_color_space(0);
- strcpy(asset->vcodec, ff->ff_video_format(0));
+ strcpy(asset->vcodec, ff->ff_video_codec(0));
}
IndexState *index_state = asset->index_state;
index_state->read_markers(file->preferences->index_directory, asset->path);
this->parent_window = parent_window;
this->asset = asset;
this->edl = edl;
+ avctx = 0;
+ fmt_ctx = 0;
ff_options_dialog = 0;
- obj = 0;
format_name = 0;
codec_name = 0;
}
delete ff_options_dialog;
}
-void FFMPEGConfigWindow::start(const void *obj)
+void FFMPEGConfigWindow::start(AVCodecContext *avctx)
{
- this->obj = obj;
+ this->avctx = avctx;
+ ff_options_dialog->start();
+}
+
+void FFMPEGConfigWindow::start(AVFormatContext *fmt_ctx)
+{
+ this->fmt_ctx = fmt_ctx;
ff_options_dialog->start();
}
unlock_window();
}
-char *FFMPEGConfigAudio::get_options() {
- return asset->ff_audio_options;
+void FFMPEGConfigAudio::read_options()
+{
+ const char *options = audio_options->get_text();
+ int options_len = strlen(options);
+ ff_options_dialog->load_options(options, options_len);
}
-int FFMPEGConfigAudio::get_options_len() {
- return sizeof(asset->ff_audio_options)-1;
+void FFMPEGConfigAudio::save_options()
+{
+ char options[BCTEXTLEN];
+ ff_options_dialog->store_options(options, sizeof(options)-1);
+ audio_options->update(options);
}
void FFMPEGConfigAudio::load_options()
unlock_window();
}
-char *FFMPEGConfigVideo::get_options() {
- return asset->ff_video_options;
+void FFMPEGConfigVideo::read_options()
+{
+ const char *options = video_options->get_text();
+ int options_len = strlen(options);
+ ff_options_dialog->load_options(options, options_len);
}
-int FFMPEGConfigVideo::get_options_len() {
- return sizeof(asset->ff_video_options)-1;
+void FFMPEGConfigVideo::save_options()
+{
+ char options[BCTEXTLEN];
+ ff_options_dialog->store_options(options, sizeof(options)-1);
+ video_options->update(options);
}
void FFMPEGConfigVideo::load_options()
unlock_window();
}
-char *FFMPEGConfigFormat::get_options() {
- return asset->ff_format_options;
+void FFMPEGConfigFormat::read_options()
+{
+ const char *options = format_options->get_text();
+ int options_len = strlen(options);
+ ff_options_dialog->load_options(options, options_len);
}
-int FFMPEGConfigFormat::get_options_len() {
- return sizeof(asset->ff_format_options)-1;
+void FFMPEGConfigFormat::save_options()
+{
+ char options[BCTEXTLEN];
+ ff_options_dialog->store_options(options, sizeof(options)-1);
+ format_options->update(options);
+}
+void FFMPEGConfigFormat::save_changes()
+{
+ read_options();
+ char *options = asset->ff_format_options;
+ int options_len = sizeof(asset->ff_format_options)-1;
+ ff_options_dialog->store_options(options, options_len);
}
void FFMPEGConfigFormat::load_options()
void *obj = (void *)options->obj;
uint8_t *bp = 0;
if( av_opt_get(obj, opt->name, 0, &bp) >= 0 && bp != 0 ) {
- const char *val = (const char *)bp;
+ const char *val = (const char *)bp;
if( opt->unit && *val ) {
int id = atoi(val);
const char *uid = unit_name(id);
FFOptionsWindow *fwin = kind->fwin;
FFOptions &options = fwin->options;
options.initialize(fwin, idx);
+ kind->set_text(get_text());
fwin->draw();
return 1;
}
FFOptions::FFOptions()
{
- avctx = 0;
obj = 0;
}
FFOptions::~FFOptions()
{
remove_all_objects();
- avcodec_free_context(&avctx);
}
int FFOptions::cmpr(const void *a, const void *b)
void FFOptions::initialize(FFOptionsWindow *win, int kind)
{
remove_all_objects();
- this->win = win;
win->selected = 0;
- obj = win->dialog->cfg_window->obj;
+ const void *obj = 0;
+ switch( kind ) {
+ case FF_KIND_CODEC:
+ obj = (const void *)win->dialog->cfg_window->avctx->priv_data;
+ break;
+ case FF_KIND_FFMPEG:
+ obj = (const void *)win->dialog->cfg_window->avctx;
+ break;
+ case FF_KIND_FORMAT:
+ obj = (const void *)win->dialog->cfg_window->fmt_ctx->priv_data;
+ break;
+ }
+ this->win = win;
+ this->obj = obj;
if( obj ) {
FFOptions &conf = *this;
const AVOption *opt = 0;
}
qsort(&values[0],size(),sizeof(values[0]),cmpr);
}
- if( win->kind )
- win->kind->set(kind);
win->panel->update();
win->panel->set_yposition(0);
}
add_subwindow(new BC_OKButton(this));
add_subwindow(new BC_CancelButton(this));
panel->create_objects();
- options.initialize(this, codec_name ? FF_KIND_CODEC : FF_KIND_FORMAT);
+ int k = codec_name ? FF_KIND_CODEC : FF_KIND_FORMAT;
+ options.initialize(this, k);
+ if( kind )
+ kind->set(k);
draw();
show_window(1);
unlock_window();
void FFOptionsDialog::load_options(const char *bp, int len)
{
+ av_dict_free(&ff_opts);
char line[BCTEXTLEN];
char key[BCSTRLEN], val[BCTEXTLEN];
const char *dp = bp + len-1;
*cp = 0;
}
+
void FFOptionsDialog::start()
{
if( options_window ) {
return;
}
cfg_window->get_pop_cursor(wx, wy);
- char *options = cfg_window->get_options();
- int options_len = cfg_window->get_options_len();
- load_options(options, options_len);
+ cfg_window->read_options();
BC_DialogThread::start();
}
void FFOptionsDialog::handle_done_event(int result)
{
if( !result ) {
- char *options = cfg_window->get_options();
- int options_len = cfg_window->get_options_len();
- store_options(options, options_len);
- update_options(options);
+ cfg_window->lock_window("FFMPEGConfigFormat::save_options");
+ cfg_window->save_options();
+ cfg_window->unlock_window();
}
options_window = 0;
}
int ret = 0;
Asset *asset = aud_config->asset;
const char *name = asset->acodec;
- char *audio_format = aud_config->format_name;
- char *audio_codec = aud_config->codec_name;
+ char audio_format[BCSTRLEN]; audio_format[0] = 0;
+ char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
AVCodec *codec = !ret &&
!FFMPEG::get_format(audio_format, "audio", name) &&
!FFMPEG::get_codec(audio_codec, "audio", name) ?
eprintf(_("no codec context: %s: %s"), name, audio_codec);
ret = 1;
}
- if( !ret ) {
- const void *obj = avctx->priv_data;
- aud_config->start(obj);
- }
+ if( !ret )
+ aud_config->start(avctx);
return 1;
}
int ret = 0;
Asset *asset = vid_config->asset;
const char *name = asset->vcodec;
- char *video_format = vid_config->format_name;
- char *video_codec = vid_config->codec_name;
+ char video_format[BCSTRLEN]; video_format[0] = 0;
+ char video_codec[BCSTRLEN]; video_codec[0] = 0;
AVCodec *codec = !ret &&
!FFMPEG::get_format(video_format, "video", name) &&
!FFMPEG::get_codec(video_codec, "video", name) ?
ret = 1;
}
- if( !ret ) {
- const void *obj = (const void *)avctx->priv_data;
- vid_config->start(obj);
- }
+ if( !ret )
+ vid_config->start(avctx);
return 1;
}
-FFOptionsViewFormat::FFOptionsViewFormat(BC_WindowBase *parent_window,
+FFOptionsViewFormat::FFOptionsViewFormat(FFMPEGConfigWindow *cfg_window,
EDL *edl, Asset *asset, int x, int y, const char *text)
: BC_GenericButton(x, y, text)
{
- this->parent_window = parent_window;
+ this->cfg_window = cfg_window;
this->edl = edl;
this->asset = asset;
format_dialog = 0;
{
Asset *asset = fmt_config->asset;
char *format_name = asset->fformat;
+ char *replace_name0 = "mov";
+ char *replace_name1 = "mpegts";
+ char *replace_name2 = "matroska";
+ if (!strcmp(format_name, "qt"))
+ format_name = replace_name0; // fixup
+ if (!strcmp(format_name, "m2ts"))
+ format_name = replace_name1; // fixup
+ if (!strcmp(format_name, "mkv"))
+ format_name = replace_name2; // fixup
avformat_free_context(fmt_ctx); fmt_ctx = 0;
int ret = avformat_alloc_output_context2(&fmt_ctx, 0, format_name, 0);
if( ret || !fmt_ctx ) {
eprintf(_("no format named: %s"), format_name);
ret = 1;
}
- if( !ret ) {
- const void *obj = fmt_ctx->priv_data;
- fmt_config->start(obj);
- }
+ if( !ret )
+ fmt_config->start(fmt_ctx);
return 1;
}
cfg_window = new FFMPEGConfigFormat(this, wx, wy,
view_format->asset, view_format->edl);
cfg_window->create_objects();
+ cfg_window->read_options();
return cfg_window;
}
void FFOptionsFormatViewDialog::handle_done_event(int result)
{
- if( !result ) {
- char *options = cfg_window->get_options();
- int options_len = cfg_window->get_options_len();
- cfg_window->ff_options_dialog->store_options(options, options_len);
- cfg_window->ff_options_dialog->update_options(options);
- }
+ if( !result )
+ cfg_window->save_changes();
cfg_window = 0;
}