Skip to content

Commit 81a7efd

Browse files
authored
Merge pull request #174 from phunkyfish/ffmpeg7-changes
Build comskip with ffmpeg7
2 parents 2ef8684 + cd5fce3 commit 81a7efd

File tree

6 files changed

+125
-6
lines changed

6 files changed

+125
-6
lines changed

.github/workflows/build.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- os: ubuntu-latest
12+
platform: linux
13+
- os: macos-latest
14+
platform: macos
15+
ffmpeg_version: ffmpeg5
16+
- os: macos-latest
17+
platform: macos
18+
ffmpeg_version: ffmpeg6
19+
- os: macos-latest
20+
platform: macos
21+
ffmpeg_version: ffmpeg7
22+
- os: windows-latest
23+
platform: windows-mingw
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup
29+
shell: bash
30+
run: |
31+
setupScript='ci/${{ matrix.platform }}/setup.sh'
32+
[ ! -f "$setupScript" ] || "$setupScript"
33+
34+
- name: Configure Apt packages
35+
if: ${{ matrix.platform == 'linux' }}
36+
run: |
37+
sudo apt-get install -y autoconf libtool git build-essential libargtable2-dev libavformat-dev libswscale-dev libsdl1.2-dev
38+
39+
- name: Configure Brew packages ffmpeg7
40+
if: ${{ matrix.ffmpeg_version == 'ffmpeg7' }}
41+
run: |
42+
brew install autoconf automake libtool pkgconfig argtable ffmpeg sdl
43+
44+
- name: Configure Brew packages ffmpeg6
45+
if: ${{ matrix.ffmpeg_version == 'ffmpeg6' }}
46+
run: |
47+
brew install autoconf automake libtool pkgconfig argtable ffmpeg@6 sdl
48+
brew link ffmpeg@6
49+
50+
- name: Configure Brew packages ffmpeg5
51+
if: ${{ matrix.ffmpeg_version == 'ffmpeg5' }}
52+
run: |
53+
brew install autoconf automake libtool pkgconfig argtable ffmpeg@5 sdl
54+
brew link ffmpeg@5
55+
56+
- name: Setup msys2
57+
uses: msys2/setup-msys2@v2
58+
if: ${{ matrix.platform == 'windows-mingw' }}
59+
with:
60+
update: true
61+
install: >-
62+
mingw-w64-x86_64-gcc
63+
mingw-w64-x86_64-make
64+
mingw-w64-x86_64-autotools
65+
mingw-w64-x86_64-libtool
66+
mingw-w64-x86_64-pkg-config
67+
mingw-w64-x86_64-yasm
68+
mingw-w64-x86_64-argtable
69+
mingw-w64-x86_64-ffmpeg
70+
- name: Put MSYS2_MinGW64 on PATH
71+
if: ${{ matrix.platform == 'windows-mingw' }}
72+
run: |
73+
echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
74+
75+
- name: Configure and build Posix
76+
if: ${{ matrix.platform != 'windows-mingw' }}
77+
run: |
78+
./autogen.sh
79+
./configure
80+
make
81+
82+
- name: Configure and build Windows
83+
if: ${{ matrix.platform == 'windows-mingw' }}
84+
run: |
85+
msys2 -c './autogen.sh'
86+
msys2 -c './configure'
87+
msys2 -c 'make'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ autom4te.cache
2121
compile
2222
config.*
2323
configure
24+
configure~
2425
depcomp
2526
install-sh
2627
missing

comskip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "platform.h"
1717
#include "vo.h"
1818
#include <argtable2.h>
19+
#include <pthread.h>
1920

2021

2122
#include <libavformat/avformat.h>

