Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated markdown according to standards #1

Open
wants to merge 20 commits into
base: separate-codec
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ comskip.c.save-failed
# Eclipse IDE
.cproject
.project


#VSCODE
.vscode/
=======
# VS Code
.vscode/*

125 changes: 16 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,136 +1,43 @@
## Comskip
# Comskip

Commercial detector
http://www.kaashoek.com/comskip/
<http://www.kaashoek.com/comskip/>

![Example Comskip image](https://github.com/essandess/etv-comskip/blob/master/example.png)
*Commercials are marked and skipped using [associated projects](https://github.com/essandess/etv-comskip).*

### Requirements
## Requirements

- FFmpeg with headers and shared libraries (2.4+)
- This is version is specifically build for MacOS ARM64 with FFmpeg6 with headers and shared libraries
- libargtable2 for option parsing
- Optional: SDL for building the Comskip GUI

### Building
### TODO
[ ] Native GUI and drop SDL dependency
[ ] Remove all code and configuration for other systems than MacOS
[ ] Rewrite mpeg2dec to eliminate deprecated functions

#### Building from GitHub

Building directly from GitHub also requires GNU autotools (autoconf, automake, and libtool).

```
$ git clone git://github.com/erikkaashoek/Comskip
$ cd Comskip
$ ./autogen.sh
$ ./configure
$ make
```

#### Building from a tarball

```
$ tar zxpfv comskip-<version>.tar.gz
$ cd comskip-<version>
$ ./configure
$ make
```

### Setting up a build environment

#### Windows

There are many ways to setup a build system on Windows.

##### Cross Compile with Ubuntu Bionic (18.04) with MinGW-w64

```
$ sudo apt-get install -y subversion curl texinfo g++ bison flex cvs yasm automake libtool autoconf gcc cmake git make pkg-config zlib1g-dev mercurial unzip pax nasm gperf autogen bzip2
$ git clone https://github.com/erikkaashoek/Comskip.git
$ cd Comskip
$ ./cross_compile_comskip.sh
```

##### MSYS2 and MinGW-w64

These instructions use MSYS2 and MinGW-w64, but other environments should also work:

- Install MSYS2 by following the instructions at https://msys2.github.io/
- Install the essential build tools: `pacman -S mingw-w64-i686-gcc gcc make autoconf automake libtool pkgconfig yasm`
- Close the MSYS2 shell and launch a MinGW-w64 shell; this is the shell you'll use for all builds
- Build FFmpeg (http://ffmpeg.org/), argtable2 (http://argtable.sourceforge.net/) and SDL2 from source and install them to /usr/local
- Add /usr/local/lib/pkg-config to PKG_CONFIG_PATH (e.g., add `export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig` to ~/.bashrc, then type `source ~/.bashrc`)

#### Mac OS X

First install Xcode (freely available from the Mac OS X App Store). After it's installed, install the Xcode command-line tools by executing `xcode-select --install` from a terminal.

The easiest way to install Comskip's dependencies is via Homebrew (http://brew.sh/):

```
$ brew install autoconf automake libtool pkgconfig argtable ffmpeg sdl
Recommended way to install dependencies is MacPorts.
```

[Macports](https://www.macports.org/install.php) natively compiles all libraries from source. The project [etv-comskip](https://github.com/essandess/etv-comskip) has an example [Makefile](https://github.com/essandess/etv-comskip/blob/master/Makefile) using Macports tools.
sudo port -v install autoconf automake libtool pkgconfig argtable ffmpeg6 libsdl coreutils

```
$ sudo port install ffmpeg coreutils argtable
```

#### Linux

##### Ubuntu Xenial (16.04)

```
$ apt-get install -y autoconf libtool git build-essential libargtable2-dev libavformat-dev libsdl1.2-dev
```

##### Ubuntu Vivid (15.04)

```
$ apt-get install -y git build-essential libargtable2-dev libavformat-ffmpeg-dev libsdl1.2-dev
```

##### Ubuntu Trusty (14.04)

```
$ add-apt-repository -y ppa:mc3man/trusty-media
$ apt-get update

$ apt-get install -y git build-essential libargtable2-dev libsdl1.2-dev
$ apt-get install -y ffmpeg libva-dev libsoxr-dev libvorbis-dev libbz2-dev zlib1g-dev libxvidcore-dev libvpx-dev libx264-dev libx265-dev libspeex-dev libfdk-aac-dev libvorbisenc2 libopus-dev libmp3lame-dev libdca-dev libfaac-dev libopencore-amrnb-dev libvo-aacenc-dev libopencore-amrwb-dev

$ git clone https://github.com/foo86/dcadec
$ cd dcadec
$ make install
```

##### Ubuntu Precise (12.04)

```
$ add-apt-repository -y ppa:pavlyshko/precise
$ add-apt-repository -y ppa:chris-lea/zeromq
$ apt-get update

$ wget https://launchpad.net/ubuntu/+archive/primary/+files/libfdk-aac0_0.1.1%2B20130514-2_amd64.deb
$ wget https://launchpad.net/ubuntu/+archive/primary/+files/libopus0_1.0.1-0ubuntu2_amd64.deb
$ wget https://launchpadlibrarian.net/205263953/libwebp5_0.4.1-1.2pmo1%7Eprecise_amd64.deb
$ dpkg -i libfdk-aac0_0.1.1+20130514-2_amd64.deb
$ dpkg -i libopus0_1.0.1-0ubuntu2_amd64.deb
$ dpkg -i libwebp5_0.4.1-1.2pmo1~precise_amd64.deb

$ apt-get install -y git build-essential libargtable2-dev libsdl1.2-dev
$ apt-get install -y ffmpeg-opti libavformat-ffmpeg-opti-dev
```

### Building static binaries

You can build a static binary by passing the `--enable-static` parameter to `configure`, but beware the following caveats:
### Installation
Due to bug in FFmpeg6 not providing required `mem_internal.h` file in MacPorts
installation I attached it here. Copy this to
`/opt/local/libexec/ffmpeg6/include/libavutil` and run `bash autogen.sh && ./configure &&
make`

- True static linking on Mac OS X is not supported by Apple. Do not use the `--enable-static` directive on OS X. Rather, use the script [matryoshka-name-tool](https://github.com/essandess/matryoshka-name-tool) to use OS X's `install_name_tool` to modify the comskip binary and create a directory of shared libraries that may be distributed to users without homebrew or Macports installations. The project [etv-comskip](https://github.com/essandess/etv-comskip) has an example [Makefile](https://github.com/essandess/etv-comskip/blob/master/Makefile) using matryoshka-name-tool.

- Some libraries have incomplete or incorrect dependencies listed in their pkgconfig files. If static linking fails on your system, you'll need to override these by manually specifying the `argtable2_LIBS`, `ffmpeg_LIBS`, and `sdl_LIBS` environment variables with the required list of libraries and their locations.

### Ini file

You can find ini files at:
http://www.kaashoek.com/comskip/
<http://www.kaashoek.com/comskip/>
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ artifacts:
before_build:
- git log -1
- cd C:\projects\comskip
- appveyor DownloadFile https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.4.1-full_build-shared.7z
- appveyor DownloadFile https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.0.1-full_build-shared.7z
- appveyor DownloadFile https://downloads.sourceforge.net/project/argtable/argtable/argtable-2.13/argtable2-13.tar.gz

build_script:
- 7z x ffmpeg-4.4.1-full_build-shared.7z
- 7z x ffmpeg-5.0.1-full_build-shared.7z
- C:\msys64\usr\bin\bash -lc "cd /c/projects/comskip && tar xf argtable2-13.tar.gz && cd argtable2-13 && ./configure --build=x86_64-w64-mingw32 && make"
- C:\msys64\usr\bin\bash -lc "cd /c/projects/comskip && ./autogen.sh && argtable2_CFLAGS='-Iargtable2-13/src' argtable2_LIBS='-Largtable2-13/src/.libs -largtable2' ffmpeg_CFLAGS='-Iffmpeg-4.4.1-full_build-shared/include' ffmpeg_LIBS='-Lffmpeg-4.4.1-full_build-shared/lib -lavutil -lavformat -lavcodec -lswscale' ./configure && make"
- C:\msys64\usr\bin\bash -lc "cd /c/projects/comskip && ./autogen.sh && argtable2_CFLAGS='-Iargtable2-13/src' argtable2_LIBS='-Largtable2-13/src/.libs -largtable2' ffmpeg_CFLAGS='-Iffmpeg-5.0.1-full_build-shared/include' ffmpeg_LIBS='-Lffmpeg-5.0.1-full_build-shared/lib -lavutil -lavformat -lavcodec -lswscale' ./configure && make"

before_test:
- C:\msys64\usr\bin\bash -lc "cd /c/projects/comskip && export PATH=$(pwd)/ffmpeg-4.4.1-full_build-shared/bin/:$PATH && ls -alh comskip.exe && ldd comskip.exe"
- C:\msys64\usr\bin\bash -lc "cd /c/projects/comskip && export PATH=$(pwd)/ffmpeg-5.0.1-full_build-shared/bin/:$PATH && ls -alh comskip.exe && ldd comskip.exe"
- appveyor DownloadFile https://s3.amazonaws.com/tmm1/ten-copy.mkv

test_script:
- SET PATH=C:\projects\comskip\ffmpeg-4.4.1-full_build-shared\bin;%PATH%
- SET PATH=C:\projects\comskip\ffmpeg-5.0.1-full_build-shared\bin;%PATH%
- comskip ten-copy.mkv
- cat ten-copy.txt
- grep "9361\s17922" ten-copy.txt
6 changes: 3 additions & 3 deletions comskip.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ int sceneChangePercent;
bool lastFrameWasBlack = false;
bool lastFrameWasSceneChange = false;

#include <libavutil/avutil.h> // only for DECLARE_ALIGNED
#include <libavutil/avutil.h>
#include <libavutil/mem_internal.h> // only for DECLARE_ALIGNED
static DECLARE_ALIGNED(32, long, histogram)[256];
static DECLARE_ALIGNED(32, long, lastHistogram)[256];

Expand Down Expand Up @@ -976,7 +977,7 @@ int FindBlackThreshold(double percentile);
int FindUniformThreshold(double percentile);
void OutputFrameArray(bool screenOnly);
void OutputBlackArray();
void OutputFrame();
void OutputFrame(int frame_number);
void OpenOutputFiles();
void InitializeFrameArray(long i);
void InitializeBlackArray(long i);
Expand Down Expand Up @@ -13832,7 +13833,6 @@ return;
}



void OutputFrameArray(bool screenOnly)
{
int i;
Expand Down
13 changes: 11 additions & 2 deletions comskip.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#ifndef COMSKIP
#define COMSKIP
#endif
#ifdef _WIN32

#define PACKAGE_STRING "Comskip 0.82.011"


#define _UNICODE

#ifndef PACKAGE_STRING
#define PACKAGE_STRING " Comskip 0.82.011"
#endif
#define _UNICODE

#define MAXWIDTH 8000
#define MAXHEIGHT 4800

#ifndef PROCESS_CC
#define PROCESS_CC "true"
#endif
7 changes: 7 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,10 @@
#define ENABLE_FAST_CMOV 1
#define HAVE_FAST_CMOV 1
#endif

#ifdef ARCH_ARM64
#define ENABLE_CMOV 1
#define HAVE_CMOV 1
#define ENABLE_FAST_CMOV 1
#define HAVE_FAST_CMOV 1
#endif
138 changes: 138 additions & 0 deletions mem_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2002 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef AVUTIL_MEM_INTERNAL_H
#define AVUTIL_MEM_INTERNAL_H

#include "config.h"

#include <stdint.h>

#include "attributes.h"
#include "macros.h"
#include "mem.h"
#include "version.h"

/**
* @def DECLARE_ALIGNED(n,t,v)
* Declare a variable that is aligned in memory.
*
* @code{.c}
* DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
* DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
*
* // The default-alignment equivalent would be
* uint16_t aligned_int = 42;
* uint8_t aligned_array[128];
* @endcode
*
* @param n Minimum alignment in bytes
* @param t Type of the variable (or array element)
* @param v Name of the variable
*/

