Skip to content
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
110 changes: 110 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: test
run-name: ${{ github.workflow }} - ${{ github.sha }}
on:
push:
branches: [ main, up ]
pull_request:
branches: [ main, up ]
workflow_dispatch:


jobs:
ffvvc-test:
name: ffvvc-test / ${{ matrix.os.name }}/${{ matrix.compiler.name }}/${{ matrix.assembler.name }}
env:
configure_flags: --enable-ffmpeg --disable-everything --enable-decoder=vvc --enable-parser=vvc --enable-demuxer=vvc --enable-protocol=file,pipe --enable-encoder=rawvideo,wrapped_avframe --enable-muxer=rawvideo,md5,null
strategy:
fail-fast: false
matrix:
os:
- { name: linux, runner: ubuntu-latest, shell: bash, runner_threads: 4 }
- { name: windows, runner: windows-latest, shell: 'msys2 {0}', runner_threads: 1 }
compiler:
- { name: gcc, flags: --cc=gcc }
- { name: clang, flags: --cc=clang }
- { name: msvc, flags: --toolchain=msvc }
- { name: clang-usan, flags: '--toolchain=clang-usan' }
- { name: clang-asan, flags: '--toolchain=clang-asan' }
assembler:
- { name: no asm, flags: --disable-asm }
- { name: yasm, flags: --as=yasm }
- { name: nasm, flags: --as=nasm }
exclude:
# GitHub's Actions runners do not support AVX2.
- os: { name: linux, runner: ubuntu-latest, shell: bash, runner_threads: 4}
compiler: { name: msvc, flags: --toolchain=msvc }
- os: { name: linux, runner: ubuntu-latest, shell: bash, runner_threads: 4 }
assembler: { name: yasm, flags: --as=yasm }
- os: { name: linux, runner: ubuntu-latest, shell: bash, runner_threads: 4 }
assembler: { name: nasm, flags: --as=nasm }
# Address sanitizer cannot be run with handwritten assembly.
- compiler: { name: clang-asan, flags: '--toolchain=clang-asan' }
assembler: { name: nasm, flags: --as=nasm }
- compiler: { name: clang-asan, flags: '--toolchain=clang-asan' }
assembler: { name: yasm, flags: --as=yasm }
# Windows only supports MSVC.
- os: { name: windows, runner: windows-latest, shell: 'msys2 {0}', runner_threads: 1 }
compiler: { name: gcc, flags: --cc=gcc }
- os: { name: windows, runner: windows-latest, shell: 'msys2 {0}', runner_threads: 1 }
compiler: { name: clang, flags: --cc=clang }
- os: { name: windows, runner: windows-latest, shell: 'msys2 {0}', runner_threads: 1 }
compiler: { name: clang-usan, flags: '--toolchain=clang-usan' }
- os: { name: windows, runner: windows-latest, shell: 'msys2 {0}', runner_threads: 1 }
compiler: { name: clang-asan, flags: '--toolchain=clang-asan' }

runs-on: ${{ matrix.os.runner }}
defaults:
run:
shell: ${{ matrix.os.shell }}

steps:
- name: Get MSVC
if: ${{ matrix.compiler.name == 'msvc' && matrix.os.name == 'windows' }}
uses: ilammy/msvc-dev-cmd@v1

- name: Set up MSYS2
if: ${{ matrix.os.shell == 'msys2 {0}' }}
uses: msys2/setup-msys2@v2
with:
release: false
msystem: UCRT64
path-type: inherit
install: >-
make
diffutils

- name: Setup python package
run: python3 -m pip install tqdm pyyaml

- name: Get assembler
if: ${{ matrix.os.shell == 'msys2 {0}' && matrix.assembler.name != 'no asm' }}
run: pacman --noconfirm -S ${{ matrix.assembler.name }}

- name: Get source
uses: actions/checkout@v3
with:
path: FFmpeg

- name: Configure
run: cd FFmpeg && ./configure ${{ matrix.compiler.flags }} ${{ matrix.assembler.flags }} ${{ env.configure_flags }} || (tail ffbuild/config.log; false)

- name: Build
run: cd FFmpeg && make -j8

- name: Get tests
uses: actions/checkout@v3
with:
repository: ffvvc/tests
path: tests

- name: Unit test
run: python3 tests/tools/ffmpeg.py --threads ${{ matrix.os.runner_threads }} --ffmpeg-path=./FFmpeg/ffmpeg tests/conformance/passed

- name: Check ASM
run: cd FFmpeg && make checkasm -j && ./tests/checkasm/checkasm

- name: Negative test
run: python3 tests/tools/ffmpeg.py --threads ${{ matrix.os.runner_threads }} --ffmpeg-path=./FFmpeg/ffmpeg tests/conformance/failed || true

