support for premultipled alpha
This commit is contained in:
+15
-6
@@ -766,16 +766,26 @@ void open_clip_worker(Clip* clip) {
|
||||
|
||||
AVFilterContext* last_filter = clip->buffersrc_ctx;
|
||||
|
||||
char filter_args[100];
|
||||
|
||||
if (ms->video_interlacing != VIDEO_PROGRESSIVE) {
|
||||
AVFilterContext* yadif_filter;
|
||||
char yadif_args[100];
|
||||
snprintf(yadif_args, sizeof(yadif_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc
|
||||
avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, nullptr, clip->filter_graph);
|
||||
snprintf(filter_args, sizeof(filter_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc
|
||||
avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", filter_args, nullptr, clip->filter_graph);
|
||||
|
||||
avfilter_link(last_filter, 0, yadif_filter, 0);
|
||||
last_filter = yadif_filter;
|
||||
}
|
||||
|
||||
if (!clip->media->to_footage()->alpha_is_premultiplied) {
|
||||
AVFilterContext* premultiply_filter;
|
||||
snprintf(filter_args, sizeof(filter_args), "inplace=1");
|
||||
avfilter_graph_create_filter(&premultiply_filter, avfilter_get_by_name("premultiply"), "premultiply", filter_args, nullptr, clip->filter_graph);
|
||||
|
||||
avfilter_link(last_filter, 0, premultiply_filter, 0);
|
||||
last_filter = premultiply_filter;
|
||||
}
|
||||
|
||||
/* stabilization code */
|
||||
/*bool stabilize = false;
|
||||
if (stabilize) {
|
||||
@@ -799,11 +809,10 @@ void open_clip_worker(Clip* clip) {
|
||||
|
||||
clip->pix_fmt = avcodec_find_best_pix_fmt_of_list(valid_pix_fmts, static_cast<enum AVPixelFormat>(clip->stream->codecpar->format), 1, nullptr);
|
||||
const char* chosen_format = av_get_pix_fmt_name(static_cast<enum AVPixelFormat>(clip->pix_fmt));
|
||||
char format_args[100];
|
||||
snprintf(format_args, sizeof(format_args), "pix_fmts=%s", chosen_format);
|
||||
snprintf(filter_args, sizeof(filter_args), "pix_fmts=%s", chosen_format);
|
||||
|
||||
AVFilterContext* format_conv;
|
||||
avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, nullptr, clip->filter_graph);
|
||||
avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", filter_args, nullptr, clip->filter_graph);
|
||||
avfilter_link(last_filter, 0, format_conv, 0);
|
||||
|
||||
avfilter_link(format_conv, 0, clip->buffersink_ctx, 0);
|
||||
|
||||
Reference in New Issue
Block a user