Failed Conditions
Push — master ( 85c284...561f65 )
by Sébastien
02:44
created

YadifInterface::getFFmpegCLIValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Video\Filter;
6
7
use Soluble\MediaTools\Video\Filter\Type\FFMpegVideoFilterInterface;
8
use Soluble\MediaTools\Video\Filter\Type\VideoDeinterlacerInterface;
9
10
class YadifInterface implements FFMpegVideoFilterInterface, VideoDeinterlacerInterface
11
{
12
    public const DEFAULT_MODE   = 0;
13
    public const DEFAULT_PARITY = -1;
14
    public const DEFAULT_DEINT  = 0;
15
16
    /** @var array<string, int> */
17
    protected $options = [
18
        'mode'   => self::DEFAULT_MODE,
19
        'parity' => self::DEFAULT_PARITY,
20
        'deint'  => self::DEFAULT_DEINT,
21
    ];
22
23
    /**
24
     * @param int $mode   The interlacing mode to adopt (0, send_frame Output one frame for each frame)
25
     * @param int $parity default=-1 Enable automatic detection of field parity. 0:
26
     * @param int $deint  Specify which frames to deinterlace (0: all - Deinterlace all frames.)
27
     */
28 1
    public function __construct(int $mode = self::DEFAULT_MODE, int $parity = self::DEFAULT_PARITY, int $deint = self::DEFAULT_DEINT)
29
    {
30 1
        $this->options = [
31 1
            'mode'   => $mode,
32 1
            'parity' => $parity,
33 1
            'deint'  => $deint,
34
        ];
35 1
    }
36
37 1
    public function getFFmpegCLIValue(): string
38
    {
39 1
        $yadifArg = sprintf(
40 1
            'yadif=mode=%s:parity=%s:deint=%s',
41 1
            $this->options['mode'],
42 1
            $this->options['parity'],
43 1
            $this->options['deint']
44
        );
45
46 1
        return $yadifArg;
47
    }
48
}
49