- name: Check for fuzz regressions
run: python3 tests/tools/ffmpeg.py --threads ${{ matrix.os.runner_threads }} --ffmpeg-path=./FFmpeg/ffmpeg --no-output-check --allow-decode-error tests/fuzz/passed
2 changes: 1 addition & 1 deletion libavcodec/cabac_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
}
#endif

#ifndef get_cabac_inline
#if !defined(get_cabac_inline) || !defined(refill2)
static void refill2(CABACContext *c){
int i;
unsigned x;
Expand Down
28 changes: 1 addition & 27 deletions libavcodec/vvc/cabac.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,32 +856,6 @@ int ff_vvc_cabac_init(VVCLocalContext *lc,
return ret;
}

//fixme
static void vvc_refill2(CABACContext* c) {
int i;
unsigned x;
#if !HAVE_FAST_CLZ
x = c->low ^ (c->low - 1);
i = 7 - ff_h264_norm_shift[x >> (CABAC_BITS - 1)];
#else
i = ff_ctz(c->low) - CABAC_BITS;
#endif

x = -CABAC_MASK;

#if CABAC_BITS == 16
x += (c->bytestream[0] << 9) + (c->bytestream[1] << 1);
#else
x += c->bytestream[0] << 1;
#endif

c->low += x << i;
#if !UNCHECKED_BITSTREAM_READER
if (c->bytestream < c->bytestream_end)
#endif
c->bytestream += CABAC_BITS / 8;
}

static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int ctx)
{
VVCCabacState *s = base + ctx;
Expand All @@ -904,7 +878,7 @@ static int inline vvc_get_cabac(CABACContext *c, VVCCabacState* base, const int
c->low <<= lps_mask;

if (!(c->low & CABAC_MASK))
vvc_refill2(c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember this will introduce some build errors for the window

could you "git cherry-pick ..ffvvc/workflow" and force-push your branch?
So we can now see the windows result

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I also tried it on Windows and everything works

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! please send to maling list for review.
thank you

refill2(c);
s->state[0] = s->state[0] - (s->state[0] >> s->shift[0]) + (1023 * bit >> s->shift[0]);
s->state[1] = s->state[1] - (s->state[1] >> s->shift[1]) + (16383 * bit >> s->shift[1]);
return bit;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/vvc/dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ static void export_frame_params(VVCContext *s, const VVCFrameContext *fc)
c->coded_height = pps->height;
c->width = pps->width - ((pps->r->pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]);
c->height = pps->height - ((pps->r->pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]);
c->has_b_frames = sps->r->sps_dpb_params.dpb_max_num_reorder_pics[sps->r->sps_max_sublayers_minus1];
}

static int frame_setup(VVCFrameContext *fc, VVCContext *s)
Expand Down
28 changes: 14 additions & 14 deletions libavcodec/vvc/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
#include <stdint.h>
#include <stddef.h>

enum TxType {
DCT2,
DST7,
DCT8,
N_TX_TYPE,
enum VVCTxType {
VVC_DCT2,
VVC_DST7,
VVC_DCT8,
VVC_N_TX_TYPE,
};

enum TxSize {
TX_SIZE_2,
TX_SIZE_4,
TX_SIZE_8,
TX_SIZE_16,
TX_SIZE_32,
TX_SIZE_64,
N_TX_SIZE,
enum VVCTxSize {
VVC_TX_SIZE_2,
VVC_TX_SIZE_4,
VVC_TX_SIZE_8,
VVC_TX_SIZE_16,
VVC_TX_SIZE_32,
VVC_TX_SIZE_64,
VVC_N_TX_SIZE,
};

typedef struct VVCInterDSPContext {
Expand Down Expand Up @@ -127,7 +127,7 @@ typedef struct VVCItxDSPContext {
void (*add_residual_joint)(uint8_t *dst, const int *res, int width, int height, ptrdiff_t stride, int c_sign, int shift);
void (*pred_residual_joint)(int *buf, int width, int height, int c_sign, int shift);

void (*itx[N_TX_TYPE][N_TX_SIZE])(int *coeffs, ptrdiff_t step, size_t nz);
void (*itx[VVC_N_TX_TYPE][VVC_N_TX_SIZE])(int *coeffs, ptrdiff_t step, size_t nz);
void (*transform_bdpcm)(int *coeffs, int width, int height, int vertical, int log2_transform_range);
} VVCItxDSPContext;

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/vvc/dsp_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void FUNC(transform_bdpcm)(int *coeffs, const int width, const int height
static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx)
{
#define VVC_ITX(TYPE, type, s) \
itx->itx[TYPE][TX_SIZE_##s] = ff_vvc_inv_##type##_##s; \
itx->itx[VVC_##TYPE][VVC_##TX_SIZE_##s] = ff_vvc_inv_##type##_##s; \

#define VVC_ITX_COMMON(TYPE, type) \
VVC_ITX(TYPE, type, 4); \
Expand Down
26 changes: 13 additions & 13 deletions libavcodec/vvc/intra.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ static void ilfnst_transform(const VVCLocalContext *lc, TransformBlock *tb)
}

//part of 8.7.4 Transformation process for scaled transform coefficients
static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum TxType *trh, enum TxType *trv)
static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum VVCTxType *trh, enum VVCTxType *trv)
{
const CodingUnit *cu = lc->cu;
static const enum TxType mts_to_trh[] = {DCT2, DST7, DCT8, DST7, DCT8};
static const enum TxType mts_to_trv[] = {DCT2, DST7, DST7, DCT8, DCT8};
static const enum VVCTxType mts_to_trh[] = { VVC_DCT2, VVC_DST7, VVC_DCT8, VVC_DST7, VVC_DCT8 };
static const enum VVCTxType mts_to_trv[] = { VVC_DCT2, VVC_DST7, VVC_DST7, VVC_DCT8, VVC_DCT8 };
const VVCSPS *sps = fc->ps.sps;
int implicit_mts_enabled = 0;
if (tb->c_idx || (cu->isp_split_type != ISP_NO_SPLIT && cu->lfnst_idx)) {
*trh = *trv = DCT2;
*trh = *trv = VVC_DCT2;
return;
}

Expand All @@ -152,11 +152,11 @@ static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalConte
const int w = tb->tb_width;
const int h = tb->tb_height;
if (cu->sbt_flag) {
*trh = (cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? DST7 : DCT8;
*trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? DST7 : DCT8;
*trh = (cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
*trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
} else {
*trh = (w >= 4 && w <= 16) ? DST7 : DCT2;
*trv = (h >= 4 && h <= 16) ? DST7 : DCT2;
*trh = (w >= 4 && w <= 16) ? VVC_DST7 : VVC_DCT2;
*trv = (h >= 4 && h <= 16) ? VVC_DST7 : VVC_DCT2;
}
return;
}
Expand Down Expand Up @@ -447,7 +447,7 @@ static void dequant(const VVCLocalContext *lc, const TransformUnit *tu, Transfor

//transmatrix[0][0]
#define DCT_A 64
static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
{
const VVCSPS *sps = fc->ps.sps;
const int w = tb->tb_width;
Expand All @@ -456,7 +456,7 @@ static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxT
const size_t nzh = tb->max_scan_y + 1;
const int shift[] = { 7, 5 + sps->log2_transform_range - sps->bit_depth };

if (w == h && nzw == 1 && nzh == 1 && trh == DCT2 && trv == DCT2) {
if (w == h && nzw == 1 && nzh == 1 && trh == VVC_DCT2 && trv == VVC_DCT2) {
const int add[] = { 1 << (shift[0] - 1), 1 << (shift[1] - 1) };
const int t = (tb->coeffs[0] * DCT_A + add[0]) >> shift[0];
const int dc = (t * DCT_A + add[1]) >> shift[1];
Expand All @@ -476,15 +476,15 @@ static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxT
scale(tb->coeffs, tb->coeffs, w, h, shift[1]);
}

static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
{
const VVCSPS *sps = fc->ps.sps;
const int w = tb->tb_width;
const int h = tb->tb_height;
const size_t nzw = tb->max_scan_x + 1;
const size_t nzh = tb->max_scan_y + 1;

if ((w > 1 && nzw == 1 && trh == DCT2) || (h > 1 && nzh == 1 && trv == DCT2)) {
if ((w > 1 && nzw == 1 && trh == VVC_DCT2) || (h > 1 && nzh == 1 && trv == VVC_DCT2)) {
const int shift = 6 + sps->log2_transform_range - sps->bit_depth;
const int add = 1 << (shift - 1);
const int dc = (tb->coeffs[0] * DCT_A + add) >> shift;
Expand Down Expand Up @@ -542,7 +542,7 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx,
transform_bdpcm(tb, lc, cu);
dequant(lc, tu, tb);
if (!tb->ts) {
enum TxType trh, trv;
enum VVCTxType trh, trv;

if (cu->apply_lfnst_flag[c_idx])
ilfnst_transform(lc, tb);
Expand Down
3 changes: 0 additions & 3 deletions libavcodec/vvc_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ static void set_parser_ctx(AVCodecParserContext *s, AVCodecContext *avctx,
avctx->color_range =
sps->vui.vui_full_range_flag ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;

avctx->has_b_frames =
sps->sps_dpb_params.dpb_max_num_reorder_pics[sps->sps_max_sublayers_minus1];

if (sps->sps_ptl_dpb_hrd_params_present_flag &&
sps->sps_timing_hrd_params_present_flag) {
uint32_t num = sps->sps_general_timing_hrd_parameters.num_units_in_tick;
Expand Down