fix: fixes to QSV deinterlacing

This commit is contained in:
Christian Benincasa
2026-02-23 12:19:02 -05:00
parent bf052dd80a
commit f9208e0f51
3 changed files with 23 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
import { FilterOption } from '@/ffmpeg/builder/filter/FilterOption.js';
import type { FrameState } from '@/ffmpeg/builder/state/FrameState.js';
import { FrameDataLocation } from '../../types.ts';
import { HardwareUploadQsvFilter } from './HardwareUploadQsvFilter.ts';
export class DeinterlaceQsvFilter extends FilterOption {
readonly filter: string;
@@ -14,14 +16,14 @@ export class DeinterlaceQsvFilter extends FilterOption {
nextState(currentState: FrameState): FrameState {
return currentState.update({
deinterlace: false,
frameDataLocation: 'hardware',
frameDataLocation: FrameDataLocation.Hardware,
});
}
private generateFilter(currentState: FrameState): string {
const prelude =
currentState.frameDataLocation === 'hardware'
? 'hwupload=extra_hw_frames=64,'
currentState.frameDataLocation !== FrameDataLocation.Hardware
? `${new HardwareUploadQsvFilter(64).filter},`
: '';
return `${prelude}deinterlace_qsv`;
}

View File

@@ -0,0 +1,3 @@
import { FilterOption } from '../FilterOption.ts';
export class TonemapQsvFilter extends FilterOption {}

View File

@@ -20,9 +20,9 @@ import { WatermarkScaleFilter } from '@/ffmpeg/builder/filter/watermark/Watermar
import {
PixelFormatNv12,
PixelFormatP010,
PixelFormats,
PixelFormatYuv420P10Le,
PixelFormatYuva420P,
PixelFormats,
} from '@/ffmpeg/builder/format/PixelFormat.js';
import type { AudioInputSource } from '@/ffmpeg/builder/input/AudioInputSource.js';
import type { ConcatInputSource } from '@/ffmpeg/builder/input/ConcatInputSource.js';
@@ -39,6 +39,7 @@ import { FrameDataLocation } from '@/ffmpeg/builder/types.js';
import type { Nullable } from '@/types/util.js';
import { isDefined, isNonEmptyString } from '@/util/index.js';
import { every, head, inRange, isNull, some } from 'lodash-es';
import { getBooleanEnvVar, TUNARR_ENV_VARS } from '../../../../util/env.ts';
import { H264QsvEncoder } from '../../encoder/qsv/H264QsvEncoder.ts';
import { HevcQsvEncoder } from '../../encoder/qsv/HevcQsvEncoder.ts';
import { Mpeg2QsvEncoder } from '../../encoder/qsv/Mpeg2QsvEncoder.ts';
@@ -191,6 +192,7 @@ export class QsvPipelineBuilder extends SoftwarePipelineBuilder {
currentState = this.setDeinterlace(currentState);
currentState = this.setScale(currentState);
currentState = this.setTonemap(currentState);
currentState = this.setPad(currentState);
this.setStillImageLoop();
@@ -248,10 +250,12 @@ export class QsvPipelineBuilder extends SoftwarePipelineBuilder {
protected setDeinterlace(currentState: FrameState): FrameState {
let nextState = currentState;
if (this.context.shouldDeinterlace) {
const filter =
currentState.frameDataLocation === FrameDataLocation.Software
? new DeinterlaceFilter(this.ffmpegState, currentState)
: new DeinterlaceQsvFilter(currentState);
let filter: FilterOption;
if (this.context.pipelineOptions.disableHardwareFilters) {
filter = new DeinterlaceFilter(this.ffmpegState, currentState);
} else {
filter = new DeinterlaceQsvFilter(currentState);
}
nextState = filter.nextState(nextState);
this.videoInputSource.filterSteps.push(filter);
}
@@ -538,6 +542,12 @@ export class QsvPipelineBuilder extends SoftwarePipelineBuilder {
return currentState;
}
protected setTonemap(currentState: FrameState): FrameState {
if (!getBooleanEnvVar(TUNARR_ENV_VARS.TONEMAP_ENABLED, false)) {
return currentState;
}
}
protected getIsIntelQsvOrVaapi(): boolean {
return (
this.ffmpegState.decoderHwAccelMode === HardwareAccelerationMode.Qsv ||