GithubHelp home page GithubHelp logo

pkuvcl / davs2 Goto Github PK

View Code? Open in Web Editor NEW
128.0 13.0 52.0 990 KB

An open-source decoder of AVS2-P2/IEEE1857.4 video coding standard

License: GNU General Public License v2.0

C 8.04% C++ 59.83% Assembly 31.78% Shell 0.09% Makefile 0.26%

davs2's Introduction

davs2

davs2 is an open-source decoder of AVS2-P2/IEEE1857.4 video coding standard.

An encoder, xavs2, can be found at Github or Gitee (mirror in China).

GitHub tag GitHub issues GitHub forks GitHub stars

Linux(Ubuntu-16.04):Travis Build Status Windows(VS2013):AppVeyor Build Status

Stargazers over time Stargazers over time

Compile it

Windows

Use VS2013 or latest version of visual studio open the ./build/vs2013/davs2.sln solution and set the davs2 as the start project.

Notes

  1. A shell executor, i.e. the bash in git for windows, is needed and should be found in PATH variable. For example, the path C:\Program Files\Git\bin can be added if git-for-windows is installed.
  2. nasm.exe with version 2.13 (or later version) is needed and should be put into the PATH directory. For windows platform, you can downloaded the packege and unpack the zip file to get nasm.exe: https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip

Linux

$ cd build/linux
$ ./configure
$ make

Try it

Decode AVS2 stream test.avs with 1 thread and output to a YUV file named dec.yuv.

./davs2 -i test.avs -t 1 -o dec.yuv

Decode AVS2 stream test.avs and display the decoding result via ffplay.

./davs2 -i test.avs -t 1 -o stdout | ffplay -i -

Parameter Instructions

Parameter Alias Result
--input=test.avs -i test.avs Setting the input bitstream file
--output=dec.yuv -o dec.yuv Setting the output YUV file
--psnr=rec.yuv -r rec.yuv Setting the reference reconstruction YUV file
--threads=N -t N Setting the threads for decoding (default: 1)
--md5=M -m M Reference MD5, used to check whether the output YUV is right
--verbose -v Enable decoding status every frame (Default: Enabled)
--help -h Showing this instruction

Issue and Pull Request

Issues should be reported here

If you have some bugs fixed or features implemented, and would like to share with the public, please make a Pull Request.

Homepages

PKU-VCL

AVS2-P2/IEEE1857.4 Encoder: xavs2 (Github), xavs2 (mirror in China)

AVS2-P2/IEEE1857.4 Decoder: davs2 (Github), davs2 (mirror in China)

davs2's People

Contributors

404networkerror avatar dbermond avatar hwrenx avatar knightmet avatar luofalei avatar ua0lnj avatar xuyiqun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

davs2's Issues

make -j8编译失败在aarch64平台

我遇到一个问题,关于在centos8 aarch64平台移植xavs2出现的问题,如下所示:

[root@centos8 linux]# ./configure --prefix=$build_dir/avs2_lib --enable-pic --enable-shared
platform:      AARCH64
byte order:    little-endian
system:        LINUX
cli:           yes
libxavs2:      internal
shared:        yes
static:        yes
asm:           yes
interlaced:    yes
avs:           no
lavf:          no
ffms:          no
mp4:           no
gpl:           yes
thread:        posix
opencl:        no
filters:       crop select_every
lto:           no
debug:         no
gprof:         no
strip:         no
PIC:           yes
bit depth:     8
chroma format: all

