Alin Gherghescu wrote:
> 4. Decoder HW + Encoder SW --> not working (with VAAPI)
the fix is:
replace functionvideofilters_get_filters() from src/transcoding/transcode/video.c with function below.
static int
_video_filters_get_filters(TVHContext *self, AVDictionary **opts, char **filters)
{
char download[48];
char deint[8];
char hw_deint[64];
char scale[24];
char hw_scale[64];
char upload[48];
int ihw = _video_filters_hw_pix_fmt(self->iavctx->pix_fmt);
int ohw = _video_filters_hw_pix_fmt(self->oavctx->pix_fmt);
int filter_scale = (self->iavctx->height != self->oavctx->height);
int filter_deint = 0, filter_download = 0, filter_upload = 0;
if (tvh_context_get_int_opt(opts, "tvh_filter_deint", &filter_deint)) {
return -1;
}
filter_download = (ihw && (!ohw || filter_scale || filter_deint)) ? 1 : 0;
filter_upload = ((filter_download || !ihw) && ohw) ? 1 : 0;
memset(deint, 0, sizeof(deint));
memset(hw_deint, 0, sizeof(hw_deint));
#if ENABLE_HWACCELS
if (filter_deint) {
// when hwaccel is enabled we have two optios:
if (ihw) {
// hw deint
hwaccels_get_deint_filter(self->iavctx, hw_deint, sizeof(hw_deint));
}
else {
// sw deint
if (str_snprintf(deint, sizeof(deint), "yadif")) {
return -1;
}
}
}
#else
if (filter_deint) {
if (str_snprintf(deint, sizeof(deint), "yadif")) {
return -1;
}
}
#endif
memset(scale, 0, sizeof(scale));
memset(hw_scale, 0, sizeof(hw_scale));
#if ENABLE_HWACCELS
if (filter_scale) {
// when hwaccel is enabled we have two optios:
if (ihw) {
// hw scale
hwaccels_get_scale_filter(self->iavctx, self->oavctx, hw_scale, sizeof(hw_scale));
}
else {
// sw scale
if (str_snprintf(scale, sizeof(scale), "scale=w=-2:h=%d",
self->oavctx->height)) {
return -1;
}
}
}
#else
if (filter_scale) {
if (str_snprintf(scale, sizeof(scale), "scale=w=-2:h=%d",
self->oavctx->height)) {
return -1;
}
}
#endif
#if ENABLE_HWACCELS
if (hw_deint[0] == '\0' && deint[0] == '\0' && hw_scale[0] == '\0' && scale[0] == '\0') {
filter_download = filter_upload = 0;
}
#else
if (deint[0] == '\0' && scale[0] == '\0') {
filter_download = filter_upload = 0;
}
#endif
memset(download, 0, sizeof(download));
if (filter_download &&
str_snprintf(download, sizeof(download), "hwdownload,format=pix_fmts=%s",
av_get_pix_fmt_name(self->iavctx->sw_pix_fmt))) {
return -1;
}
memset(upload, 0, sizeof(upload));
if (filter_upload &&
str_snprintf(upload, sizeof(upload), "format=pix_fmts=%s|%s,hwupload",
av_get_pix_fmt_name(self->oavctx->sw_pix_fmt),
av_get_pix_fmt_name(self->oavctx->pix_fmt))) {
return -1;
}
if (!(*filters = str_join(",", hw_deint, hw_scale, download, deint, scale, upload, NULL))) {
return -1;
}
return 0;
}