#include "libmjpeg.h"
#include "mainerror.h"
#include "mwindow.h"
+#include "preferences.h"
#include "vframe.h"
#ifdef FFMPEG3
seek_pos = curr_pos = 0;
seeked = 1; eof = 0;
reading = writing = 0;
- hw_dev = 0;
hw_pixfmt = AV_PIX_FMT_NONE;
hw_device_ctx = 0;
flushed = 0;
AVHWDeviceType FFVideoStream::decode_hw_activate()
{
AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
- const char *hw_dev = getenv("CIN_HW_DEV");
- if( hw_dev ) {
+ const char *hw_dev = ffmpeg->opt_hw_dev;
+ if( !hw_dev ) hw_dev = getenv("CIN_HW_DEV");
+ if( !hw_dev ) hw_dev = ffmpeg->ff_hw_dev();
+ if( hw_dev && *hw_dev && strcmp(_("none"), hw_dev) ) {
type = av_hwdevice_find_type_by_name(hw_dev);
if( type == AV_HWDEVICE_TYPE_NONE ) {
fprintf(stderr, "Device type %s is not supported.\n", hw_dev);
}
AVPixelFormat pix_fmt = (AVPixelFormat)ip->format;
- if( pix_fmt == ((FFVideoStream *)this)->hw_pixfmt ) {
+ FFVideoStream *vid =(FFVideoStream *)this;
+ if( pix_fmt == vid->hw_pixfmt ) {
int ret = 0;
if( !sw_frame && !(sw_frame=av_frame_alloc()) )
ret = AVERROR(ENOMEM);
pix_fmt = (AVPixelFormat)ip->format;
}
if( ret < 0 ) {
- ff_err(ret, "Error retrieving data from GPU to CPU\n");
+ eprintf(_("Error retrieving data from GPU to CPU\nfile: %s\n"),
+ vid->ffmpeg->fmt_ctx->url);
return -1;
}
}
int ret = sws_scale(convert_ctx, ip->data, ip->linesize, 0, ip->height,
ipic->data, ipic->linesize);
if( ret < 0 ) {
- ff_err(ret, "FFVideoConvert::convert_picture_frame: sws_scale() failed\n");
+ ff_err(ret, "FFVideoConvert::convert_picture_frame: sws_scale() failed\nfile: %s\n",
+ vid->ffmpeg->fmt_ctx->url);
return -1;
}
return 0;
opt_duration = -1;
opt_video_filter = 0;
opt_audio_filter = 0;
+ opt_hw_dev = 0;
fflags = 0;
char option_path[BCTEXTLEN];
set_option_path(option_path, "%s", "ffmpeg.opts");
av_dict_free(&opts);
delete [] opt_video_filter;
delete [] opt_audio_filter;
+ delete [] opt_hw_dev;
}
int FFMPEG::check_sample_rate(AVCodec *codec, int sample_rate)
opt_video_filter = cstrdup(val);
else if( !strcmp(key, "audio_filter") )
opt_audio_filter = cstrdup(val);
+ else if( !strcmp(key, "cin_hw_dev") )
+ opt_hw_dev = cstrdup(val);
else if( !strcmp(key, "loglevel") )
set_loglevel(val);
else
return file_base->file->cpus;
}
+const char *FFMPEG::ff_hw_dev()
+{
+ return &file_base->file->preferences->use_hw_dev[0];
+}
+
int FFVideoStream::create_filter(const char *filter_spec, AVCodecParameters *avpar)
{
avfilter_register_all();
int reading, writing;
int seeked, eof;
- const char *hw_dev;
int hw_pixfmt;
AVBufferRef *hw_device_ctx;
double opt_duration;
char *opt_video_filter;
char *opt_audio_filter;
+ char *opt_hw_dev;
char file_format[BCTEXTLEN];
int fflags;
int ff_video_mpeg_color_range(int stream);
int ff_cpus();
+ const char *ff_hw_dev();
void dump_context(AVCodecContext *ctx);
};
int y0 = y;
win = add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
maxw = win->get_w();
+ int x1 = x + xmargin4;
+ win = add_subwindow(new BC_Title(x1, y + 5, _("Use HW Device:")));
+ x1 += win->get_w() + 5;
+ PrefsUseHWDev *use_hw_dev = new PrefsUseHWDev(pwindow, this, x1, y);
+ use_hw_dev->create_objects();
int y1 = y += 30;
win = add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
preroll->create_objects();
y += 30;
- int x1 = x + xmargin4;
+ x1 = x + xmargin4;
BC_Title *smp_title = new BC_Title(x1, y + 5, _("Project SMP cpus:"));
add_subwindow(smp_title);
- int x2 = x1 + smp_title->get_w() + 5;
- PrefsProjectSMP *proj_smp = new PrefsProjectSMP(pwindow, this, x2, y);
+ x1 += smp_title->get_w() + 5;
+ PrefsProjectSMP *proj_smp = new PrefsProjectSMP(pwindow, this, x1, y);
proj_smp->create_objects();
PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
}
+PrefsUseHWDev::PrefsUseHWDev(PreferencesWindow *pwindow,
+ PerformancePrefs *subwindow, int x, int y)
+ : BC_PopupTextBox(subwindow,0,0,x,y,100,80,LISTBOX_TEXT)
+{
+ this->pwindow = pwindow;
+}
+
+void PrefsUseHWDev::create_objects()
+{
+ BC_PopupTextBox::create_objects();
+ hw_dev_names.append(new BC_ListBoxItem(_("none")));
+ hw_dev_names.append(new BC_ListBoxItem("vaapi"));
+ hw_dev_names.append(new BC_ListBoxItem("vdpau"));
+ hw_dev_names.append(new BC_ListBoxItem(""));
+ update_list(&hw_dev_names);
+ update(&pwindow->thread->preferences->use_hw_dev[0]);
+}
+
+int PrefsUseHWDev::handle_event()
+{
+ strncpy(&pwindow->thread->preferences->use_hw_dev[0],
+ get_text(), sizeof(pwindow->thread->preferences->use_hw_dev));
+ return 1;
+}
+
PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
PerformancePrefs *subwindow,
int x,
int hot_node;
CICacheSize *cache_size;
+ PerfsUseHWDev *use_hw_dev;
enum
{
PreferencesWindow *pwindow;
};
+class PrefsUseHWDev : public BC_PopupTextBox
+{
+public:
+ PrefsUseHWDev(PreferencesWindow *pwindow,
+ PerformancePrefs *subwindow, int x, int y);
+ void create_objects();
+ int handle_event();
+
+ PreferencesWindow *pwindow;
+ ArrayList<BC_ListBoxItem *> hw_dev_names;
+};
+
#endif
class PrefsRenderFarmReset;
class PrefsRenderFarmWatchdog;
class CICacheSize;
+class PerfsUseHWDev;
#endif
project_smp = processors = calculate_processors(0);
real_processors = calculate_processors(1);
ffmpeg_marker_indexes = 1;
+ memset(&use_hw_dev, 0, sizeof(use_hw_dev));
warn_indexes = 1;
warn_version = 1;
bd_warn_root = 1;
processors = that->processors;
real_processors = that->real_processors;
ffmpeg_marker_indexes = that->ffmpeg_marker_indexes;
+ strcpy(use_hw_dev, &that->use_hw_dev[0]);
warn_indexes = that->warn_indexes;
warn_version = that->warn_version;
bd_warn_root = that->bd_warn_root;
project_smp = defaults->get("PROJECT_SMP", project_smp);
force_uniprocessor = defaults->get("FORCE_UNIPROCESSOR", force_uniprocessor);
ffmpeg_marker_indexes = defaults->get("FFMPEG_MARKER_INDEXES", ffmpeg_marker_indexes);
+ memset(&use_hw_dev, 0, sizeof(use_hw_dev));
+ defaults->get("USE_HW_DEV", use_hw_dev);
warn_indexes = defaults->get("WARN_INDEXES", warn_indexes);
warn_version = defaults->get("WARN_VERSION", warn_version);
bd_warn_root = defaults->get("BD_WARN_ROOT", bd_warn_root);
defaults->update("PROJECT_SMP", project_smp);
defaults->update("FORCE_UNIPROCESSOR", force_uniprocessor);
defaults->update("FFMPEG_MARKER_INDEXES", ffmpeg_marker_indexes);
+ defaults->update("USE_HW_DEV", use_hw_dev);
defaults->update("WARN_INDEXES", warn_indexes);
defaults->update("WARN_VERSION", warn_version);
defaults->update("BD_WARN_ROOT", bd_warn_root);
int real_processors;
// ffmpeg builds marker indexes as it builds idx files
int ffmpeg_marker_indexes;
+// ffmpeg hw_dev driver probe name
+ char use_hw_dev[BCSTRLEN];
// warning
int warn_indexes;
int warn_version;