You can run 'make' or 'make fprofiled' now.
[root@centos8 linux]# make -j8
\033[33m dependency file generation... \033[0m
gcc: error: /root/AVS2/buildFFmpegAVS2/davs2/source/common/aarch64/asm-offsets.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
gcc: error: /root/AVS2/buildFFmpegAVS2/davs2/source/common/aarch64/mc-c.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
gcc: error: /root/AVS2/buildFFmpegAVS2/davs2/source/common/aarch64/predict-c.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
……
rch64/pixel-a.o common/aarch64/predict-a.o common/aarch64/quant-a.o
gcc: error: common/aarch64/asm-offsets.o: No such file or directory
gcc: error: common/aarch64/mc-c.o: No such file or directory
gcc: error: common/aarch64/predict-c.o: No such file or directory
gcc: error: common/aarch64/bitstream-a.o: No such file or directory
gcc: error: common/aarch64/cabac-a.o: No such file or directory
gcc: error: common/aarch64/dct-a.o: No such file or directory
gcc: error: common/aarch64/deblock-a.o: No such file or directory
gcc: error: common/aarch64/mc-a.o: No such file or directory
gcc: error: common/aarch64/pixel-a.o: No such file or directory
gcc: error: common/aarch64/predict-a.o: No such file or directory
gcc: error: common/aarch64/quant-a.o: No such file or directory
make: *** [Makefile:224: libdavs2.so.13] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ar: common/aarch64/asm-offsets.o: No such file or directory
make: *** [Makefile:219: libdavs2.a] Error 1

现在我看到configure以及Makefile里头关于这方面的描述:
vim configure:
image
这里中间缺少了拉取common/aarch64的步骤。
vim Makefile:
image
由于common/aarch64里头没有这些文件,导致编译失败。

你能够告诉我如何才能够下载到上面那些文件么?(包括xavs2也报这样的错误)

Using option --help fails (and no option does not fail)

Executing davs2 -h or `davs2 --help`` emits help text twice and then fails with "missing input file."

Execting davs2emits help once and succeeds.

I would expect --help to succeed (emitting help only once), and no option to fail.

linux configure $CFLAGS 环境变量导致大小端测试失败("endian test failed")

Describe the bug

linux环境下,在build/linux/目录下,执行./configure,当存在“CFLAGS”环境变量时,会干扰大小端的测试,导致configure失败,终端输出“endian test failed”

To Reproduce

设置环境变量CFLAGS:
export CFLAGS="-march=native -O2 -ftree-loop-vectorize -pipe -fstack-protector-strong -fstack-clash-protection -fno-plt -fexceptions -fasynchronous-unwind-tables -flto -grecord-gcc-switches"
执行./configure
输出:endian test failed

Expected behavior

在编译发布版本时,使用上述CFLAGS以获得更好的优化是很常见的,configure不应当因此而失败。

Screenshots

image

Desktop (please complete the following information):

  • OS: Arch Linux
  • Compiler: gcc (GCC) 10.2.0
  • yasm: 1.3.0

个人解决方案:
见附件
fix-endian-test-failed-with-cflags.patch.txt

Decode Fail Bug

root@iZuf6a76txemsleel0sc9hZ:~/avs2# davs2 -i 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.avs -o 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.yuv --threads=1
davs2 -i 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.avs -o 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.yuv --threads=1


AVS2 file : 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.avs
Reference file : (null)
Output file : 电影-动作片_镜头切换频繁_3mins_avs_cqp_13_0_16.yuv

[davs2 info]: davs2: 1.5.131 1db2b48.8, 2018-10-31 12:51:42
[davs2 info]: CPU Capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[davs2 info]: Manager 7fa76003f020: using 1 thread(s): 1(frame/AEC)+0(pool/REC), 2 tasks
[davs2 info]: Manager 7fa76003f020: Sequence Resolution: 1920x1080.
Sequence size: 1920x1080; BitDepth: 8/8, FrameRate: 30.000 Hz

[davs2 debug]: Dec[ 1] 7fa7600443c0: discontinuous COI (prev: 137 --> curr: 137).
davs2: /root/davs2/source/common/decoder.cc:294: void task_send_picture_to_output_list(davs2_t*, davs2_outpic_t*): Assertion `curr == NULL || curr->frame->i_poc > pic->frame->i_poc' failed.
Aborted: 4485/4502, fps: 40.3, LeftTime: 0.422 sec

Windows x86 build failed.

1 - error compile quant8.asm:
source\common\x86\quant8.asm(48): error : mismatch in operand sizes
source\common\x86\quant8.asm(49): error : invalid combination of opcode and operands
source\common\x86\quant8.asm(54): error : invalid combination of opcode and operands

2 - error link with libdavs2_asm:
libdavs2.lib(cpu.obj) : error LNK2001: unresolved external symbol _davs2_cpu_xgetbv
and same error for all functions in .asm files.

help text is only in chinese

Help text emitted with option --help is in chinese.

Great for chinese people, but not so useful for people like me living in Europe.

Please consider adding english help - as a minimum side-by-side with the chinese, or more ideally using gettext.

Heap-buffer-overflow in vlc_read_alf_coeff() --> davs2/source/common/alf.cc:389

Describe the bug

=============================================================================================

static void vlc_read_alf_coeff(davs2_bs_t *bs, alf_param_t *alf_param)
{
const int numCoeff = ALF_MAX_NUM_COEF;
int f, symbol, pre_symbole;
int pos;

switch (alf_param->componentID) {
case IMG_U:
case IMG_V:
    for (pos = 0; pos < numCoeff; pos++) {
        alf_param->coeffmulti[0][pos] = se_v(bs, "Chroma ALF coefficients");
    }
    break;
case IMG_Y:
    alf_param->filters_per_group = ue_v(bs, "ALF filter number");
    alf_param->filters_per_group = alf_param->filters_per_group + 1;

    memset(alf_param->filterPattern, 0, ALF_NUM_VARS * sizeof(int));
    pre_symbole = 0;
    symbol = 0;
    for (f = 0; f < alf_param->filters_per_group; f++) {
        if (f > 0) {
            if (alf_param->filters_per_group != 16) {
                symbol = ue_v(bs, "Region distance");
            } else {
                symbol = 1;
            }
            alf_param->filterPattern[symbol + pre_symbole] = 1;
            pre_symbole += symbol;
        }

        for (pos = 0; pos < numCoeff; pos++) {
            alf_param->coeffmulti[f][pos] = se_v(bs, "Luma ALF coefficients");      //   <------  out of bounds here
        }
    }
    break;

=============================================================================================

To Reproduce

cd /path/to/davs2/build/linux/
./configure --enable-pic
vim config.mak (add -fsanitize=address to CFLAGS, and -fsanitize=address -lasan to LDFLAGS)
make
./davs2 -i /path/to/poc3 -o test.yuv

ASAN Crash log

=================================================================
==107031==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7fb6ae012c3c at pc 0x5600c2dccb94 bp 0x7fffa1b502f0 sp 0x7fffa1b502e0
WRITE of size 4 at 0x7fb6ae012c3c thread T0
#0 0x5600c2dccb93 in vlc_read_alf_coeff /home/arayz/arayz/work/davs2/source/common/alf.cc:389
#1 0x5600c2dccb93 in davs2_alf_read_param /home/arayz/arayz/work/davs2/source/common/alf.cc:414
#2 0x5600c2d3772b in parse_picture_header_intra /home/arayz/arayz/work/davs2/source/common/header.cc:484
#3 0x5600c2d3772b in parse_picture_header /home/arayz/arayz/work/davs2/source/common/header.cc:705
#4 0x5600c2d3772b in davs2_parse_header /home/arayz/arayz/work/davs2/source/common/header.cc:1519
#5 0x5600c2d227e1 in decoder_decode_es_unit(davs2_mgr_t*, es_unit_t*) /home/arayz/arayz/work/davs2/source/common/davs2.cc:600
#6 0x5600c2d22fd9 in davs2_decoder_send_packet /home/arayz/arayz/work/davs2/source/common/davs2.cc:676
#7 0x5600c2d20698 in test_decoder /home/arayz/arayz/work/davs2/source/test/test.c:231
#8 0x5600c2d217bc in main /home/arayz/arayz/work/davs2/source/test/test.c:329
#9 0x7fb6c28e2082 in __libc_start_main ../csu/libc-start.c:308
#10 0x5600c2d1c52d in _start (/home/arayz/arayz/work/davs2/build/linux/davs2+0xc52d)

0x7fb6ae012c3d is located 0 bytes to the right of 3028029-byte region [0x7fb6add2f800,0x7fb6ae012c3d)
allocated by thread T0 here:
#0 0x7fb6c2f2c808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x5600c2d295e9 in davs2_malloc /home/arayz/arayz/work/davs2/source/common/common.h:1240
#2 0x5600c2d295e9 in davs2_decoder_alloc_extra_buffer /home/arayz/arayz/work/davs2/source/common/decoder.cc:838
#3 0x7fb6bfb4f3bf ()

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/arayz/arayz/work/davs2/source/common/alf.cc:389 in vlc_read_alf_coeff
Shadow bytes around the buggy address:
0x0ff755bfa530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ff755bfa540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ff755bfa550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ff755bfa560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ff755bfa570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ff755bfa580: 00 00 00 00 00 00 00[05]fa fa fa fa fa fa fa fa
0x0ff755bfa590: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff755bfa5a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff755bfa5b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff755bfa5c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff755bfa5d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==107031==ABORTING

Additional context

  • OS: Ubuntu 22.04 (server)
  • Compiler gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)

PoC:
poc3.zip

Global-buffer-overflow in parse_sequence_header() --> source/common/header.cc:269

Describe the bug

Bug Relevant code as follows:

====================================================================================
static
int parse_sequence_header(davs2_mgr_t *mgr, davs2_seq_t *seq, davs2_bs_t *bs)
{
......

seq->head.bitrate    = ((seq->bit_rate_upper << 18) + seq->bit_rate_lower) * 400;
seq->head.frame_rate = FRAME_RATE[seq->head.frame_rate_id - 1];          //   <------ read overflow here

seq->i_enc_width     = ((seq->head.width + MIN_CU_SIZE - 1) >> MIN_CU_SIZE_IN_BIT) << MIN_CU_SIZE_IN_BIT;
seq->i_enc_height    = ((seq->head.height   + MIN_CU_SIZE - 1) >> MIN_CU_SIZE_IN_BIT) << MIN_CU_SIZE_IN_BIT;
seq->valid_flag = 1;

}

====================================================================================

This is a security issue.

To Reproduce

cd /path/to/davs2/build/linux/
./configure --enable-pic
vim config.mak (add -fsanitizer=address to CFLAGS, and -fsanitizer=address -lasan to LDFLAGS)
make
./davs2 -i /path/to/poc1.avs -o test.yuv

ASAN Crash log

=================================================================
==4112727==ERROR: AddressSanitizer: global-buffer-overflow on address 0x555555956808 at pc 0x5555555a44d0 bp 0x7fffffffc910 sp 0x7fffffffc900
READ of size 4 at 0x555555956808 thread T0
#0 0x5555555a44cf in parse_sequence_header /root/arayz/davs2/source/common/header.cc:269
#1 0x5555555b1ffb in davs2_parse_header /root/arayz/davs2/source/common/header.cc:1517
#2 0x555555572af9 in decoder_decode_es_unit(davs2_mgr_t*, es_unit_t*) /root/arayz/davs2/source/common/davs2.cc:600
#3 0x555555573617 in davs2_decoder_send_packet /root/arayz/davs2/source/common/davs2.cc:676
#4 0x5555555703b3 in test_decoder /root/arayz/davs2/source/test/test.c:231
#5 0x555555564fdf in main /root/arayz/davs2/source/test/test.c:329
#6 0x7ffff7096d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#7 0x7ffff7096e3f in __libc_start_main_impl ../csu/libc-start.c:392
#8 0x5555555663d4 in _start (/root/arayz/davs2/build/linux/davs2+0x123d4)

0x555555956808 is located 24 bytes to the left of global variable 'BETA_TABLE' defined in '/root/arayz/davs2/source/common/header.cc:69:22' (0x555555956820) of size 64
0x555555956808 is located 8 bytes to the right of global variable 'FRAME_RATE' defined in '/root/arayz/davs2/source/common/header.cc:121:24' (0x5555559567e0) of size 32
SUMMARY: AddressSanitizer: global-buffer-overflow /root/arayz/davs2/source/common/header.cc:269 in parse_sequence_header
Shadow bytes around the buggy address:
0x0aab2ab22cb0: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 06
0x0aab2ab22cc0: f9 f9 f9 f9 00 00 00 01 f9 f9 f9 f9 00 00 00 04
0x0aab2ab22cd0: f9 f9 f9 f9 00 00 00 00 07 f9 f9 f9 f9 f9 f9 f9
0x0aab2ab22ce0: 00 00 00 00 05 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x0aab2ab22cf0: 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x0aab2ab22d00: f9[f9]f9 f9 00 00 00 00 00 00 00 00 f9 f9 f9 f9
0x0aab2ab22d10: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
0x0aab2ab22d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0aab2ab22d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0aab2ab22d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0aab2ab22d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==4112727==ABORTING

Additional context

  • OS: Ubuntu 22.04 (server)
  • Compiler gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)

PoC:
poc1.zip

MingW64 make 报错/msys2 Make报错,请求修复。

MingW64 make failed

./configure --enable-shared

报错,无法编译呢。仅仅提供vs2013,实际应用中有些场景不支持啊,求助。

盼复

Desktop (please complete the following information):

  • OS: windows
  • Compiler gcc 9.3 nasm 2.14 yasm MingW64 msys2 MingW32
  • yasm [e.g. 1.2.0, 1.3.0-luofl]

Decoder freeze if stream is incorrect.

If stream start with 0x1b6 instead 0x1b0, decoder drop frames and freeze after receive 0x1b0.

[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;31m[davs2 error]: Dec[ 0] 7f913c35f920: failed to update decoder (invalid sequence header)..[0m
.[1;36m[davs2 info]: Manager 7f913c35ed80: Sequence Resolution: 1920x1080..[0m
.[1;36m[davs2 info]: Dec[ 0] 7f913c35f920: COI of the first frame is 41..[0m
.[1;31m[davs2 error]: Dec[ 1] 7f913c364120: reference frame of [coi: 42, poc: 44]: <COI: 33> not found..[0m
.[1;31m[davs2 error]: Failed to decode frame <COI: 42, POC: 44

Attached patch fix this.
davs2.patch.gz

添加cmake的构建系统和脚本

请详细填写以下四项关键元素

功能描述

功能带来的效应

cmake是大势所趋,可以在所有平台一套脚本搞定

缺少此功能的影响

实现的思路与方式

Unable to rewind video

Describe the bug

I am unable to rewind any AVS2 video. I can play or pause, but I can't change the video position.

To Reproduce

  1. Build FFmpeg 4.2.1 with DAVS2 1.6 support
  2. Build FFMS2 2.23.1
  3. Use any video player/editor that is based on FFmpeg/FFMS2
  4. Open a sample video

To be more specific:

  1. Clone repo: https://github.com/scx/aegisub-flatpak.git
git clone --recurse-submodules https://github.com/scx/aegisub-flatpak.git
  1. Checkout v3.2.2+20190914:
git checkout v3.2.2+20190914
  1. Apply the patch: aegisub-flatpak-davs2.patch (mirrors: 1, 2)
  2. Build a flatpak package:
flatpak-builder "build" "org.aegisub.Aegisub.yaml" --force-clean --install-deps-from="flathub"
  1. Download a sample video
  2. Run flatpak-ed Aegisub:
flatpak-builder --run "build" "org.aegisub.Aegisub.yaml" "aegisub"
  1. Open the sample video file:
    VideoOpen Video...
  2. Play video to the end, then try to rewind

Expected behavior

Able to rewind or go forward (change video position).

Desktop

  • OS: Freedesktop 19.08/GNOME 3.34 (Flatpak)
  • Compiler: GCC 9.2.0

Output

[davs2 info]: davs2: 1.6.0 not-in-git-tree.8, 2019-09-14 19:10:55
[davs2 info]: CPU Capabilities:  MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[davs2 info]: Manager 55e4ba168640: using 1 thread(s): 1(frame/AEC)+0(pool/REC), 2 tasks
[davs2 info]: Manager 55e4ba168640: Sequence Resolution: 1920x1080.
[davs2 info]: davs2: 1.6.0 not-in-git-tree.8, 2019-09-14 19:10:55
[davs2 info]: CPU Capabilities:  MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[davs2 info]: Manager 7f0234003700: using 1 thread(s): 1(frame/AEC)+0(pool/REC), 2 tasks
[davs2 info]: davs2: 1.6.0 not-in-git-tree.8, 2019-09-14 19:10:55
[davs2 info]: CPU Capabilities:  MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[davs2 info]: Manager 55e4ba24d120: using 1 thread(s): 1(frame/AEC)+0(pool/REC), 2 tasks
[davs2 info]: Manager 55e4ba24d120: Sequence Resolution: 1920x1080.
[davs2 info]: davs2: 1.6.0 not-in-git-tree.8, 2019-09-14 19:10:55
[davs2 info]: CPU Capabilities:  MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[davs2 info]: Manager 55e4ba24d120: using 8 thread(s): 8(frame/AEC)+0(pool/REC), 9 tasks
[davs2 info]: Manager 55e4ba24d120: Sequence Resolution: 1920x1080.
[davs2 debug]: Dec[ 0] 55e4ba24dcc0: discontinuous COI (prev: 8 --> curr: 0).
[davs2 warn]: Dec[ 0] 55e4ba24dcc0: force to remove obsolete frame <poc: 0>.
[davs2 warn]: Dec[ 0] 55e4ba24dcc0: force to remove obsolete frame <poc: 8>.
[davs2 warn]: Dec[ 0] 55e4ba24dcc0: force to remove obsolete frame <poc: 4>.
[davs2 warn]: Dec[ 0] 55e4ba24dcc0: force to remove obsolete frame <poc: 6>.
[davs2 debug]: Dec[ 0] 55e4ba24dcc0: discontinuous COI (prev: 199 --> curr: 20).
[davs2 error]: Dec[ 0] 55e4ba24dcc0: reference frame of [coi: 532, poc: 529]: <COI: 531> not found.
[davs2 error]: Failed to decode frame <COI: 532, POC: 529>

Error

[davs2 error]: Dec[ 0] 55e4ba24dcc0: reference frame of [coi: 532, poc: 529]: <COI: 531> not found.
[davs2 error]: Failed to decode frame <COI: 532, POC: 529>

duplicate symbol _bs_init in libdavs2.a(bitstream.o)

Describe the bug

When trying to build ffmpeg with --enable-libdavs2 and --enable-libbluray, it fails with error of the following:

LD ffmpeg_g
duplicate symbol _bs_init in:
/Volumes/ffmpeg_compile/lib/libdavs2.a(bitstream.o)
/Volumes/ffmpeg_compile/lib/libbluray.a(libbluray_la-bits.o)
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ffmpeg_g] Error 1

To Reproduce

1.Build both libdavs2 and libbluray library as static
2.Try to build ffmpeg with --enable-libdavs2 and --enable-libbluray options.
3.ffmpeg make process fails with duplicate symbol error as above.

Expected behavior

Can build ffmpeg without error.

Desktop (please complete the following information):

  • OS: macOS 10.14.1 Mojave
  • Compiler: Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  • yasm: nasm 2.14

Additional context

I have similar experience while building ffmpeg. The cause is functions in one library is not defined as static. So this time might be same reason. Function bs_init in davs2/source/common/bitstream.cc is suspicious.

build ffmpeg

In ffmpegavs2 no issues, therefore I write here.
Different variables in davs and ffmpeg:

davs2_param_t -> "i_info_level" in ffmpeg, "info_level" in davs.
davs2_seq_info_t -> "horizontal_size" in ffmpeg, "width" in davs.
davs2_seq_info_t -> "vertical_size" in ffmpeg, "height" in davs.
davs2_seq_info_t -> "output_bitdepth" in ffmpeg, "output_bit_depth" in davs.

vs2015 win32 build failed

win32 abi 无法编译通过。
x64可以通过。

能介绍下三个工程的区别么?
libavs2_asm 开启汇编?
libavs2_intrin_avx 内建avx加速?
libavs2_intrin_sse 内建sse加速?

你的操作系统(包括版本)、编译器(GCC/G++, VS)、汇编器yasm(版本号)。

win10 x64
vs2015
nasm 2.14.02 x64
Additional context

Add any other context about the problem here, i.e. video sequences and bitstreams.

....\source\common\x86\blockcopy8.asm
3> intrinsic.cc
2> intrinsic_deblock_avx2.cc
3> intrinsic_alf.cc
2> intrinsic_idct_avx2.cc
3> intrinsic_deblock.cc
2> intrinsic_inter_pred_avx2.cc
3> intrinsic_idct.cc
2> intrinsic_intra-pred_avx2.cc
2> intrinsic_pixel_avx.cc
3> intrinsic_idct_avx2.cc
2> intrinsic_sao_avx2.cc
3> intrinsic_inter_pred.cc
3> intrinsic_intra-filledge.cc
3> intrinsic_intra-pred.cc
3> intrinsic_pixel.cc
3> intrinsic_sao.cc
2> libdavs2_intrin_avx.vcxproj -> F:\git\davs2\build\vs2013..\bin\Win32_Release\libdavs2_intrin_avx.lib
3> libdavs2_intrin_sse.vcxproj -> F:\git\davs2\build\vs2013..\bin\Win32_Release\libdavs2_intrin_sse.lib
1> ....\source\common\x86\const-a.asm
1> ....\source\common\x86\cpu-a.asm
1> ....\source\common\x86\dct8.asm
1> ....\source\common\x86\mc-a2.asm
1> ....\source\common\x86\pixeladd8.asm
1> ....\source\common\x86\quant8.asm
1>F:\git\davs2\source\common\x86\quant8.asm(48): error : mismatch in operand sizes
1>F:\git\davs2\source\common\x86\quant8.asm(49): error : invalid combination of opcode and operands
1>F:\git\davs2\source\common\x86\quant8.asm(54): error : invalid combination of opcode and operands
1>F:\git\davs2\build\vs2013\nasm.targets(50,5): error MSB3721: 命令“nasm.exe -Xvc -f win32 -o "F:\git\davs2\build\vs2013\Win32_Release\libdavs2_asm\quant8.obj" -I"....\source\common\x86/" -DSTACK_ALIGNMENT=32 -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8 -DARCH_X86_64=0 "F:\git\davs2\source\common\x86\quant8.asm"”已退出,返回代码为 1。
4>------ 已启动全部重新生成: 项目: libdavs2, 配置: Release Win32 ------
4> 'sh' 不是内部或外部命令,也不是可运行的程序
4> 或批处理文件。
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: 命令“cd /d "F:\git\davs2\build\vs2013...." && sh version.sh
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: :VCEnd”已退出,代码为 9009。
========== 全部重新生成: 成功 2 个,失败 2 个,跳过 0 个 ==========

Build failed on Ubuntu 22.04

Describe the bug

A clear and concise description of what the bug is.

请详细的描述这个bug的细节

Build failed

To Reproduce

Steps to reproduce the behavior (including the commond line parameters)

请详细描述重现这个bug的步骤(运行的命令行参数、输入的文件)

git clone https://github.com/pkuvcl/davs2.git
cd davs2/
cd build/linux/
./configure
make

Then we can see the error.

 [linking execution] davs2
g++ -o davs2  test/test.o libdavs2.a  -m64  -lm -lpthread
/usr/bin/ld: libdavs2.a(blockcopy8.o): relocation R_X86_64_32S against hidden symbol `davs2_pb_1' can not be used when making a PIE object
/usr/bin/ld: libdavs2.a(dct8.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: libdavs2.a(mc-a2.o): relocation R_X86_64_32S against hidden symbol `davs2_pw_00ff' can not be used when making a PIE object
collect2: error: ld returned 1 exit status
make: *** [Makefile:196: davs2] Error 1

Expected behavior

A clear and concise description of what you expected to happen.

你认为这个功能本应如何工作

Screenshots

If applicable, add screenshots to help explain your problem.

如果有可能,请提供截图

Desktop (please complete the following information):

  • OS: [e.g. Windows10, Ubuntu 18.04]
  • Compiler [e.g. Visual Studio 2013, GCC 5.6.0]
  • yasm [e.g. 1.2.0, 1.3.0-luofl]

你的操作系统(包括版本)、编译器(GCC/G++, VS)、汇编器yasm(版本号)。

OS: Ubuntu 22.04
Compiler: gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

Additional context

Add any other context about the problem here, i.e. video sequences and bitstreams.

额外的材料,例如输入的视频序列、码流文件等。

Is there an operation I'm missing?

Final linking failed (GNU ld)

Source files compile down to object files pretty well, but at the linking stage if fails to link which results in a incomplete build. The branch I chose for building is master.

Reproduction

the same instructions described in the README.md.

Expected behavior

In terminal when make is executed this should display:

make: Circular /home/tryamid/Projects/davs2/source/test/test.c <- /home/tryamid/Projects/davs2/source/test/test.c dependency dropped.
 [linking execution] davs2 
g++ -o davs2  test/test.o libdavs2.a  -m64  -lm -lpthread
/usr/bin/ld: libdavs2.a(blockcopy8.o): relocation R_X86_64_32S against hidden symbol `davs2_pb_1' can not be used when making a PIE object
/usr/bin/ld: libdavs2.a(dct8.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: libdavs2.a(mc-a2.o): relocation R_X86_64_32S against hidden symbol `davs2_pw_00ff' can not be used when making a PIE object
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:195: recipe for target 'davs2' failed
make: *** [davs2] Error 1

Pre-requisites

  • OS: Ubuntu 18.04.3 (Bionic Beaver)
  • Compiler: GCC 7.4.0
  • yasm version: 1.3.0

ffmpeg configure: ERROR: davs2 >= 1.5.115 not found using pkg-config

FFMPEG configure meet with ERROR: davs2 >= 1.5.115 not found using pkg-config.
(execute version.sh in tar file only get version 1.5.0).
root@ubuntu:/modules/davs2# ./version.sh
#define DAVS2_BUILD 15
#define DAVS2_POINTVER "1.5.0"
root@ubuntu:/modules/davs2#

how can I solve it? the code master (date: 2018.11.06)

configure fail with "endian test failed"

barry@barry-HP-ENVY-Notebook:~/Sources/xavs2/davs2/build/linux$ uname -a

Linux barry-HP-ENVY-Notebook 4.15.0-24-generic #26-Ubuntu SMP Wed Jun 13 08:44:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

barry@barry-HP-ENVY-Notebook:~/Sources/xavs2/davs2/build/linux$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic

barry@barry-HP-ENVY-Notebook:~/Sources/xavs2/davs2/build/linux$ ./configure
endian test failed

Build ffmpeg with avs2 for android

Hi,I want to build a shared library of ffmpeg with avs2 for android.
Before that,I have built libxavs2.so and libdavs2.so successfully by using android_build.sh in xavs2/build/linux.
But when I try to build FFmpegAVS2 with the following script,it cannot find davs2.

The script is :

#!/bin/zsh
ARCH=arm64
SDK_VERSION=21

TOOLCHAIN=/home/xu/my_toolchains_r17c/${ARCH}
NDKROOT=$TOOLCHAIN/sysroot
build_dir=`pwd`  # current dir

# ------------------------------------------------------
if [ "$ARCH" = "arm64" ]
then
    PLATFORM_PREFIX="aarch64-linux-android-"
    HOST="aarch64"
    PLATFORM_VERSION=4.9
    EXTRA_CFLAGS="-march=armv8-a -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie -D__ANDROID_API__=21"
else
    PLATFORM_PREFIX="arm-linux-androideabi-"
    HOST="arm"
    PLATFORM_VERSION=4.9
    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie"
fi

PREFIX=$(pwd)/android/${ARCH}
CROSS_PREFIX=$TOOLCHAIN/bin/${PLATFORM_PREFIX}
ADDI_LDFLAGS="-L$TOOLCHAIN/sysroot/usr/lib -fPIE -pie -shared"

#rm -f $(pwd)/compat/strtod.o
export PKG_CONFIG_PATH=$(pwd)/android/${ARCH}/lib/pkgconfig

function build_one
{
./configure \
--prefix=$PREFIX \
--enable-gpl \
--enable-libxavs2 \
--enable-libdavs2 \
--enable-shared \
--enable-static \
--disable-doc \
--enable-cross-compile \
--cross-prefix=$CROSS_PREFIX \
--target-os=android \
--arch=aarch64 \
--sysroot=$NDKROOT \
--extra-cflags="-Os -fpic $EXTRA_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
--enable-protocol=file \
--enable-pic \
--enable-small \
--disable-programs \
--disable-symver \
$ADDITIONAL_CONFIG_FLAG
}

ADDITIONAL_CONFIG_FLAG="--enable-yasm"

cd FFmpegAVS2
echo "Starting build_one"
build_one
echo "build_one done!"
#make clean
#make
#echo "make done!"
#make install
#echo "make install done!"

It report an error:

ERROR: davs2 >= 1.6.0 not found using pkg-config

But in PKG_CONFIG_PATH($(pwd)/android/${ARCH}/lib/pkgconfig),there exsits a davs2.pc:

prefix=/home/xu/test/ffmpeg-AVS2-Android/android/arm64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: davs2
Description: AVS2 (IEEE 1857.4) decoder library
Version: 1.6.181
Libs: -L${exec_prefix}/lib -ldavs2 
Libs.private: -lm
Cflags: -I${prefix}/include

and the version >= 1.6.0.

The ffbuild/config.log is :

check_complexfunc cexp 1
test_ld cc
test_cc
BEGIN /tmp/ffconf.xk5VqWQQ/test.c
    1	#include <complex.h>
    2	#include <math.h>
    3	float foo(complex float f, complex float g) { return cexp(f * I); }
    4	int main(void){ return (int) foo; }
END /tmp/ffconf.xk5VqWQQ/test.c
/home/xu/my_toolchains/arm64/bin/aarch64-linux-android-gcc --sysroot=/home/xu/my_toolchains/arm64/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -march=armv8-a -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie -D__ANDROID_API__=21 -std=c11 -fomit-frame-pointer -fPIC -pthread -c -o /tmp/ffconf.xk5VqWQQ/test.o /tmp/ffconf.xk5VqWQQ/test.c
/tmp/ffconf.xk5VqWQQ/test.c: In function 'foo':
/tmp/ffconf.xk5VqWQQ/test.c:3:1: warning: implicit declaration of function 'cexp' [-Wimplicit-function-declaration]
 float foo(complex float f, complex float g) { return cexp(f * I); }
 ^
/tmp/ffconf.xk5VqWQQ/test.c:3:54: warning: incompatible implicit declaration of built-in function 'cexp'
 float foo(complex float f, complex float g) { return cexp(f * I); }
                                                      ^
/tmp/ffconf.xk5VqWQQ/test.c: In function 'main':
/tmp/ffconf.xk5VqWQQ/test.c:4:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 int main(void){ return (int) foo; }
                        ^
/home/xu/my_toolchains/arm64/bin/aarch64-linux-android-gcc -L/home/xu/my_toolchains/arm64/sysroot/usr/lib -fPIE -pie -shared --sysroot=/home/xu/my_toolchains/arm64/sysroot -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.xk5VqWQQ/test /tmp/ffconf.xk5VqWQQ/test.o
require_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
check_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
test_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
false --exists --print-errors davs2 >= 1.6.0
ERROR: davs2 >= 1.6.0 not found using pkg-config

Build fails with gcc8

Describe the bug

I'm getting the following error when trying to build davs2 git master with gcc8:

To Reproduce

The steps to reproduce are already described on the above link.

Expected behavior

A successful build with gcc8.

Screenshots

Not applicable.

Desktop (please complete the following information):

  • OS: Arch Linux x86_64
  • Compiler: gcc 8.2.1
  • yasm: 1.3.0
  • glibc: 2.28

Additional context

It builds fine when using gcc 7.3.1.

Build fails when using 10-bit depth

I'm getting the following compile error when trying to build in 10-bit mode:

/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc: In function ‘void davs2_write_a_frame(davs2_picture_t*, davs2_frame_t*)’:
/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc:959:42: error: cannot convert ‘pel_t* {aka short unsigned int*}’ to ‘uint8_t* {aka unsigned char*}’ in assignment
         pic->planes[0]  = frame->planes[0];
                                          ^
/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc:960:42: error: cannot convert ‘pel_t* {aka short unsigned int*}’ to ‘uint8_t* {aka unsigned char*}’ in assignment
         pic->planes[1]  = frame->planes[1];
                                          ^
/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc:961:42: error: cannot convert ‘pel_t* {aka short unsigned int*}’ to ‘uint8_t* {aka unsigned char*}’ in assignment
         pic->planes[2]  = frame->planes[2];
                                          ^
/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc: In function ‘davs2_t* decoder_open(davs2_mgr_t*, davs2_t*, int)’:
/storage/linux/abs/davs2-git/src/davs2-git/source/common/decoder.cc:1071:73: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘davs2_t*’ [-Wformat=]
     sprintf(h->module_log.module_name, "Dec[%2d] %06llx", idx_decoder, h);
                                                                         ^
make: *** [Makefile:228: common/decoder.o] Error 1

Commands used:

$ ./configure 
        --prefix='/usr' \
        --enable-shared \
        --bit-depth='10' \
        --chroma-format='all' \
        --enable-lto \
        --enable-pic \
        --disable-swscale \
        --disable-lavf \
        --disable-ffms \
        --disable-gpac
$ make -j1

It builds fine with 8-bit depth by using --bit-depth='8'.

System Information:
OS: Arch Linux x86_64
Compiler: using gcc 7.3.1 to compile this (gcc 8.1.1 gives error)
yasm: 1.3.0
l-smash: 2.14.5
davs2: git master

Global-buffer-overflow in cu_get_quant_params() --> davs2/source/common/quant.h:115

Describe the bug

=============================================================================================

static ALWAYS_INLINE
void cu_get_quant_params(davs2_t * h, int qp, int bit_size,
int *shift, int *scale)
{
*shift = IQ_SHIFT[qp] + (h->sample_bit_depth + 1) + bit_size - LIMIT_BIT; <------ out of bounds here
*scale = IQ_TAB[qp];
}

=============================================================================================

To Reproduce

cd /path/to/davs2/build/linux/
./configure --enable-pic
vim config.mak (add -fsanitize=address to CFLAGS, and -fsanitize=address -lasan to LDFLAGS)
make
./davs2 -i /path/to/poc4 -o test.yuv

ASAN Crash log

=================================================================
==107413==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55ec49b52e7c at pc 0x55ec49a5bb2d bp 0x7fabbb269cb0 sp 0x7fabbb269ca0
READ of size 2 at 0x55ec49b52e7c thread T1
#0 0x55ec49a5bb2c in cu_get_quant_params /home/arayz/arayz/work/davs2/source/common/quant.h:115
#1 0x55ec49a5bb2c in cu_read_all_coeffs /home/arayz/arayz/work/davs2/source/common/cu.cc:662
#2 0x55ec49a5bb2c in cu_read_info /home/arayz/arayz/work/davs2/source/common/cu.cc:872
#3 0x55ec49a5bb2c in davs2_decode_lcu_parse /home/arayz/arayz/work/davs2/source/common/cu.cc:1327
#4 0x55ec49a55deb in davs2_decode_lcu_parse /home/arayz/arayz/work/davs2/source/common/cu.cc:1316
#5 0x55ec49a55deb in davs2_decode_lcu_parse /home/arayz/arayz/work/davs2/source/common/cu.cc:1316
#6 0x55ec49a55deb in davs2_decode_lcu_parse /home/arayz/arayz/work/davs2/source/common/cu.cc:1316
#7 0x55ec499abb6b in decode_one_lcu_row /home/arayz/arayz/work/davs2/source/common/decoder.cc:438
#8 0x55ec499b12ee in davs2_decoder_decode_picture_data /home/arayz/arayz/work/davs2/source/common/decoder.cc:1168
#9 0x55ec499d8b6a in davs2_threadpool_thread /home/arayz/arayz/work/davs2/source/common/threadpool.cc:216
#10 0x7fabce4aa608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477
#11 0x7fabce083132 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f132)

0x55ec49b52e7c is located 4 bytes to the left of global variable 'dmh_pos' defined in '/home/arayz/arayz/work/davs2/source/common/cu.cc:77:21' (0x55ec49b52e80) of size 36
0x55ec49b52e7c is located 28 bytes to the right of global variable 'davs2_IQ_SHIFT' defined in '/home/arayz/arayz/work/davs2/source/common/cu.cc:91:15' (0x55ec49b52dc0) of size 160
SUMMARY: AddressSanitizer: global-buffer-overflow /home/arayz/arayz/work/davs2/source/common/quant.h:115 in cu_get_quant_params
Shadow bytes around the buggy address:
0x0abe09362570: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
0x0abe09362580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9
0x0abe09362590: f9 f9 f9 f9 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
0x0abe093625a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abe093625b0: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x0abe093625c0: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9[f9]
0x0abe093625d0: 00 00 00 00 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x0abe093625e0: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
0x0abe093625f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0abe09362600: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
0x0abe09362610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
Thread T1 created by T0 here:
#0 0x7fabce4ff815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
#1 0x55ec499d8f36 in davs2_threadpool_init /home/arayz/arayz/work/davs2/source/common/threadpool.cc:271

==107413==ABORTING

Additional context

  • OS: Ubuntu 20.04 (Desktop)
  • Compiler: gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

PoC:
poc4.zip

FFmpegAVS2 configure failed

when I use ./configure in folder FFmpegAVS2 on linux platform,davs2_decoder_decode check failed;but if i modify this function to davs2_decoder_open,./configure success;later when I use make -j2 in FFmpegAVS2,i meet some compile errors,such as:
libavcodec/libdavs2.c: In function ‘DumpFrames’:
libavcodec/libdavs2.c:80:27: error: ‘davs2_picture_t’ has no member named ‘ret_type’
if (pic == NULL || pic->ret_type == DAVS2_GOT_HEADER) {
^
libavcodec/libdavs2.c:92:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
const int bytes_per_sample = pic->bytes_per_sample;
^
▽ibavcodec/libdavs2.c:96:29: error: ‘davs2_picture_t’ has no member named ‘width’
int size_plane = pic->width[i] * pic->lines[i] * bytes_per_sample;
^
libavcodec/libdavs2.c:99:31: error: ‘davs2_picture_t’ has no member named ‘width’
frm->linesize[i] = pic->width[i] * bytes_per_sample;
^
libavcodec/libdavs2.c: In function ‘ff_davs2_end’:
libavcodec/libdavs2.c:123:9: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘void *’ [-Wformat=]
av_log(avctx, AV_LOG_WARNING, "[davs2] decoder destroyed. 0x%llx; frames %d\n", cad->decoder, cad->decoded_frames);
^
libavcodec/libdavs2.c: In function ‘davs2_decode_frame’:
libavcodec/libdavs2.c:143:26: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
cad->packet.data = buf_ptr;
^
libavcodec/libdavs2.c:155:31: error: ‘davs2_picture_t’ has no member named ‘ret_type’
if (cad->out_frame.ret_type != DAVS2_DEFAULT) {
^
libavcodec/libdavs2.c:168:24: error: ‘davs2_packet_t’ has no member named ‘marker’
cad->packet.marker = 0;
^
libavcodec/libdavs2.c:169:30: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
cad->packet.data = buf_ptr;
^
libavcodec/libdavs2.c:175:13: error: implicit declaration of function ‘davs2_decoder_decode’ [-Werror=implicit-function-declaration]
len = davs2_decoder_decode(cad->decoder, &cad->packet, &cad->headerset, &cad->out_frame);
^
libavcodec/libdavs2.c:177:31: error: ‘davs2_picture_t’ has no member named ‘ret_type’
+++++++++++++++I think davs2's verion is not right,but I alreadly use the most new version of davs2;
can someone help me? thanks very much;

Free an invalid address could lead to SEGV in davs2_free davs2/source/common/common.h:1269

Describe the bug

This bug allows to free an invalid address which is dangerous, the pointer to be free seems corrupted.

=============================================================================================

$ gdb ./davs2
(gdb) b davs2_free
Breakpoint 1 at 0x555555565b23: davs2_free. (9 locations)
(gdb) r -o ./test.yuv -i poc2
Thread 1 "davs2" hit Breakpoint 1, davs2_free (ptr=0x627000000120) at /home/arayz/arayz/work/davs2/source/common/common.h:1269
1269 free(*(((void **)ptr) - 1));
(gdb) x/20xb *(((void **)ptr) - 1)
0x627000000100: 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe
0x627000000108: 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe 0xbe
0x627000000110: 0xbe 0xbe 0xbe 0xbe
(gdb) c
Continuing.

Thread 1 "davs2" hit Breakpoint 1, davs2_free (ptr=0x7fffcde91e60) at /home/arayz/arayz/work/davs2/source/common/common.h:1269
1269 free(*(((void **)ptr) - 1));
(gdb) x/20xb *(((void **)ptr) - 1)
0xfffffff100000000: Cannot access memory at address 0xfffffff100000000

=============================================================================================

To Reproduce

cd /path/to/davs2/build/linux/
./configure --enable-pic
vim config.mak (add -fsanitize=address to CFLAGS, and -fsanitize=address -lasan to LDFLAGS)
make
./davs2 -i /path/to/poc2.avs -o test.yuv

ASAN Crash log

=================================================================
==105979==ERROR: AddressSanitizer: SEGV on unknown address 0xfffffff0fffffff0 (pc 0x7f652159ba16 bp 0xfffffff0fffffff0 sp 0x7ffdae8c08e0 T0)
==105979==The signal is caused by a WRITE memory access.
#0 0x7f652159ba15 in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sanitizer::atomic_uint8_t::Type, __sanitizer::memory_order) ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:79
#1 0x7f652159ba15 in __asan::Allocator::AtomicallySetQuarantineFlagIfAllocated(__asan::AsanChunk*, void*, __sanitizer::BufferedStackTrace*) ../../../../src/libsanitizer/asan/asan_allocator.cc:552
#2 0x7f652159ba15 in __asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) ../../../../src/libsanitizer/asan/asan_allocator.cc:629
#3 0x7f652159ba15 in __asan::asan_free(void*, __sanitizer::BufferedStackTrace*, __asan::AllocType) ../../../../src/libsanitizer/asan/asan_allocator.cc:865
#4 0x7f65216803d8 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:127
#5 0x5587417e73ff in davs2_free /home/arayz/arayz/work/davs2/source/common/common.h:1269
#6 0x5587417e73ff in davs2_frame_destroy /home/arayz/arayz/work/davs2/source/common/frame.cc:371
#7 0x5587417e2f69 in davs2_decoder_free_extra_buffer /home/arayz/arayz/work/davs2/source/common/decoder.cc:777
#8 0x5587417e6431 in davs2_decoder_decoder_close /home/arayz/arayz/work/davs2/source/common/decoder.cc:1205
#9 0x5587417dd34a in davs2_decoder_close /home/arayz/arayz/work/davs2/source/common/davs2.cc:797
#10 0x5587417da81f in test_decoder /home/arayz/arayz/work/davs2/source/test/test.c:275
#11 0x5587417db7bc in main /home/arayz/arayz/work/davs2/source/test/test.c:329
#12 0x7f6521036082 in __libc_start_main ../csu/libc-start.c:308
#13 0x5587417d652d in _start (/home/arayz/arayz/work/davs2/build/linux/davs2+0xc52d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:79 in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sanitizer::atomic_uint8_t::Type, __sanitizer::memory_order)
==105979==ABORTING

This is a security issue.

Additional context

  • OS: Ubuntu 20.04 (Desktop)
  • Compiler gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

PoC:
poc2.zip

添加cmake的构建系统和脚本

请详细填写以下四项关键元素

功能描述

功能带来的效应

cmake是大势所趋,可以在所有平台一套脚本搞定

缺少此功能的影响

实现的思路与方式

关于随机解码opengop会某些gop的帧解不出来

对于avs2的ES流,已经解析出来所有的gop信息以及位置偏移。现在进行seek操作时直接定位到一个完整的gop信息,对数据流用davs2进行解码,对于closegop的情况都可以解出来每一帧,但是对于opengop有一些gop的最后几帧解不出来。
对于opengop的随机解码现在支持吗?
谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.