Failed Conditions
Push — master ( c58e29...ead145 )
by Sébastien
03:32
created

YadifVideoFilter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 37
c 0
b 0
f 0
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFFmpegCLIValue() 0 10 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 YadifVideoFilter 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