int FFMPEG::get_format(char *format, const char *path, char *spec)
{
- char option_path[BCTEXTLEN], line[BCTEXTLEN], codec[BCSTRLEN];
+ char option_path[BCTEXTLEN], line[BCTEXTLEN], codec[BCTEXTLEN];
get_option_path(option_path, path, spec);
FILE *fp = fopen(option_path,"r");
if( !fp ) return 1;
return read_options(option_path, opts);
}
+int FFMPEG::load_options(const char *path, char *bfr, int len)
+{
+ *bfr = 0;
+ FILE *fp = fopen(path, "r");
+ if( !fp ) return 1;
+ fgets(bfr, len, fp); // skip hdr
+ len = fread(bfr, 1, len-1, fp);
+ if( len < 0 ) len = 0;
+ bfr[len] = 0;
+ fclose(fp);
+ return 0;
+}
+
void FFMPEG::set_loglevel(const char *ap)
{
if( !ap || !*ap ) return;
int scan_options(const char *options, AVDictionary *&opts);
int read_options(FILE *fp, const char *options, AVDictionary *&opts);
int load_options(const char *options, AVDictionary *&opts);
+ static int load_options(const char *path, char *bfr, int len);
void set_loglevel(const char *ap);
static double to_secs(int64_t time, AVRational time_base);
int info(char *text, int len);
return BC_YUV420P;
}
-static void load_options(const char *path, char *bfr, int len)
-{
- *bfr = 0;
- FILE *fp = fopen(path, "r");
- if( !fp ) return;
- fgets(bfr, len, fp); // skip hdr
- len = fread(bfr, 1, len-1, fp);
- if( len < 0 ) len = 0;
- bfr[len] = 0;
- fclose(fp);
-}
-
//======
extern void get_exe_path(char *result); // from main.C
y += 25;
if( !asset->ff_audio_options[0] && asset->acodec[0] ) {
FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
- load_options(option_path, asset->ff_audio_options,
+ FFMPEG::load_options(option_path, asset->ff_audio_options,
sizeof(asset->ff_audio_options));
}
add_subwindow(audio_options = new FFAudioOptions(this, x, y, get_w()-x-20, 10,
Asset *asset = popup->asset;
char option_path[BCTEXTLEN];
FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
- load_options(option_path, asset->ff_audio_options,
+ FFMPEG::load_options(option_path, asset->ff_audio_options,
sizeof(asset->ff_audio_options));
popup->audio_options->update(asset->ff_audio_options);
return 1;
y += 25;
if( !asset->ff_video_options[0] && asset->vcodec[0] ) {
FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
- load_options(option_path, asset->ff_video_options,
+ FFMPEG::load_options(option_path, asset->ff_video_options,
sizeof(asset->ff_video_options));
}
add_subwindow(video_options = new FFVideoOptions(this, x, y, get_w()-x-20, 10,
Asset *asset = popup->asset;
char option_path[BCTEXTLEN];
FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
- load_options(option_path, asset->ff_video_options,
+ FFMPEG::load_options(option_path, asset->ff_video_options,
sizeof(asset->ff_video_options));
popup->video_options->update(asset->ff_video_options);
return 1;
void FormatTools::update_format()
{
if( do_audio && prompt_audio && audio_switch ) {
- asset->audio_data = File::supports_audio(asset->format);
audio_switch->update(asset->audio_data);
if( !asset->audio_data )
audio_switch->disable();
audio_switch->enable();
}
if( do_video && prompt_video && video_switch ) {
- asset->video_data = File::supports_video(asset->format);
video_switch->update(asset->video_data);
if( !asset->video_data )
video_switch->disable();
int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
// if(new_format != format->asset->format)
{
- format->asset->format = new_format;
+ Asset *asset = format->asset;
+ asset->format = new_format;
+ asset->audio_data = File::supports_audio(asset->format);
+ asset->video_data = File::supports_video(asset->format);
format->format_text->update(selection->get_text());
format->update_extension();
format->close_format_windows();
{
}
+int FormatFFMPEG::load_defaults(const char *path, const char *type,
+ char *codec, char *codec_options, int len)
+{
+ char default_file[BCTEXTLEN];
+ FFMPEG::set_option_path(default_file, "%s/%s", path, type);
+ FILE *fp = fopen(default_file,"r");
+ if( !fp ) return 1;
+ char default_codec[BCSTRLEN];
+ fgets(default_codec, sizeof(default_codec), fp);
+ fclose(fp);
+ char *cp=codec, *dp=default_codec;
+ while( *dp && *dp!='\n' ) *cp++ = *dp++;
+ *cp = 0;
+ FFMPEG::set_option_path(default_file, "%s/%s", path, codec);
+ return FFMPEG::load_options(default_file, codec_options, len);
+}
+
int FormatFFMPEG::handle_event()
{
BC_ListBoxItem *selection = get_selection(0, 0);
if( selection ) {
char *text = get_selection(0, 0)->get_text();
format->ffmpeg_type->update(text);
- strcpy(format->asset->fformat, text);
- strcpy(format->asset->ff_audio_options, "");
- strcpy(format->asset->ff_video_options, "");
+ Asset *asset = format->asset;
+ strcpy(asset->fformat, text);
+ strcpy(asset->ff_audio_options, "");
+ strcpy(asset->ff_video_options, "");
+ asset->audio_data = !load_defaults("audio", text, asset->acodec,
+ asset->ff_audio_options, sizeof(asset->ff_audio_options));
+ asset->video_data = !load_defaults("video", text, asset->vcodec,
+ asset->ff_video_options, sizeof(asset->ff_video_options));
format->update_extension();
format->close_format_windows();
format->update_format();
#include "browsebutton.h"
#include "compresspopup.h"
#include "file.inc"
+#include "ffmpeg.h"
#include "formatpopup.h"
#include "mwindow.inc"
int handle_event();
FormatTools *format;
+ static int load_defaults(const char *path, const char *type,
+ char *codec, char *codec_options, int len);
+
// squash show/hide window
int show_window(int flush=1) { return 0; }
int hide_window(int flush=1) { return 0; }
#define entityNmIndex indecies[entityNmIdx]
#define noThrow std::nothrow
+#ifndef likely
#define likely(x) (__builtin_constant_p(x) ? !!(x) : __builtin_expect(!!(x), 1))
#define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __builtin_expect(!!(x), 0))
+#endif
+#ifndef lengthof
#define lengthof(x) ((int)(sizeof(x)/sizeof(x[0])))
+#endif
#if 0
inline void *operator new(size_t n) { void *vp = malloc(n); bzero(vp,n); return vp; }
-dvd ac3
-maxrate 9000000
-minrate 0
-bufsize 1835008
+dvd.dvd
--- /dev/null
+dvd ac3
+maxrate 9000000
+minrate 0
+bufsize 1835008
--- /dev/null
+mp3 libmp3lame
-dvd mpeg2video
-s 720x480
-r 30000/1001
-pix_fmt yuv420p
-g 18
-maxrate 9000000
-minrate 0
-bufsize 1835008
-packetsize 2048
+dvd.dvd
--- /dev/null
+dvd mpeg2video
+s 720x480
+r 30000/1001
+pix_fmt yuv420p
+g 18
+maxrate 9000000
+minrate 0
+bufsize 1835008
+packetsize 2048
-mpeg mpeg2video
+mpeg.mpeg
--- /dev/null
+mpeg mpeg2video