/**
* @def DECLARE_ASM_ALIGNED(n,t,v)
* Declare an aligned variable appropriate for use in inline assembly code.
*
* @code{.c}
* DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
* @endcode
*
* @param n Minimum alignment in bytes
* @param t Type of the variable (or array element)
* @param v Name of the variable
*/

/**
* @def DECLARE_ASM_CONST(n,t,v)
* Declare a static constant aligned variable appropriate for use in inline
* assembly code.
*
* @code{.c}
* DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
* @endcode
*
* @param n Minimum alignment in bytes
* @param t Type of the variable (or array element)
* @param v Name of the variable
*/

#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
#define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
#define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
#elif defined(__DJGPP__)
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
#elif defined(__GNUC__) || defined(__clang__)
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
#elif defined(_MSC_VER)
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
#define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
#else
#define DECLARE_ALIGNED(n,t,v) t v
#define DECLARE_ASM_ALIGNED(n,t,v) t v
#define DECLARE_ASM_CONST(n,t,v) static const t v
#endif

// Some broken preprocessors need a second expansion
// to be forced to tokenize __VA_ARGS__
#define E1(x) x

#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
uint8_t la_##v[sizeof(t s o) + (a)]; \
t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)

#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
DECLARE_ALIGNED(a, t, la_##v) s o; \
t (*v) o = la_##v

#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)

#if HAVE_LOCAL_ALIGNED
# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,))
#else
# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))
#endif

#if HAVE_LOCAL_ALIGNED
# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
#else
# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))
#endif

#if HAVE_LOCAL_ALIGNED
# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
#else
# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))
#endif

#if HAVE_LOCAL_ALIGNED
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,))
#else
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
#endif

#endif /* AVUTIL_MEM_INTERNAL_H */
Loading