mpeg2dec.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,14 @@ void sound_to_frames(VideoState *is, short **b, int s, int c, int format)
575575
for (l=0;l < c;l++ ) volume += *((fb[l])++) * 64000;
576576
else
577577
for (l=0;l < c;l++ ) volume += *((fb[0])++) * 64000;
578+
#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
579+
LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
580+
*audio_buffer_ptr++ = volume / is->audio_st->codecpar->ch_layout.nb_channels;
581+
avg_volume += abs(volume / is->audio_st->codecpar->ch_layout.nb_channels);
582+
#else
578583
*audio_buffer_ptr++ = volume / is->audio_st->codecpar->channels;
579584
avg_volume += abs(volume / is->audio_st->codecpar->channels);
585+
#endif
580586
}
581587
}
582588
else
@@ -592,8 +598,14 @@ void sound_to_frames(VideoState *is, short **b, int s, int c, int format)
592598
for (l=0;l < c;l++ ) volume += *((sb[l])++);
593599
else
594600
for (l=0;l < c;l++ ) volume += *((sb[0])++);
601+
#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
602+
LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
603+
*audio_buffer_ptr++ = volume / is->audio_st->codecpar->ch_layout.nb_channels;
604+
avg_volume += abs(volume / is->audio_st->codecpar->ch_layout.nb_channels);
605+
#else
595606
*audio_buffer_ptr++ = volume / is->audio_st->codecpar->channels;
596607
avg_volume += abs(volume / is->audio_st->codecpar->channels);
608+
#endif
597609
}
598610
}
599611
}
@@ -769,7 +781,19 @@ void audio_packet_process(VideoState *is, AVPacket *pkt)
769781
}
770782

771783

772-
784+
#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
785+
LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
786+
data_size = av_samples_get_buffer_size(NULL, is->frame->ch_layout.nb_channels,
787+
is->frame->nb_samples,
788+
is->frame->format, 1);
789+
if (data_size > 0)
790+
{
791+
sound_to_frames(is, (short **)is->frame->data, is->frame->nb_samples ,is->frame->ch_layout.nb_channels, is->frame->format);
792+
}
793+
is->audio_clock += (double)data_size /
794+
(is->frame->ch_layout.nb_channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format));
795+
av_frame_unref(is->frame);
796+
#else
773797
data_size = av_samples_get_buffer_size(NULL, is->frame->channels,
774798
is->frame->nb_samples,
775799
is->frame->format, 1);
@@ -780,6 +804,7 @@ void audio_packet_process(VideoState *is, AVPacket *pkt)
780804
is->audio_clock += (double)data_size /
781805
(is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format));
782806
av_frame_unref(is->frame);
807+
#endif
783808
}
784809

785810
if (ALIGN_AC3_PACKETS && is->audio_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
@@ -1033,6 +1058,10 @@ void DoSeekRequest(VideoState *is)
10331058
if(ret < 0)
10341059
{
10351060
char *error_text;
1061+
#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
1062+
LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
1063+
error_text = "Generic";
1064+
#else
10361065
if (is->pFormatCtx->iformat->read_seek)
10371066
{
10381067
error_text = "Format specific";
@@ -1045,6 +1074,7 @@ void DoSeekRequest(VideoState *is)
10451074
{
10461075
error_text = "Generic";
10471076
}
1077+
#endif
10481078

10491079
fprintf(stderr, "%s error while seeking. target=%6.3f, \"%s\"\n", error_text,is->seek_pts, is->pFormatCtx->url);
10501080

platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef unsigned char uint8_t;
7474
typedef unsigned short uint16_t;
7575
typedef unsigned int uint32_t;
7676
typedef unsigned __int64 uint64_t;
77-
#ifndef HARDWARE_DECODE
77+
#if !defined(HARDWARE_DECODE) && !defined(__MINGW64__)
7878
#include <compat/w32pthreads.h> // Is already defined in ffmpeg
7979
#endif
8080

video_out_dx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static int create_window (dx_instance_t * instance)
541541
/* store a directx_instance pointer into the window local storage
542542
* (for later use in event_handler).
543543
* We need to use SetWindowLongPtr when it is available in mingw */
544-
SetWindowLongPtr (instance->window, GWLP_USERDATA, instance);
544+
SetWindowLongPtr (instance->window, GWLP_USERDATA, (LONG_PTR) instance);
545545
SetWindowPos(instance->window, HWND_TOP, 100, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE);
546546

547547
ShowWindow (instance->window, SW_SHOW);
@@ -928,13 +928,13 @@ void vo_init(int width, int height, char *title)
928928
memset(buf2,128,width*height);
929929

930930
#ifdef RGB
931-
instance = vo_dxrgb_open();
932-
hWind = instance;
931+
instance = (dx_instance_t *) vo_dxrgb_open();
932+
hWind = (HWND) instance;
933933
strcpy(instance->title, title);
934934
dxrgb_setup( instance, width, height, width, height, &result);
935935
// dx_setup_fbuf ( instance, buffer, &result);
936936
#else
937-
instance = vo_dx_open();
937+
instance = (HWND) vo_dx_open();
938938
strcpy(instance->title, title);
939939
dx_setup( instance, width, height, width, height, &result);
940940
#endif

0 commit comments

Comments
 (0)