1
// Copyright (C) 2010 Dirk Vanden Boer <dirk.vdb@gmail.com>
3
// This program is free software; you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation; either version 2 of the License, or
6
// (at your option) any later version.
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
#include "filmstrip.h"
18
#include "filmstripfilter.h"
20
namespace ffmpegthumbnailer
23
static const int FILMHOLE_WIDTH = 12;
24
static const int FILMHOLE_HEIGHT = 10;
26
static const quint8* determineFilmStrip(quint32 videoWidth, quint32& filmStripWidth, quint32& filmStripHeight)
28
if (videoWidth <= SMALLEST_FILM_STRIP_WIDTH * 2)
35
filmStripWidth = filmStripHeight = 4;
39
if (videoWidth <= 192)
41
filmStripWidth = filmStripHeight = 8;
45
if (videoWidth <= 384)
47
filmStripWidth = filmStripHeight = 16;
51
if (videoWidth <= 768)
53
filmStripWidth = filmStripHeight = 32;
57
filmStripWidth = filmStripHeight = 64;
63
void FilmStripFilter::process(VideoFrame& videoFrame)
65
quint32 filmStripWidth;
66
quint32 filmStripHeight;
67
const quint8* filmHole = determineFilmStrip(videoFrame.width, filmStripWidth, filmStripHeight);
75
int filmHoleIndex = 0;
76
int offset = (videoFrame.width * 3) - 3;
78
for (quint32 i = 0; i < videoFrame.height; ++i)
80
for (quint32 j = 0; j < filmStripWidth * 3; j+=3)
82
int currentFilmHoleIndex = filmHoleIndex + j;
84
videoFrame.frameData[frameIndex + j] = filmHole[currentFilmHoleIndex];
85
videoFrame.frameData[frameIndex + j + 1] = filmHole[currentFilmHoleIndex + 1];
86
videoFrame.frameData[frameIndex + j + 2] = filmHole[currentFilmHoleIndex + 2];
88
videoFrame.frameData[frameIndex + offset - j] = filmHole[currentFilmHoleIndex];
89
videoFrame.frameData[frameIndex + offset - j + 1] = filmHole[currentFilmHoleIndex + 1];
90
videoFrame.frameData[frameIndex + offset - j + 2] = filmHole[currentFilmHoleIndex + 2];
92
frameIndex += videoFrame.lineSize;
93
filmHoleIndex = (i % filmStripHeight) * filmStripWidth * 3;