Update upstream source from tag 'upstream/0.164.3095+gitbaee400'
Update to upstream version '0.164.3095+gitbaee400'
with Debian dir c750cd97c0d82f4c7a854439c9f1280440dd297d
Rico Tzschichholz
1 year, 11 months ago
80 | 80 | |
81 | 81 | build-debian-amd64: |
82 | 82 | extends: .build |
83 | image: registry.videolan.org/x264-debian-unstable:20190404162201 | |
83 | image: registry.videolan.org/x264-debian-unstable:20211206140856 | |
84 | 84 | tags: |
85 | 85 | - docker |
86 | 86 | - amd64 |
88 | 88 | |
89 | 89 | build-debian-aarch64: |
90 | 90 | extends: .build |
91 | image: registry.videolan.org/x264-debian-unstable-aarch64:20190716192245 | |
91 | image: registry.videolan.org/x264-debian-unstable-aarch64:20211206141032 | |
92 | 92 | tags: |
93 | 93 | - docker |
94 | 94 | - aarch64 |
105 | 105 | curl -f -o vlc-contrib-${_TRIPLET}-latest.tar.bz2 ${_CONTRIB_URL}${CONTRIB_NAME} |
106 | 106 | bunzip2 vlc-contrib-${_TRIPLET}-latest.tar.bz2 |
107 | 107 | tar xvf vlc-contrib-${_TRIPLET}-latest.tar |
108 | sed -i.bak -e "s#@@CONTRIB_PREFIX@@#${LOCAL_INSTALL_DIR}#g" ${PKG_CONFIG_LIBDIR}/*.pc | |
108 | perl -pi -e "s'@@CONTRIB_PREFIX@@'$(sed -e "s/'/\\\\'/g" <<< "${LOCAL_INSTALL_DIR}")'g" ${PKG_CONFIG_LIBDIR}/*.pc | |
109 | 109 | git clone --depth 1 --branch master https://github.com/l-smash/l-smash.git lsmash |
110 | 110 | cd lsmash |
111 | 111 | ./configure --prefix="${LOCAL_INSTALL_DIR}" --target-os="${_TRIPLET}" --cross-prefix="${_TRIPLET}-" |
125 | 125 | |
126 | 126 | .build-llvm-mingw: |
127 | 127 | extends: .build |
128 | image: registry.videolan.org/vlc-debian-llvm-mingw:20200703084018 | |
128 | image: registry.videolan.org/vlc-debian-llvm-mingw:20211020094514 | |
129 | 129 | tags: |
130 | 130 | - docker |
131 | 131 | - amd64 |
153 | 153 | curl -f -o vlc-contrib-${_TRIPLET}-latest.tar.bz2 ${_CONTRIB_URL}${CONTRIB_NAME} |
154 | 154 | bunzip2 vlc-contrib-${_TRIPLET}-latest.tar.bz2 |
155 | 155 | tar xvf vlc-contrib-${_TRIPLET}-latest.tar |
156 | sed -i.bak -e "s#@@CONTRIB_PREFIX@@#${LOCAL_INSTALL_DIR}#g" ${PKG_CONFIG_LIBDIR}/*.pc | |
156 | perl -pi -e "s'@@CONTRIB_PREFIX@@'$(sed -e "s/'/\\\\'/g" <<< "${LOCAL_INSTALL_DIR}")'g" ${PKG_CONFIG_LIBDIR}/*.pc | |
157 | 157 | git clone --depth 1 --branch master https://github.com/l-smash/l-smash.git lsmash |
158 | 158 | cd lsmash |
159 | 159 | ./configure --prefix="${LOCAL_INSTALL_DIR}" --target-os="${_TRIPLET}" --extra-cflags="${_XCFLAGS}" --extra-ldflags="${_XLDFLAGS}" |
57 | 57 | N: Laurent Aimar |
58 | 58 | E: fenrir AT videolan DOT org |
59 | 59 | C: fenrir |
60 | D: Intial import, former maintainer | |
60 | D: Initial import, former maintainer | |
61 | 61 | D: x86 asm (mmx/mmx2) |
62 | 62 | S: France |
63 | 63 |
390 | 390 | $(INSTALL) x264$(EXE) $(DESTDIR)$(bindir) |
391 | 391 | |
392 | 392 | install-lib-dev: |
393 | $(INSTALL) -d $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig | |
393 | $(INSTALL) -d $(DESTDIR)$(includedir) | |
394 | $(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig | |
394 | 395 | $(INSTALL) -m 644 $(SRCPATH)/x264.h x264_config.h $(DESTDIR)$(includedir) |
395 | 396 | $(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig |
396 | 397 |
0 | 0 | /***************************************************************************** |
1 | 1 | * autocomplete: x264cli shell autocomplete |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2018-2021 x264 project | |
3 | * Copyright (C) 2018-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Henrik Gramner <henrik@gramner.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * asm-offsets.c: check asm offsets for aarch64 |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * asm-offsets.h: asm offsets for aarch64 |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * asm.S: AArch64 utility macros |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2008-2021 x264 project | |
3 | * Copyright (C) 2008-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mans Rullgard <mans@mansr.com> |
6 | 6 | * David Conrad <lessen42@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream-a.S: aarch64 bitstream functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream.h: aarch64 bitstream functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * cabac-a.S: aarch64 cabac |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /**************************************************************************** |
1 | 1 | * dct-a.S: aarch64 transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: aarch64 transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.S: aarch64 deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mans Rullgard <mans@mansr.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.h: aarch64 deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.S: aarch64 motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc-c.c: aarch64 motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
209 | 209 | int qpel_idx = ((mvy&3)<<2) + (mvx&3); |
210 | 210 | intptr_t offset = (mvy>>2)*i_src_stride + (mvx>>2); |
211 | 211 | uint8_t *src1 = src[x264_hpel_ref0[qpel_idx]] + offset; |
212 | if( (mvy&3) == 3 ) // explict if() to force conditional add | |
212 | if( (mvy&3) == 3 ) // explicit if() to force conditional add | |
213 | 213 | src1 += i_src_stride; |
214 | 214 | |
215 | 215 | if( qpel_idx & 5 ) /* qpel interpolation needed */ |
235 | 235 | int qpel_idx = ((mvy&3)<<2) + (mvx&3); |
236 | 236 | intptr_t offset = (mvy>>2)*i_src_stride + (mvx>>2); |
237 | 237 | uint8_t *src1 = src[x264_hpel_ref0[qpel_idx]] + offset; |
238 | if( (mvy&3) == 3 ) // explict if() to force conditional add | |
238 | if( (mvy&3) == 3 ) // explicit if() to force conditional add | |
239 | 239 | src1 += i_src_stride; |
240 | 240 | |
241 | 241 | if( qpel_idx & 5 ) /* qpel interpolation needed */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: aarch64 motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.S: aarch64 pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.h: aarch64 pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.S: aarch64 intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Mans Rullgard <mans@mansr.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.c: aarch64 intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: aarch64 intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /**************************************************************************** |
1 | 1 | * quant.S: arm quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: arm quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * asm.S: arm utility macros |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2008-2021 x264 project | |
3 | * Copyright (C) 2008-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mans Rullgard <mans@mansr.com> |
6 | 6 | * David Conrad <lessen42@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream-a.S: arm bitstream functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Janne Grunau <janne-x264@jannau.net> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream.h: arm bitstream functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * cpu-a.S: arm cpu detection |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /**************************************************************************** |
1 | 1 | * dct-a.S: arm transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Martin Storsjo <martin@martin.st> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: arm transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.S: arm deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mans Rullgard <mans@mansr.com> |
6 | 6 | * Martin Storsjo <martin@martin.st> |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.h: arm deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.S: arm motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Mans Rullgard <mans@mansr.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc-c.c: arm motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
217 | 217 | int qpel_idx = ((mvy&3)<<2) + (mvx&3); |
218 | 218 | intptr_t offset = (mvy>>2)*i_src_stride + (mvx>>2); |
219 | 219 | uint8_t *src1 = src[x264_hpel_ref0[qpel_idx]] + offset; |
220 | if( (mvy&3) == 3 ) // explict if() to force conditional add | |
220 | if( (mvy&3) == 3 ) // explicit if() to force conditional add | |
221 | 221 | src1 += i_src_stride; |
222 | 222 | |
223 | 223 | if( qpel_idx & 5 ) /* qpel interpolation needed */ |
243 | 243 | int qpel_idx = ((mvy&3)<<2) + (mvx&3); |
244 | 244 | intptr_t offset = (mvy>>2)*i_src_stride + (mvx>>2); |
245 | 245 | uint8_t *src1 = src[x264_hpel_ref0[qpel_idx]] + offset; |
246 | if( (mvy&3) == 3 ) // explict if() to force conditional add | |
246 | if( (mvy&3) == 3 ) // explicit if() to force conditional add | |
247 | 247 | src1 += i_src_stride; |
248 | 248 | |
249 | 249 | if( qpel_idx & 5 ) /* qpel interpolation needed */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: arm motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.S: arm pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.h: arm pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.S: arm intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Mans Rullgard <mans@mansr.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.c: arm intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: arm intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /**************************************************************************** |
1 | 1 | * quant.S: arm quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * Janne Grunau <janne-x264@jannau.net> |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: arm quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: David Conrad <lessen42@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * base.c: misc common functions (bit depth independent) |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
34 | 34 | #include <sys/mman.h> |
35 | 35 | #endif |
36 | 36 | |
37 | #define X264_ISDIGIT(x) isdigit((unsigned char)(x)) | |
38 | ||
37 | 39 | /**************************************************************************** |
38 | 40 | * x264_reduce_fraction: |
39 | 41 | ****************************************************************************/ |
206 | 208 | void *ptr[]; |
207 | 209 | } strdup_buffer; |
208 | 210 | |
209 | #define BUFFER_OFFSET offsetof(strdup_buffer, ptr) | |
211 | #define BUFFER_OFFSET (int)offsetof(strdup_buffer, ptr) | |
210 | 212 | #define BUFFER_DEFAULT_SIZE 16 |
211 | 213 | |
212 | 214 | char *x264_param_strdup( x264_param_t *param, const char *src ) |
921 | 923 | if( 0 ); |
922 | 924 | OPT("asm") |
923 | 925 | { |
924 | p->cpu = isdigit(value[0]) ? atoi(value) : | |
926 | p->cpu = X264_ISDIGIT(value[0]) ? (uint32_t)atoi(value) : | |
925 | 927 | !strcasecmp(value, "auto") || atobool(value) ? x264_cpu_detect() : 0; |
926 | 928 | if( b_error ) |
927 | 929 | { |
992 | 994 | b_error |= parse_enum( value, x264_avcintra_flavor_names, &p->i_avcintra_flavor ); |
993 | 995 | OPT("sar") |
994 | 996 | { |
995 | b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) && | |
996 | 2 != sscanf( value, "%d/%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) ); | |
997 | b_error |= ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) && | |
998 | 2 != sscanf( value, "%d/%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) ); | |
997 | 999 | } |
998 | 1000 | OPT("overscan") |
999 | 1001 | b_error |= parse_enum( value, x264_overscan_names, &p->vui.i_overscan ); |
1010 | 1012 | OPT("chromaloc") |
1011 | 1013 | { |
1012 | 1014 | p->vui.i_chroma_loc = atoi(value); |
1013 | b_error = ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 ); | |
1015 | b_error |= ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 ); | |
1014 | 1016 | } |
1015 | 1017 | OPT("mastering-display") |
1016 | 1018 | { |
1042 | 1044 | b_error |= parse_enum( value, x264_transfer_names, &p->i_alternative_transfer ); |
1043 | 1045 | OPT("fps") |
1044 | 1046 | { |
1045 | if( sscanf( value, "%u/%u", &p->i_fps_num, &p->i_fps_den ) != 2 ) | |
1047 | int64_t i_fps_num; | |
1048 | int64_t i_fps_den; | |
1049 | if( sscanf( value, "%"SCNd64"/%"SCNd64, &i_fps_num, &i_fps_den ) == 2 ) | |
1050 | { | |
1051 | p->i_fps_num = i_fps_num; | |
1052 | p->i_fps_den = i_fps_den; | |
1053 | b_error |= i_fps_num < 1 || i_fps_num > UINT32_MAX || i_fps_den < 1 || i_fps_den > UINT32_MAX; | |
1054 | } | |
1055 | else | |
1046 | 1056 | { |
1047 | 1057 | double fps = atof(value); |
1048 | if( fps > 0.0 && fps <= INT_MAX/1000.0 ) | |
1058 | if( fps < 0.0005 || fps > INT_MAX ) | |
1059 | b_error = 1; | |
1060 | else if( fps <= INT_MAX/1000.0 ) | |
1049 | 1061 | { |
1050 | 1062 | p->i_fps_num = (int)(fps * 1000.0 + .5); |
1051 | 1063 | p->i_fps_den = 1000; |
0 | 0 | /***************************************************************************** |
1 | 1 | * base.h: misc common functions (bit depth independent) |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
81 | 81 | #define MEM_DYN(x, t) (*(t (*)[])(x)) |
82 | 82 | #else |
83 | 83 | //older versions of gcc prefer casting to structure instead of array |
84 | #define MEM_FIX(x, t, s) (*(struct { t a[s]; } (*))(x)) | |
84 | #define MEM_FIX(x, t, s) (*(struct { t a[s]; } MAY_ALIAS (*))(x)) | |
85 | 85 | //let's set an arbitrary large constant size |
86 | 86 | #define MEM_DYN(x, t) MEM_FIX(x, t, 4096) |
87 | 87 | #endif |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream.c: bitstream writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
91 | 91 | { |
92 | 92 | /* Size doesn't include the size of the header we're writing now. */ |
93 | 93 | int chunk_size = size - 4; |
94 | orig_dst[0] = chunk_size >> 24; | |
95 | orig_dst[1] = chunk_size >> 16; | |
96 | orig_dst[2] = chunk_size >> 8; | |
97 | orig_dst[3] = chunk_size >> 0; | |
94 | orig_dst[0] = (uint8_t)(chunk_size >> 24); | |
95 | orig_dst[1] = (uint8_t)(chunk_size >> 16); | |
96 | orig_dst[2] = (uint8_t)(chunk_size >> 8); | |
97 | orig_dst[3] = (uint8_t)(chunk_size >> 0); | |
98 | 98 | } |
99 | 99 | |
100 | 100 | nal->i_payload = size; |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream.h: bitstream writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * cabac.c: arithmetic coder |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
88 | 88 | cb->p[-1] += carry; |
89 | 89 | while( bytes_outstanding > 0 ) |
90 | 90 | { |
91 | *(cb->p++) = carry-1; | |
91 | *(cb->p++) = (uint8_t)(carry-1); | |
92 | 92 | bytes_outstanding--; |
93 | 93 | } |
94 | *(cb->p++) = out; | |
94 | *(cb->p++) = (uint8_t)out; | |
95 | 95 | cb->i_bytes_outstanding = 0; |
96 | 96 | } |
97 | 97 | } |
142 | 142 | { |
143 | 143 | uint32_t v = val + (1<<exp_bits); |
144 | 144 | int k = 31 - x264_clz( v ); |
145 | uint32_t x = (bypass_lut[k-exp_bits]<<exp_bits) + v; | |
145 | uint32_t x = ((uint32_t)bypass_lut[k-exp_bits]<<exp_bits) + v; | |
146 | 146 | k = 2*k+1-exp_bits; |
147 | 147 | int i = ((k-1)&7)+1; |
148 | 148 | do { |
0 | 0 | /***************************************************************************** |
1 | 1 | * cabac.h: arithmetic coder |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * common.c: misc common functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * common.h: misc common functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * cpu.c: cpu detection |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
26 | 26 | |
27 | 27 | #include "base.h" |
28 | 28 | |
29 | #if HAVE_POSIXTHREAD && SYS_LINUX | |
29 | #if SYS_CYGWIN || SYS_SunOS || SYS_OPENBSD | |
30 | #include <unistd.h> | |
31 | #endif | |
32 | #if SYS_LINUX | |
33 | #ifdef __ANDROID__ | |
34 | #include <unistd.h> | |
35 | #else | |
30 | 36 | #include <sched.h> |
37 | #endif | |
31 | 38 | #endif |
32 | 39 | #if SYS_BEOS |
33 | 40 | #include <kernel/OS.h> |
34 | 41 | #endif |
35 | #if SYS_MACOSX || SYS_FREEBSD | |
42 | #if SYS_MACOSX || SYS_OPENBSD || SYS_FREEBSD | |
36 | 43 | #include <sys/types.h> |
37 | 44 | #include <sys/sysctl.h> |
38 | 45 | #endif |
39 | 46 | #if SYS_OPENBSD |
40 | #include <sys/param.h> | |
41 | #include <sys/sysctl.h> | |
42 | 47 | #include <machine/cpu.h> |
43 | 48 | #endif |
44 | 49 | |
300 | 305 | #elif HAVE_ALTIVEC |
301 | 306 | |
302 | 307 | #if SYS_MACOSX || SYS_OPENBSD || SYS_FREEBSD |
303 | #include <sys/sysctl.h> | |
308 | ||
304 | 309 | uint32_t x264_cpu_detect( void ) |
305 | 310 | { |
306 | 311 | /* Thank you VLC */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * cpu.h: cpu detection |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2004-2021 x264 project | |
3 | * Copyright (C) 2004-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.c: transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2004-2021 x264 project | |
3 | * Copyright (C) 2004-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.c: deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
101 | 101 | tc++; |
102 | 102 | } |
103 | 103 | |
104 | delta = x264_clip3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); | |
104 | delta = x264_clip3( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc ); | |
105 | 105 | pix[-1*xstride] = x264_clip_pixel( p0 + delta ); /* p0' */ |
106 | 106 | pix[ 0*xstride] = x264_clip_pixel( q0 - delta ); /* q0' */ |
107 | 107 | } |
142 | 142 | |
143 | 143 | if( abs( p0 - q0 ) < alpha && abs( p1 - p0 ) < beta && abs( q1 - q0 ) < beta ) |
144 | 144 | { |
145 | int delta = x264_clip3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); | |
145 | int delta = x264_clip3( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc ); | |
146 | 146 | pix[-1*xstride] = x264_clip_pixel( p0 + delta ); /* p0' */ |
147 | 147 | pix[ 0*xstride] = x264_clip_pixel( q0 - delta ); /* q0' */ |
148 | 148 | } |
314 | 314 | if( !M32(bS) || !alpha || !beta ) |
315 | 315 | return; |
316 | 316 | |
317 | tc[0] = (tc0_table(index_a)[bS[0]] << (BIT_DEPTH-8)) + b_chroma; | |
318 | tc[1] = (tc0_table(index_a)[bS[1]] << (BIT_DEPTH-8)) + b_chroma; | |
319 | tc[2] = (tc0_table(index_a)[bS[2]] << (BIT_DEPTH-8)) + b_chroma; | |
320 | tc[3] = (tc0_table(index_a)[bS[3]] << (BIT_DEPTH-8)) + b_chroma; | |
317 | tc[0] = (tc0_table(index_a)[bS[0]] * (1 << (BIT_DEPTH-8))) + b_chroma; | |
318 | tc[1] = (tc0_table(index_a)[bS[1]] * (1 << (BIT_DEPTH-8))) + b_chroma; | |
319 | tc[2] = (tc0_table(index_a)[bS[2]] * (1 << (BIT_DEPTH-8))) + b_chroma; | |
320 | tc[3] = (tc0_table(index_a)[bS[3]] * (1 << (BIT_DEPTH-8))) + b_chroma; | |
321 | 321 | |
322 | 322 | pf_inter( pix, i_stride, alpha, beta, tc ); |
323 | 323 | } |
654 | 654 | } while( 0 ) |
655 | 655 | |
656 | 656 | if( !transform_8x8 ) FILTER( 0, 1 ); |
657 | FILTER( 0, 2 ); | |
657 | FILTER( 0, 2 ); | |
658 | 658 | if( !transform_8x8 ) FILTER( 0, 3 ); |
659 | 659 | |
660 | 660 | if( !transform_8x8 ) FILTER( 1, 1 ); |
661 | FILTER( 1, 2 ); | |
661 | FILTER( 1, 2 ); | |
662 | 662 | if( !transform_8x8 ) FILTER( 1, 3 ); |
663 | 663 | |
664 | 664 | #undef FILTER |
0 | 0 | /***************************************************************************** |
1 | 1 | * frame.c: frame handling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * frame.h: frame handling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * macroblock.c: macroblock common functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
1248 | 1248 | if( h->mb.cache.varref[l][index] >= 0 )\ |
1249 | 1249 | {\ |
1250 | 1250 | h->mb.cache.varref[l][index] >>= 1;\ |
1251 | h->mb.cache.varmv[l][index][1] <<= 1;\ | |
1251 | h->mb.cache.varmv[l][index][1] *= 2;\ | |
1252 | 1252 | h->mb.cache.mvd[l][index][1] <<= 1;\ |
1253 | 1253 | } |
1254 | 1254 | MAP_MVS |
0 | 0 | /***************************************************************************** |
1 | 1 | * macroblock.h: macroblock common functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
360 | 360 | * uses all neighbors, even those that didn't end up using this ref. |
361 | 361 | * h->mb. need only valid values from other blocks */ |
362 | 362 | #define x264_mb_predict_mv_ref16x16 x264_template(mb_predict_mv_ref16x16) |
363 | void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[8][2], int *i_mvc ); | |
363 | void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t (*mvc)[2], int *i_mvc ); | |
364 | 364 | |
365 | 365 | #define x264_mb_mc x264_template(mb_mc) |
366 | 366 | void x264_mb_mc( x264_t *h ); |
394 | 394 | static ALWAYS_INLINE uint32_t pack16to32_mask( int a, int b ) |
395 | 395 | { |
396 | 396 | #if WORDS_BIGENDIAN |
397 | return (b&0xFFFF) + (a<<16); | |
398 | #else | |
399 | return (a&0xFFFF) + (b<<16); | |
397 | return (b&0xFFFF) + ((uint32_t)a<<16); | |
398 | #else | |
399 | return (a&0xFFFF) + ((uint32_t)b<<16); | |
400 | 400 | #endif |
401 | 401 | } |
402 | 402 | static ALWAYS_INLINE uint64_t pack32to64( uint32_t a, uint32_t b ) |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.c: motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
115 | 115 | static void mc_weight( pixel *dst, intptr_t i_dst_stride, pixel *src, intptr_t i_src_stride, |
116 | 116 | const x264_weight_t *weight, int i_width, int i_height ) |
117 | 117 | { |
118 | int offset = weight->i_offset << (BIT_DEPTH-8); | |
118 | int offset = weight->i_offset * (1 << (BIT_DEPTH-8)); | |
119 | 119 | int scale = weight->i_scale; |
120 | 120 | int denom = weight->i_denom; |
121 | 121 | if( denom >= 1 ) |
422 | 422 | int v = pix[0]+pix[1]+pix[2]+pix[3]; |
423 | 423 | for( int x = 0; x < stride-4; x++ ) |
424 | 424 | { |
425 | sum[x] = v + sum[x-stride]; | |
425 | sum[x] = (uint16_t)(v + sum[x-stride]); | |
426 | 426 | v += pix[x+4] - pix[x]; |
427 | 427 | } |
428 | 428 | } |
432 | 432 | int v = pix[0]+pix[1]+pix[2]+pix[3]+pix[4]+pix[5]+pix[6]+pix[7]; |
433 | 433 | for( int x = 0; x < stride-8; x++ ) |
434 | 434 | { |
435 | sum[x] = v + sum[x-stride]; | |
435 | sum[x] = (uint16_t)(v + sum[x-stride]); | |
436 | 436 | v += pix[x+8] - pix[x]; |
437 | 437 | } |
438 | 438 | } |
440 | 440 | static void integral_init4v( uint16_t *sum8, uint16_t *sum4, intptr_t stride ) |
441 | 441 | { |
442 | 442 | for( int x = 0; x < stride-8; x++ ) |
443 | sum4[x] = sum8[x+4*stride] - sum8[x]; | |
443 | sum4[x] = (uint16_t)(sum8[x+4*stride] - sum8[x]); | |
444 | 444 | for( int x = 0; x < stride-8; x++ ) |
445 | sum8[x] = sum8[x+8*stride] + sum8[x+8*stride+4] - sum8[x] - sum8[x+4]; | |
445 | sum8[x] = (uint16_t)(sum8[x+8*stride] + sum8[x+8*stride+4] - sum8[x] - sum8[x+4]); | |
446 | 446 | } |
447 | 447 | |
448 | 448 | static void integral_init8v( uint16_t *sum8, intptr_t stride ) |
449 | 449 | { |
450 | 450 | for( int x = 0; x < stride-8; x++ ) |
451 | sum8[x] = sum8[x+8*stride] - sum8[x]; | |
451 | sum8[x] = (uint16_t)(sum8[x+8*stride] - sum8[x]); | |
452 | 452 | } |
453 | 453 | |
454 | 454 | void x264_frame_init_lowres( x264_t *h, x264_frame_t *frame ) |
549 | 549 | |
550 | 550 | int x = mvs[i][0]; |
551 | 551 | int y = mvs[i][1]; |
552 | unsigned mbx = (x>>5)+i; | |
553 | unsigned mby = (y>>5)+mb_y; | |
552 | unsigned mbx = (unsigned)((x>>5)+i); | |
553 | unsigned mby = (unsigned)((y>>5)+mb_y); | |
554 | 554 | unsigned idx0 = mbx + mby * stride; |
555 | 555 | unsigned idx2 = idx0 + stride; |
556 | 556 | x &= 31; |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2004-2021 x264 project | |
3 | * Copyright (C) 2004-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * |
60 | 60 | if( !(lowres_costs[i] & (1 << (list+LOWRES_COST_SHIFT))) )\ |
61 | 61 | continue;\ |
62 | 62 | \ |
63 | unsigned mbx = current[0];\ | |
64 | unsigned mby = current[1];\ | |
63 | unsigned mbx = (unsigned)current[0];\ | |
64 | unsigned mby = (unsigned)current[1];\ | |
65 | 65 | unsigned idx0 = mbx + mby * stride;\ |
66 | 66 | unsigned idx2 = idx0 + stride;\ |
67 | 67 | \ |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct-c.c: msa transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: msa transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock-c.c: msa deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Neha Rana <neha.rana@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.h: msa deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * macros.h: msa macros |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc-c.c: msa motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Neha Rana <neha.rana@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: msa motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Neha Rana <neha.rana@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel-c.c: msa pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mandar Sahastrabuddhe <mandar.sahastrabuddhe@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.h: msa pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mandar Sahastrabuddhe <mandar.sahastrabuddhe@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict-c.c: msa intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mandar Sahastrabuddhe <mandar.sahastrabuddhe@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: msa intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant-c.c: msa quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: msa quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Rishikesh More <rishikesh.more@imgtec.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mvpred.c: motion vector prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
170 | 170 | int16_t *mv_b = h->mb.cache.mv[0][X264_SCAN8_0 - 8]; |
171 | 171 | |
172 | 172 | if( i_refa == -2 || i_refb == -2 || |
173 | !( i_refa | M32( mv_a ) ) || | |
174 | !( i_refb | M32( mv_b ) ) ) | |
173 | !( (uint32_t)i_refa | M32( mv_a ) ) || | |
174 | !( (uint32_t)i_refb | M32( mv_b ) ) ) | |
175 | 175 | { |
176 | 176 | M32( mv ) = 0; |
177 | 177 | } |
256 | 256 | |
257 | 257 | int i_part_8x8 = i_mb_8x8 + x8 + (ypart>>1) * h->mb.i_b8_stride; |
258 | 258 | int i_ref1_ref = h->fref[1][0]->ref[0][i_part_8x8]; |
259 | int i_ref = (map_col_to_list0(i_ref1_ref>>preshift) << postshift) + (offset&i_ref1_ref&MB_INTERLACED); | |
259 | int i_ref = (map_col_to_list0(i_ref1_ref>>preshift) * (1 << postshift)) + (offset&i_ref1_ref&MB_INTERLACED); | |
260 | 260 | |
261 | 261 | if( i_ref >= 0 ) |
262 | 262 | { |
263 | 263 | int dist_scale_factor = h->mb.dist_scale_factor[i_ref][0]; |
264 | 264 | int16_t *mv_col = h->fref[1][0]->mv[0][i_mb_4x4 + 3*x8 + ypart * h->mb.i_b4_stride]; |
265 | int16_t mv_y = (mv_col[1]<<yshift)/2; | |
265 | int16_t mv_y = (mv_col[1] * (1 << yshift)) / 2; | |
266 | 266 | int l0x = ( dist_scale_factor * mv_col[0] + 128 ) >> 8; |
267 | 267 | int l0y = ( dist_scale_factor * mv_y + 128 ) >> 8; |
268 | 268 | if( h->param.i_threads > 1 && (l0y > h->mb.mv_max_spel[1] || l0y-mv_y > h->mb.mv_max_spel[1]) ) |
303 | 303 | mv_c = h->mb.cache.mv[i_list][X264_SCAN8_0 - 8 - 1]; |
304 | 304 | } |
305 | 305 | |
306 | int i_ref = X264_MIN3( (unsigned)i_refa, (unsigned)i_refb, (unsigned)i_refc ); | |
306 | int i_ref = (int)X264_MIN3( (unsigned)i_refa, (unsigned)i_refb, (unsigned)i_refc ); | |
307 | 307 | if( i_ref < 0 ) |
308 | 308 | { |
309 | 309 | i_ref = -1; |
469 | 469 | { |
470 | 470 | int changed; |
471 | 471 | |
472 | changed = M32( h->mb.cache.direct_mv[0][0] ) ^ M32( h->mb.cache.mv[0][x264_scan8[0]] ); | |
473 | changed |= M32( h->mb.cache.direct_mv[1][0] ) ^ M32( h->mb.cache.mv[1][x264_scan8[0]] ); | |
472 | changed = (int)(M32( h->mb.cache.direct_mv[0][0] ) ^ M32( h->mb.cache.mv[0][x264_scan8[0]] )); | |
473 | changed |= (int)(M32( h->mb.cache.direct_mv[1][0] ) ^ M32( h->mb.cache.mv[1][x264_scan8[0]] )); | |
474 | 474 | changed |= h->mb.cache.direct_ref[0][0] ^ h->mb.cache.ref[0][x264_scan8[0]]; |
475 | 475 | changed |= h->mb.cache.direct_ref[1][0] ^ h->mb.cache.ref[1][x264_scan8[0]]; |
476 | 476 | if( !changed && h->mb.i_partition != D_16x16 ) |
477 | 477 | { |
478 | changed |= M32( h->mb.cache.direct_mv[0][3] ) ^ M32( h->mb.cache.mv[0][x264_scan8[12]] ); | |
479 | changed |= M32( h->mb.cache.direct_mv[1][3] ) ^ M32( h->mb.cache.mv[1][x264_scan8[12]] ); | |
478 | changed |= (int)(M32( h->mb.cache.direct_mv[0][3] ) ^ M32( h->mb.cache.mv[0][x264_scan8[12]] )); | |
479 | changed |= (int)(M32( h->mb.cache.direct_mv[1][3] ) ^ M32( h->mb.cache.mv[1][x264_scan8[12]] )); | |
480 | 480 | changed |= h->mb.cache.direct_ref[0][3] ^ h->mb.cache.ref[0][x264_scan8[12]]; |
481 | 481 | changed |= h->mb.cache.direct_ref[1][3] ^ h->mb.cache.ref[1][x264_scan8[12]]; |
482 | 482 | } |
483 | 483 | if( !changed && h->mb.i_partition == D_8x8 ) |
484 | 484 | { |
485 | changed |= M32( h->mb.cache.direct_mv[0][1] ) ^ M32( h->mb.cache.mv[0][x264_scan8[4]] ); | |
486 | changed |= M32( h->mb.cache.direct_mv[1][1] ) ^ M32( h->mb.cache.mv[1][x264_scan8[4]] ); | |
487 | changed |= M32( h->mb.cache.direct_mv[0][2] ) ^ M32( h->mb.cache.mv[0][x264_scan8[8]] ); | |
488 | changed |= M32( h->mb.cache.direct_mv[1][2] ) ^ M32( h->mb.cache.mv[1][x264_scan8[8]] ); | |
485 | changed |= (int)(M32( h->mb.cache.direct_mv[0][1] ) ^ M32( h->mb.cache.mv[0][x264_scan8[4]] )); | |
486 | changed |= (int)(M32( h->mb.cache.direct_mv[1][1] ) ^ M32( h->mb.cache.mv[1][x264_scan8[4]] )); | |
487 | changed |= (int)(M32( h->mb.cache.direct_mv[0][2] ) ^ M32( h->mb.cache.mv[0][x264_scan8[8]] )); | |
488 | changed |= (int)(M32( h->mb.cache.direct_mv[1][2] ) ^ M32( h->mb.cache.mv[1][x264_scan8[8]] )); | |
489 | 489 | changed |= h->mb.cache.direct_ref[0][1] ^ h->mb.cache.ref[0][x264_scan8[4]]; |
490 | 490 | changed |= h->mb.cache.direct_ref[1][1] ^ h->mb.cache.ref[1][x264_scan8[4]]; |
491 | 491 | changed |= h->mb.cache.direct_ref[0][2] ^ h->mb.cache.ref[0][x264_scan8[8]]; |
515 | 515 | } |
516 | 516 | |
517 | 517 | /* This just improves encoder performance, it's not part of the spec */ |
518 | void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[9][2], int *i_mvc ) | |
518 | void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t (*mvc)[2], int *i_mvc ) | |
519 | 519 | { |
520 | 520 | int16_t (*mvr)[2] = h->mb.mvr[i_list][i_ref]; |
521 | 521 | int i = 0; |
532 | 532 | int shift = 1 + MB_INTERLACED - h->mb.field[xy]; \ |
533 | 533 | int16_t *mvp = h->mb.mvr[i_list][i_ref<<1>>shift][xy]; \ |
534 | 534 | mvc[i][0] = mvp[0]; \ |
535 | mvc[i][1] = mvp[1]<<1>>shift; \ | |
535 | mvc[i][1] = mvp[1]*2>>shift; \ | |
536 | 536 | i++; \ |
537 | 537 | } |
538 | 538 | |
589 | 589 | { \ |
590 | 590 | int mb_index = h->mb.i_mb_xy + dx + dy*h->mb.i_mb_stride; \ |
591 | 591 | int scale = (curpoc - refpoc) * l0->inv_ref_poc[MB_INTERLACED&field]; \ |
592 | mvc[i][0] = (l0->mv16x16[mb_index][0]*scale + 128) >> 8; \ | |
593 | mvc[i][1] = (l0->mv16x16[mb_index][1]*scale + 128) >> 8; \ | |
592 | mvc[i][0] = x264_clip3( (l0->mv16x16[mb_index][0]*scale + 128) >> 8, INT16_MIN, INT16_MAX ); \ | |
593 | mvc[i][1] = x264_clip3( (l0->mv16x16[mb_index][1]*scale + 128) >> 8, INT16_MIN, INT16_MAX ); \ | |
594 | 594 | i++; \ |
595 | 595 | } |
596 | 596 |
0 | 0 | /***************************************************************************** |
1 | 1 | * opencl.c: OpenCL initialization and kernel compilation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2012-2021 x264 project | |
3 | * Copyright (C) 2012-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steve Borho <sborho@multicorewareinc.com> |
6 | 6 | * Anton Mitrofanov <BugMaster@narod.ru> |
0 | 0 | /***************************************************************************** |
1 | 1 | * opencl.h: OpenCL structures and defines |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2012-2021 x264 project | |
3 | * Copyright (C) 2012-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steve Borho <sborho@multicorewareinc.com> |
6 | 6 | * Anton Mitrofanov <BugMaster@narod.ru> |
0 | 0 | /***************************************************************************** |
1 | 1 | * osdep.c: platform-specific code |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * osdep.h: platform-specific code |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
288 | 288 | #define ALIGNED_8( var ) DECLARE_ALIGNED( var, 8 ) |
289 | 289 | #define ALIGNED_16( var ) DECLARE_ALIGNED( var, 16 ) |
290 | 290 | |
291 | // ARM compiliers don't reliably align stack variables | |
291 | // ARM compilers don't reliably align stack variables | |
292 | 292 | // - EABI requires only 8 byte stack alignment to be maintained |
293 | 293 | // - gcc can't align stack variables to more even if the stack were to be correctly aligned outside the function |
294 | 294 | // - armcc can't either, but is nice enough to actually tell you so |
495 | 495 | } |
496 | 496 | static ALWAYS_INLINE uint16_t endian_fix16( uint16_t x ) |
497 | 497 | { |
498 | return (x<<8)|(x>>8); | |
498 | return (uint16_t)((x<<8)|(x>>8)); | |
499 | 499 | } |
500 | 500 | #endif |
501 | 501 | |
551 | 551 | #define x264_prefetch(x) |
552 | 552 | #endif |
553 | 553 | |
554 | #if HAVE_POSIXTHREAD | |
555 | #if SYS_WINDOWS | |
556 | #define x264_lower_thread_priority(p)\ | |
557 | {\ | |
558 | x264_pthread_t handle = pthread_self();\ | |
559 | struct sched_param sp;\ | |
560 | int policy = SCHED_OTHER;\ | |
561 | pthread_getschedparam( handle, &policy, &sp );\ | |
562 | sp.sched_priority -= p;\ | |
563 | pthread_setschedparam( handle, policy, &sp );\ | |
564 | } | |
565 | #elif SYS_HAIKU | |
566 | #include <OS.h> | |
567 | #define x264_lower_thread_priority(p)\ | |
568 | { UNUSED status_t nice_ret = set_thread_priority( find_thread( NULL ), B_LOW_PRIORITY ); } | |
569 | #else | |
570 | #include <unistd.h> | |
571 | #define x264_lower_thread_priority(p) { UNUSED int nice_ret = nice(p); } | |
572 | #endif /* SYS_WINDOWS */ | |
573 | #elif HAVE_WIN32THREAD | |
574 | #define x264_lower_thread_priority(p) SetThreadPriority( GetCurrentThread(), X264_MAX( -2, -p ) ) | |
575 | #else | |
576 | #define x264_lower_thread_priority(p) | |
577 | #endif | |
578 | ||
579 | 554 | #endif /* X264_OSDEP_H */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.c: pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
266 | 266 | sum2_t sum = 0; |
267 | 267 | for( int i = 0; i < 4; i++, pix1 += i_pix1, pix2 += i_pix2 ) |
268 | 268 | { |
269 | a0 = pix1[0] - pix2[0]; | |
270 | a1 = pix1[1] - pix2[1]; | |
269 | a0 = (sum2_t)(pix1[0] - pix2[0]); | |
270 | a1 = (sum2_t)(pix1[1] - pix2[1]); | |
271 | 271 | b0 = (a0+a1) + ((a0-a1)<<BITS_PER_SUM); |
272 | a2 = pix1[2] - pix2[2]; | |
273 | a3 = pix1[3] - pix2[3]; | |
272 | a2 = (sum2_t)(pix1[2] - pix2[2]); | |
273 | a3 = (sum2_t)(pix1[3] - pix2[3]); | |
274 | 274 | b1 = (a2+a3) + ((a2-a3)<<BITS_PER_SUM); |
275 | 275 | tmp[i][0] = b0 + b1; |
276 | 276 | tmp[i][1] = b0 - b1; |
291 | 291 | sum2_t sum = 0; |
292 | 292 | for( int i = 0; i < 4; i++, pix1 += i_pix1, pix2 += i_pix2 ) |
293 | 293 | { |
294 | a0 = (pix1[0] - pix2[0]) + ((sum2_t)(pix1[4] - pix2[4]) << BITS_PER_SUM); | |
295 | a1 = (pix1[1] - pix2[1]) + ((sum2_t)(pix1[5] - pix2[5]) << BITS_PER_SUM); | |
296 | a2 = (pix1[2] - pix2[2]) + ((sum2_t)(pix1[6] - pix2[6]) << BITS_PER_SUM); | |
297 | a3 = (pix1[3] - pix2[3]) + ((sum2_t)(pix1[7] - pix2[7]) << BITS_PER_SUM); | |
294 | a0 = (sum2_t)(pix1[0] - pix2[0]) + ((sum2_t)(pix1[4] - pix2[4]) << BITS_PER_SUM); | |
295 | a1 = (sum2_t)(pix1[1] - pix2[1]) + ((sum2_t)(pix1[5] - pix2[5]) << BITS_PER_SUM); | |
296 | a2 = (sum2_t)(pix1[2] - pix2[2]) + ((sum2_t)(pix1[6] - pix2[6]) << BITS_PER_SUM); | |
297 | a3 = (sum2_t)(pix1[3] - pix2[3]) + ((sum2_t)(pix1[7] - pix2[7]) << BITS_PER_SUM); | |
298 | 298 | HADAMARD4( tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], a0,a1,a2,a3 ); |
299 | 299 | } |
300 | 300 | for( int i = 0; i < 4; i++ ) |
335 | 335 | sum2_t sum = 0; |
336 | 336 | for( int i = 0; i < 8; i++, pix1 += i_pix1, pix2 += i_pix2 ) |
337 | 337 | { |
338 | a0 = pix1[0] - pix2[0]; | |
339 | a1 = pix1[1] - pix2[1]; | |
338 | a0 = (sum2_t)(pix1[0] - pix2[0]); | |
339 | a1 = (sum2_t)(pix1[1] - pix2[1]); | |
340 | 340 | b0 = (a0+a1) + ((a0-a1)<<BITS_PER_SUM); |
341 | a2 = pix1[2] - pix2[2]; | |
342 | a3 = pix1[3] - pix2[3]; | |
341 | a2 = (sum2_t)(pix1[2] - pix2[2]); | |
342 | a3 = (sum2_t)(pix1[3] - pix2[3]); | |
343 | 343 | b1 = (a2+a3) + ((a2-a3)<<BITS_PER_SUM); |
344 | a4 = pix1[4] - pix2[4]; | |
345 | a5 = pix1[5] - pix2[5]; | |
344 | a4 = (sum2_t)(pix1[4] - pix2[4]); | |
345 | a5 = (sum2_t)(pix1[5] - pix2[5]); | |
346 | 346 | b2 = (a4+a5) + ((a4-a5)<<BITS_PER_SUM); |
347 | a6 = pix1[6] - pix2[6]; | |
348 | a7 = pix1[7] - pix2[7]; | |
347 | a6 = (sum2_t)(pix1[6] - pix2[6]); | |
348 | a7 = (sum2_t)(pix1[7] - pix2[7]); | |
349 | 349 | b3 = (a6+a7) + ((a6-a7)<<BITS_PER_SUM); |
350 | 350 | HADAMARD4( tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], b0,b1,b2,b3 ); |
351 | 351 | } |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.c: pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2004-2021 x264 project | |
3 | * Copyright (C) 2004-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.c: ppc transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * Eric Petit <eric.petit@lapsus.org> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: ppc transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * Guillaume Poirier <gpoirier@mplayerhq.hu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.c: ppc deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.h: ppc deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.c: ppc motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * Guillaume Poirier <gpoirier@mplayerhq.hu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: ppc motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.c: ppc pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * Guillaume Poirier <gpoirier@mplayerhq.hu> |
1261 | 1261 | SA8D_1D_ALTIVEC(sa8d0v, sa8d1v, sa8d2v, sa8d3v, |
1262 | 1262 | sa8d4v, sa8d5v, sa8d6v, sa8d7v ); |
1263 | 1263 | |
1264 | /* accumulation of the absolute value of all elements of the resulting bloc */ | |
1264 | /* accumulation of the absolute value of all elements of the resulting block */ | |
1265 | 1265 | vec_s16_t abs0v = VEC_ABS(sa8d0v); |
1266 | 1266 | vec_s16_t abs1v = VEC_ABS(sa8d1v); |
1267 | 1267 | vec_s16_t sum01v = vec_add(abs0v, abs1v); |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.h: ppc pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * ppccommon.h: ppc utility macros |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Eric Petit <eric.petit@lapsus.org> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.c: ppc intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: ppc intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.c: ppc quantization |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: ppc quantization |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2007-2021 x264 project | |
3 | * Copyright (C) 2007-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Guillaume Poirier <gpoirier@mplayerhq.hu> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.c: intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.c: quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
46 | 46 | #define QUANT_ONE( coef, mf, f ) \ |
47 | 47 | { \ |
48 | 48 | if( (coef) > 0 ) \ |
49 | (coef) = (f + (coef)) * (mf) >> 16; \ | |
49 | (coef) = ((f) + (uint32_t)(coef)) * (mf) >> 16; \ | |
50 | 50 | else \ |
51 | (coef) = - ((f - (coef)) * (mf) >> 16); \ | |
51 | (coef) = -(int32_t)(((f) + (uint32_t)(-coef)) * (mf) >> 16); \ | |
52 | 52 | nz |= (coef); \ |
53 | 53 | } |
54 | 54 | |
100 | 100 | } |
101 | 101 | |
102 | 102 | #define DEQUANT_SHL( x ) \ |
103 | dct[x] = ( dct[x] * dequant_mf[i_mf][x] ) << i_qbits | |
103 | dct[x] = ( dct[x] * dequant_mf[i_mf][x] ) * (1 << i_qbits) | |
104 | 104 | |
105 | 105 | #define DEQUANT_SHR( x ) \ |
106 | 106 | dct[x] = ( dct[x] * dequant_mf[i_mf][x] + f ) >> (-i_qbits) |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * rectangle.c: rectangle filling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * rectangle.h: rectangle filling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
27 | 27 | static ALWAYS_INLINE void x264_macroblock_cache_rect( void *dst, int w, int h, int s, uint32_t v ) |
28 | 28 | { |
29 | 29 | uint8_t *d = dst; |
30 | uint16_t v2 = s == 2 ? v : v * 0x101; | |
31 | uint32_t v4 = s == 4 ? v : s == 2 ? v * 0x10001 : v * 0x1010101; | |
30 | uint16_t v2 = s >= 2 ? v : v * 0x101; | |
31 | uint32_t v4 = s >= 4 ? v : s >= 2 ? v * 0x10001 : v * 0x1010101; | |
32 | 32 | uint64_t v8 = v4 + ((uint64_t)v4 << 32); |
33 | 33 | s *= 8; |
34 | 34 | |
141 | 141 | else |
142 | 142 | x264_macroblock_cache_rect( mvd_cache, width*2, height, 2, mvd ); |
143 | 143 | } |
144 | static ALWAYS_INLINE void x264_macroblock_cache_ref( x264_t *h, int x, int y, int width, int height, int i_list, uint8_t ref ) | |
144 | static ALWAYS_INLINE void x264_macroblock_cache_ref( x264_t *h, int x, int y, int width, int height, int i_list, int8_t ref ) | |
145 | 145 | { |
146 | 146 | void *ref_cache = &h->mb.cache.ref[i_list][X264_SCAN8_0+x+8*y]; |
147 | 147 | if( x264_nonconstant_p( width ) || x264_nonconstant_p( height ) ) |
148 | x264_cache_ref_func_table[width + (height<<1)-3]( ref_cache, ref ); | |
148 | x264_cache_ref_func_table[width + (height<<1)-3]( ref_cache, (uint8_t)ref ); | |
149 | 149 | else |
150 | x264_macroblock_cache_rect( ref_cache, width, height, 1, ref ); | |
150 | x264_macroblock_cache_rect( ref_cache, width, height, 1, (uint8_t)ref ); | |
151 | 151 | } |
152 | 152 | static ALWAYS_INLINE void x264_macroblock_cache_skip( x264_t *h, int x, int y, int width, int height, int b_skip ) |
153 | 153 | { |
0 | 0 | /***************************************************************************** |
1 | 1 | * set.c: quantization init |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * |
157 | 157 | quant8_mf[i_list][q][i] = DIV(def_quant8[q][i] * 16, h->sps->scaling_list[4+i_list][i]); |
158 | 158 | } |
159 | 159 | } |
160 | ||
161 | #define MAX_MF X264_MIN( 0xffff, (1 << (25 - BIT_DEPTH)) - 1 ) | |
162 | ||
160 | 163 | for( int q = 0; q <= QP_MAX_SPEC; q++ ) |
161 | 164 | { |
162 | 165 | int j; |
164 | 167 | for( int i = 0; i < 16; i++ ) |
165 | 168 | { |
166 | 169 | h->unquant4_mf[i_list][q][i] = (1ULL << (q/6 + 15 + 8)) / quant4_mf[i_list][q%6][i]; |
167 | h->quant4_mf[i_list][q][i] = j = SHIFT(quant4_mf[i_list][q%6][i], q/6 - 1); | |
170 | j = SHIFT(quant4_mf[i_list][q%6][i], q/6 - 1); | |
171 | h->quant4_mf[i_list][q][i] = (uint16_t)j; | |
168 | 172 | if( !j ) |
169 | 173 | { |
170 | 174 | min_qp_err = X264_MIN( min_qp_err, q ); |
173 | 177 | // round to nearest, unless that would cause the deadzone to be negative |
174 | 178 | h->quant4_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j ); |
175 | 179 | h->quant4_bias0[i_list][q][i] = (1<<15)/j; |
176 | if( j > 0xffff && q > max_qp_err && (i_list == CQM_4IY || i_list == CQM_4PY) ) | |
180 | if( j > MAX_MF && q > max_qp_err && (i_list == CQM_4IY || i_list == CQM_4PY) ) | |
177 | 181 | max_qp_err = q; |
178 | if( j > 0xffff && q > max_chroma_qp_err && (i_list == CQM_4IC || i_list == CQM_4PC) ) | |
182 | if( j > MAX_MF && q > max_chroma_qp_err && (i_list == CQM_4IC || i_list == CQM_4PC) ) | |
179 | 183 | max_chroma_qp_err = q; |
180 | 184 | } |
181 | 185 | if( h->param.analyse.b_transform_8x8 ) |
193 | 197 | } |
194 | 198 | h->quant8_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j ); |
195 | 199 | h->quant8_bias0[i_list][q][i] = (1<<15)/j; |
196 | if( j > 0xffff && q > max_qp_err && (i_list == CQM_8IY || i_list == CQM_8PY) ) | |
200 | if( j > MAX_MF && q > max_qp_err && (i_list == CQM_8IY || i_list == CQM_8PY) ) | |
197 | 201 | max_qp_err = q; |
198 | if( j > 0xffff && q > max_chroma_qp_err && (i_list == CQM_8IC || i_list == CQM_8PC) ) | |
202 | if( j > MAX_MF && q > max_chroma_qp_err && (i_list == CQM_8IC || i_list == CQM_8PC) ) | |
199 | 203 | max_chroma_qp_err = q; |
200 | 204 | } |
201 | 205 | } |
0 | 0 | /***************************************************************************** |
1 | 1 | * set.h: quantization init |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
139 | 139 | int b_qpprime_y_zero_transform_bypass; |
140 | 140 | int i_chroma_format_idc; |
141 | 141 | |
142 | int b_avcintra; | |
142 | int b_avcintra_hd; | |
143 | int b_avcintra_4k; | |
143 | 144 | int i_cqm_preset; |
144 | 145 | const uint8_t *scaling_list[8]; /* could be 12, but we don't allow separate Cb/Cr lists */ |
145 | 146 |
0 | 0 | /***************************************************************************** |
1 | 1 | * tables.c: const tables |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
242 | 242 | x264_cqm_jvt8i, x264_cqm_jvt8p |
243 | 243 | }; |
244 | 244 | |
245 | // 1080i25_avci50, 1080p25_avci50 | |
245 | // 720p_avci50, 1080i_avci50, 1080p_avci50 | |
246 | 246 | const uint8_t x264_cqm_avci50_4ic[16] = |
247 | 247 | { |
248 | 248 | 16,22,28,40, |
251 | 251 | 40,44,48,60 |
252 | 252 | }; |
253 | 253 | |
254 | // 1080p25_avci50, 720p25_avci50, 720p50_avci50 | |
254 | // 720p_avci50, 1080p_avci50 | |
255 | 255 | const uint8_t x264_cqm_avci50_p_8iy[64] = |
256 | 256 | { |
257 | 257 | 16,18,19,21,24,27,30,33, |
264 | 264 | 33,78,81,84,87,90,93,96 |
265 | 265 | }; |
266 | 266 | |
267 | // 1080i25_avci50, | |
267 | // 1080i_avci50 | |
268 | 268 | const uint8_t x264_cqm_avci50_1080i_8iy[64] = |
269 | 269 | { |
270 | 270 | 16,18,19,21,27,33,81,87, |
277 | 277 | 30,33,33,78,81,84,87,96 |
278 | 278 | }; |
279 | 279 | |
280 | // 720p25_avci100, 720p50_avci100 | |
280 | // 720p_avci100 | |
281 | 281 | const uint8_t x264_cqm_avci100_720p_4ic[16] = |
282 | 282 | { |
283 | 283 | 16,21,27,34, |
286 | 286 | 34,41,46,54 |
287 | 287 | }; |
288 | 288 | |
289 | // 720p25_avci100, 720p50_avci100 | |
289 | // 720p_avci100 | |
290 | 290 | const uint8_t x264_cqm_avci100_720p_8iy[64] = |
291 | 291 | { |
292 | 292 | 16,18,19,21,22,24,26,32, |
299 | 299 | 32,32,32,34,34,36,38,42 |
300 | 300 | }; |
301 | 301 | |
302 | // 1080i25_avci100, 1080p25_avci100 | |
302 | // 1080i_avci100, 1080p_avci100 | |
303 | 303 | const uint8_t x264_cqm_avci100_1080_4ic[16] = |
304 | 304 | { |
305 | 305 | 16,20,26,32, |
308 | 308 | 32,38,44,50 |
309 | 309 | }; |
310 | 310 | |
311 | // 1080i25_avci100, | |
311 | // 1080i_avci100 | |
312 | 312 | const uint8_t x264_cqm_avci100_1080i_8iy[64] = |
313 | 313 | { |
314 | 314 | 16,19,20,23,24,26,32,42, |
321 | 321 | 22,23,24,26,36,42,59,72 |
322 | 322 | }; |
323 | 323 | |
324 | // 1080p25_avci100, | |
324 | // 1080p_avci100 | |
325 | 325 | const uint8_t x264_cqm_avci100_1080p_8iy[64] = |
326 | 326 | { |
327 | 327 | 16,18,19,20,22,23,24,26, |
332 | 332 | 23,24,26,32,36,42,59,63, |
333 | 333 | 24,26,32,36,42,59,63,68, |
334 | 334 | 26,32,36,42,59,63,68,72 |
335 | }; | |
336 | ||
337 | // 2160p_avci300 | |
338 | const uint8_t x264_cqm_avci300_2160p_4iy[16] = | |
339 | { | |
340 | 12,16,19,20, | |
341 | 16,19,20,24, | |
342 | 19,20,24,33, | |
343 | 20,24,33,39 | |
344 | }; | |
345 | ||
346 | // 2160p_avci300 | |
347 | const uint8_t x264_cqm_avci300_2160p_4ic[16] = | |
348 | { | |
349 | 28,39,56,67, | |
350 | 39,56,67,77, | |
351 | 56,67,77,104, | |
352 | 67,77,104,133 | |
353 | }; | |
354 | ||
355 | // 2160p_avci300 | |
356 | const uint8_t x264_cqm_avci300_2160p_8iy[64] = | |
357 | { | |
358 | 12,14,16,17,19,20,20,24, | |
359 | 14,16,17,19,20,20,24,30, | |
360 | 16,17,19,20,20,24,30,42, | |
361 | 17,19,20,20,24,30,42,56, | |
362 | 19,20,20,24,30,42,56,72, | |
363 | 20,20,24,30,42,56,72,76, | |
364 | 20,24,30,42,56,72,76,80, | |
365 | 24,30,42,56,72,76,80,84 | |
335 | 366 | }; |
336 | 367 | |
337 | 368 | /***************************************************************************** |
0 | 0 | /***************************************************************************** |
1 | 1 | * tables.h: const tables |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
62 | 62 | extern const uint8_t x264_cqm_avci100_1080_4ic[16]; |
63 | 63 | extern const uint8_t x264_cqm_avci100_1080i_8iy[64]; |
64 | 64 | extern const uint8_t x264_cqm_avci100_1080p_8iy[64]; |
65 | extern const uint8_t x264_cqm_avci300_2160p_4iy[16]; | |
66 | extern const uint8_t x264_cqm_avci300_2160p_4ic[16]; | |
67 | extern const uint8_t x264_cqm_avci300_2160p_8iy[64]; | |
65 | 68 | |
66 | 69 | extern const uint8_t x264_decimate_table4[16]; |
67 | 70 | extern const uint8_t x264_decimate_table8[64]; |
0 | 0 | /***************************************************************************** |
1 | 1 | * threadpool.c: thread pooling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
36 | 36 | volatile int exit; |
37 | 37 | int threads; |
38 | 38 | x264_pthread_t *thread_handle; |
39 | void (*init_func)(void *); | |
40 | void *init_arg; | |
41 | 39 | |
42 | 40 | /* requires a synchronized list structure and associated methods, |
43 | 41 | so use what is already implemented for frames */ |
48 | 46 | |
49 | 47 | REALIGN_STACK static void *threadpool_thread( x264_threadpool_t *pool ) |
50 | 48 | { |
51 | if( pool->init_func ) | |
52 | pool->init_func( pool->init_arg ); | |
53 | ||
54 | 49 | while( !pool->exit ) |
55 | 50 | { |
56 | 51 | x264_threadpool_job_t *job = NULL; |
71 | 66 | return NULL; |
72 | 67 | } |
73 | 68 | |
74 | int x264_threadpool_init( x264_threadpool_t **p_pool, int threads, | |
75 | void (*init_func)(void *), void *init_arg ) | |
69 | int x264_threadpool_init( x264_threadpool_t **p_pool, int threads ) | |
76 | 70 | { |
77 | 71 | if( threads <= 0 ) |
78 | 72 | return -1; |
84 | 78 | CHECKED_MALLOCZERO( pool, sizeof(x264_threadpool_t) ); |
85 | 79 | *p_pool = pool; |
86 | 80 | |
87 | pool->init_func = init_func; | |
88 | pool->init_arg = init_arg; | |
89 | 81 | pool->threads = threads; |
90 | 82 | |
91 | 83 | CHECKED_MALLOC( pool->thread_handle, pool->threads * sizeof(x264_pthread_t) ); |
0 | 0 | /***************************************************************************** |
1 | 1 | * threadpool.h: thread pooling |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
29 | 29 | |
30 | 30 | #if HAVE_THREAD |
31 | 31 | #define x264_threadpool_init x264_template(threadpool_init) |
32 | X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads, | |
33 | void (*init_func)(void *), void *init_arg ); | |
32 | X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads ); | |
34 | 33 | #define x264_threadpool_run x264_template(threadpool_run) |
35 | 34 | X264_API void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg ); |
36 | 35 | #define x264_threadpool_wait x264_template(threadpool_wait) |
38 | 37 | #define x264_threadpool_delete x264_template(threadpool_delete) |
39 | 38 | X264_API void x264_threadpool_delete( x264_threadpool_t *pool ); |
40 | 39 | #else |
41 | #define x264_threadpool_init(p,t,f,a) -1 | |
40 | #define x264_threadpool_init(p,t) -1 | |
42 | 41 | #define x264_threadpool_run(p,f,a) |
43 | 42 | #define x264_threadpool_wait(p,a) NULL |
44 | 43 | #define x264_threadpool_delete(p) |
0 | 0 | /***************************************************************************** |
1 | 1 | * vlc.c : vlc tables |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
36 | 36 | { |
37 | 37 | int mask = level >> 15; |
38 | 38 | int abs_level = (level^mask)-mask; |
39 | int i_level_code = abs_level*2-mask-2; | |
39 | int i_level_code = abs_level ? abs_level*2-mask-2 : 0; | |
40 | 40 | int i_next = i_suffix; |
41 | 41 | vlc_large_t *vlc = &x264_level_token[i_suffix][level+LEVEL_TABLE_SIZE/2]; |
42 | 42 |
0 | 0 | /***************************************************************************** |
1 | 1 | * win32thread.c: windows threading |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * Pegasys Inc. <http://www.pegasys-inc.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * win32thread.h: windows threading |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* bitstream-a.asm: x86 bitstream functions |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2010-2021 x264 project | |
3 | ;* Copyright (C) 2010-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | ;* Henrik Gramner <henrik@gramner.com> |
33 | 33 | ;----------------------------------------------------------------------------- |
34 | 34 | %macro NAL_LOOP 2 |
35 | 35 | %%escape: |
36 | ; Detect false positive to avoid unneccessary escape loop | |
36 | ; Detect false positive to avoid unnecessary escape loop | |
37 | 37 | xor r3d, r3d |
38 | 38 | cmp byte [r0+r1-1], 0 |
39 | 39 | setnz r3b |
0 | 0 | /***************************************************************************** |
1 | 1 | * bitstream.h: x86 bitstream functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* cabac-a.asm: x86 cabac |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2008-2021 x264 project | |
3 | ;* Copyright (C) 2008-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* const-a.asm: x86 global constants |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2010-2021 x264 project | |
3 | ;* Copyright (C) 2010-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* cpu-a.asm: x86 cpu utilities |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | ;* Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* dct-32.asm: x86_32 transform and zigzag |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Holger Lubitz <holger@lubitz.org> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* dct-64.asm: x86_64 transform and zigzag |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Holger Lubitz <holger@lubitz.org> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* dct-a.asm: x86 transform and zigzag |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Holger Lubitz <holger@lubitz.org> |
6 | 6 | ;* Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * dct.h: x86 transform and zigzag |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* deblock-a.asm: x86 deblocking |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2005-2021 x264 project | |
3 | ;* Copyright (C) 2005-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * deblock.h: x86 deblocking |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* mc-a.asm: x86 motion compensation |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* mc-a2.asm: x86 motion compensation |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2005-2021 x264 project | |
3 | ;* Copyright (C) 2005-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc-c.c: x86 motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
498 | 498 | else |
499 | 499 | w->weightfn = h->mc.offsetadd; |
500 | 500 | for( int i = 0; i < 8; i++ ) |
501 | w->cachea[i] = abs(w->i_offset<<(BIT_DEPTH-8)); | |
501 | w->cachea[i] = abs(w->i_offset * (1 << (BIT_DEPTH-8))); | |
502 | 502 | return; |
503 | 503 | } |
504 | 504 | w->weightfn = h->mc.weight; |
505 | 505 | int den1 = 1<<w->i_denom; |
506 | 506 | int den2 = w->i_scale<<1; |
507 | int den3 = 1+(w->i_offset<<(BIT_DEPTH-8+1)); | |
507 | int den3 = 1+(w->i_offset * (1 << (BIT_DEPTH-8+1))); | |
508 | 508 | for( int i = 0; i < 8; i++ ) |
509 | 509 | { |
510 | 510 | w->cachea[i] = den1; |
536 | 536 | return; |
537 | 537 | } |
538 | 538 | w->weightfn = h->mc.weight; |
539 | den1 = w->i_offset << w->i_denom | (w->i_denom ? 1 << (w->i_denom - 1) : 0); | |
539 | den1 = (w->i_offset * (1<<w->i_denom)) | (w->i_denom ? 1 << (w->i_denom - 1) : 0); | |
540 | 540 | for( i = 0; i < 8; i++ ) |
541 | 541 | { |
542 | 542 | w->cachea[i] = w->i_scale; |
0 | 0 | /***************************************************************************** |
1 | 1 | * mc.h: x86 motion compensation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* pixel-32.asm: x86_32 pixel metrics |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* pixel.asm: x86 pixel metrics |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Holger Lubitz <holger@lubitz.org> |
0 | 0 | /***************************************************************************** |
1 | 1 | * pixel.h: x86 pixel metrics |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* predict-a.asm: x86 intra prediction |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2005-2021 x264 project | |
3 | ;* Copyright (C) 2005-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Holger Lubitz <holger@lubitz.org> |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict-c.c: intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
61 | 61 | int b = ( 5 * H + 32 ) >> 6;\ |
62 | 62 | int c = ( 5 * V + 32 ) >> 6;\ |
63 | 63 | int i00 = a - b * 7 - c * 7 + 16;\ |
64 | /* b*15 + c*15 can overflow: it's easier to just branch away in this rare case | |
64 | /* b*15 + c*15 can overflow: it's easier to just branch away in this rare case\ | |
65 | 65 | * than to try to consider it in the asm. */\ |
66 | 66 | if( BIT_DEPTH > 8 && (i00 > 0x7fff || abs(b) > 1092 || abs(c) > 1092) )\ |
67 | 67 | x264_predict_16x16_p_c( src );\ |
0 | 0 | /***************************************************************************** |
1 | 1 | * predict.h: x86 intra prediction |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* quant-a.asm: x86 quantization and level-run |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2005-2021 x264 project | |
3 | ;* Copyright (C) 2005-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
166 | 166 | ABSD m1, m0 |
167 | 167 | paddd m1, %3 |
168 | 168 | pmulld m1, %2 |
169 | psrad m1, 16 | |
169 | psrld m1, 16 | |
170 | 170 | %else ; !sse4 |
171 | 171 | mova m0, [%1] |
172 | 172 | ABSD m1, m0 |
194 | 194 | paddd m3, %3 |
195 | 195 | pmulld m2, %2 |
196 | 196 | pmulld m3, %2 |
197 | psrad m2, 16 | |
198 | psrad m3, 16 | |
197 | psrld m2, 16 | |
198 | psrld m3, 16 | |
199 | 199 | PSIGND m2, m0 |
200 | 200 | PSIGND m3, m1 |
201 | 201 | mova [%1 ], m2 |
221 | 221 | pmuludq m3, m4 |
222 | 222 | psllq m3, 32 |
223 | 223 | paddd m1, m3 |
224 | psrad m1, 16 | |
224 | psrld m1, 16 | |
225 | 225 | PSIGND m1, m0 |
226 | 226 | mova [%1], m1 |
227 | 227 | ACCUM por, %5, 1, %4 |
237 | 237 | paddd m3, [%3+mmsize] |
238 | 238 | pmulld m2, [%2 ] |
239 | 239 | pmulld m3, [%2+mmsize] |
240 | psrad m2, 16 | |
241 | psrad m3, 16 | |
240 | psrld m2, 16 | |
241 | psrld m3, 16 | |
242 | 242 | PSIGND m2, m0 |
243 | 243 | PSIGND m3, m1 |
244 | 244 | mova [%1 ], m2 |
0 | 0 | /***************************************************************************** |
1 | 1 | * quant.h: x86 quantization and level-run |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* sad-a.asm: x86 sad functions |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2003-2021 x264 project | |
3 | ;* Copyright (C) 2003-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Fiona Glaser <fiona@x264.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* sad16-a.asm: x86 high depth sad functions |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2010-2021 x264 project | |
3 | ;* Copyright (C) 2010-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Oskar Arvidsson <oskar@irock.se> |
6 | 6 | ;* Henrik Gramner <henrik@gramner.com> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* trellis-64.asm: x86_64 trellis quantization |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2012-2021 x264 project | |
3 | ;* Copyright (C) 2012-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* |
157 | 157 | %define cost_siglast stack+80 |
158 | 158 | %define level_tree stack+96 |
159 | 159 | |
160 | ; trellis_node_t is layed out differently than C. | |
160 | ; trellis_node_t is laid out differently than C. | |
161 | 161 | ; struct-of-arrays rather than array-of-structs, for simd. |
162 | 162 | %define nodes_curq r7 |
163 | 163 | %define nodes_prevq r8 |
0 | 0 | /***************************************************************************** |
1 | 1 | * util.h: x86 inline asm |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2008-2021 x264 project | |
3 | * Copyright (C) 2008-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
120 | 120 | "m"(pb_2),"m"(pb_32),"m"(pb_33) |
121 | 121 | :"mm0", "mm1", "mm2" |
122 | 122 | ); |
123 | return amvd; | |
123 | return (uint16_t)amvd; | |
124 | 124 | } |
125 | 125 | |
126 | 126 | #define x264_predictor_clip x264_predictor_clip_mmx2 |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* x86inc.asm: x264asm abstraction layer |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2005-2021 x264 project | |
3 | ;* Copyright (C) 2005-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Henrik Gramner <henrik@gramner.com> |
85 | 85 | %define mangle(x) x |
86 | 86 | %endif |
87 | 87 | |
88 | ; Use VEX-encoding even in non-AVX functions | |
89 | %ifndef FORCE_VEX_ENCODING | |
90 | %define FORCE_VEX_ENCODING 0 | |
91 | %endif | |
92 | ||
88 | 93 | %macro SECTION_RODATA 0-1 16 |
89 | 94 | %ifidn __OUTPUT_FORMAT__,win32 |
90 | 95 | SECTION .rdata align=%1 |
237 | 242 | %else |
238 | 243 | mov %1, %2 |
239 | 244 | %endif |
245 | %endmacro | |
246 | ||
247 | ; Repeats an instruction/operation for multiple arguments. | |
248 | ; Example usage: "REPX {psrlw x, 8}, m0, m1, m2, m3" | |
249 | %macro REPX 2-* ; operation, args | |
250 | %xdefine %%f(x) %1 | |
251 | %rep %0 - 1 | |
252 | %rotate 1 | |
253 | %%f(%1) | |
254 | %endrep | |
240 | 255 | %endmacro |
241 | 256 | |
242 | 257 | %macro PUSH 1 |
1013 | 1028 | %endmacro |
1014 | 1029 | |
1015 | 1030 | %macro INIT_XMM 0-1+ |
1016 | %assign avx_enabled 0 | |
1031 | %assign avx_enabled FORCE_VEX_ENCODING | |
1017 | 1032 | %define RESET_MM_PERMUTATION INIT_XMM %1 |
1018 | 1033 | %define mmsize 16 |
1019 | 1034 | %define mova movdqa |
1336 | 1351 | %1 %6, __src2 |
1337 | 1352 | %endif |
1338 | 1353 | %elif %0 >= 9 |
1339 | __instr %6, %7, %8, %9 | |
1354 | %if avx_enabled && __sizeofreg >= 16 && %4 == 1 | |
1355 | %ifnnum regnumof%7 | |
1356 | %if %3 | |
1357 | vmovaps %6, %7 | |
1358 | %else | |
1359 | vmovdqa %6, %7 | |
1360 | %endif | |
1361 | __instr %6, %6, %8, %9 | |
1362 | %else | |
1363 | __instr %6, %7, %8, %9 | |
1364 | %endif | |
1365 | %else | |
1366 | __instr %6, %7, %8, %9 | |
1367 | %endif | |
1340 | 1368 | %elif %0 == 8 |
1341 | %if avx_enabled && %5 | |
1369 | %if avx_enabled && __sizeofreg >= 16 && %4 == 0 | |
1342 | 1370 | %xdefine __src1 %7 |
1343 | 1371 | %xdefine __src2 %8 |
1344 | %ifnum regnumof%7 | |
1345 | %ifnum regnumof%8 | |
1346 | %if regnumof%7 < 8 && regnumof%8 >= 8 && regnumof%8 < 16 && sizeof%8 <= 32 | |
1347 | ; Most VEX-encoded instructions require an additional byte to encode when | |
1348 | ; src2 is a high register (e.g. m8..15). If the instruction is commutative | |
1349 | ; we can swap src1 and src2 when doing so reduces the instruction length. | |
1350 | %xdefine __src1 %8 | |
1351 | %xdefine __src2 %7 | |
1372 | %if %5 | |
1373 | %ifnum regnumof%7 | |
1374 | %ifnum regnumof%8 | |
1375 | %if regnumof%7 < 8 && regnumof%8 >= 8 && regnumof%8 < 16 && sizeof%8 <= 32 | |
1376 | ; Most VEX-encoded instructions require an additional byte to encode when | |
1377 | ; src2 is a high register (e.g. m8..15). If the instruction is commutative | |
1378 | ; we can swap src1 and src2 when doing so reduces the instruction length. | |
1379 | %xdefine __src1 %8 | |
1380 | %xdefine __src2 %7 | |
1381 | %endif | |
1352 | 1382 | %endif |
1383 | %elifnum regnumof%8 ; put memory operands in src2 when possible | |
1384 | %xdefine __src1 %8 | |
1385 | %xdefine __src2 %7 | |
1386 | %else | |
1387 | %assign __emulate_avx 1 | |
1353 | 1388 | %endif |
1354 | %endif | |
1355 | __instr %6, __src1, __src2 | |
1389 | %elifnnum regnumof%7 | |
1390 | ; EVEX allows imm8 shift instructions to be used with memory operands, | |
1391 | ; but VEX does not. This handles those special cases. | |
1392 | %ifnnum %8 | |
1393 | %assign __emulate_avx 1 | |
1394 | %elif notcpuflag(avx512) | |
1395 | %assign __emulate_avx 1 | |
1396 | %endif | |
1397 | %endif | |
1398 | %if __emulate_avx ; a separate load is required | |
1399 | %if %3 | |
1400 | vmovaps %6, %7 | |
1401 | %else | |
1402 | vmovdqa %6, %7 | |
1403 | %endif | |
1404 | __instr %6, %6, %8 | |
1405 | %else | |
1406 | __instr %6, __src1, __src2 | |
1407 | %endif | |
1356 | 1408 | %else |
1357 | 1409 | __instr %6, %7, %8 |
1358 | 1410 | %endif |
1359 | 1411 | %elif %0 == 7 |
1360 | %if avx_enabled && %5 | |
1412 | %if avx_enabled && __sizeofreg >= 16 && %5 | |
1361 | 1413 | %xdefine __src1 %6 |
1362 | 1414 | %xdefine __src2 %7 |
1363 | 1415 | %ifnum regnumof%6 |
1418 | 1470 | AVX_INSTR andps, sse, 1, 0, 1 |
1419 | 1471 | AVX_INSTR blendpd, sse4, 1, 1, 0 |
1420 | 1472 | AVX_INSTR blendps, sse4, 1, 1, 0 |
1421 | AVX_INSTR blendvpd, sse4 ; can't be emulated | |
1422 | AVX_INSTR blendvps, sse4 ; can't be emulated | |
1473 | AVX_INSTR blendvpd, sse4, 1, 1, 0 ; last operand must be xmm0 with legacy encoding | |
1474 | AVX_INSTR blendvps, sse4, 1, 1, 0 ; last operand must be xmm0 with legacy encoding | |
1423 | 1475 | AVX_INSTR cmpeqpd, sse2, 1, 0, 1 |
1424 | 1476 | AVX_INSTR cmpeqps, sse, 1, 0, 1 |
1425 | 1477 | AVX_INSTR cmpeqsd, sse2, 1, 0, 0 |
1552 | 1604 | AVX_INSTR pandn, mmx, 0, 0, 0 |
1553 | 1605 | AVX_INSTR pavgb, mmx2, 0, 0, 1 |
1554 | 1606 | AVX_INSTR pavgw, mmx2, 0, 0, 1 |
1555 | AVX_INSTR pblendvb, sse4 ; can't be emulated | |
1607 | AVX_INSTR pblendvb, sse4, 0, 1, 0 ; last operand must be xmm0 with legacy encoding | |
1556 | 1608 | AVX_INSTR pblendw, sse4, 0, 1, 0 |
1557 | 1609 | AVX_INSTR pclmulqdq, fnord, 0, 1, 0 |
1558 | 1610 | AVX_INSTR pclmulhqhqdq, fnord, 0, 0, 0 |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* x86util.asm: x86 utility macros |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2008-2021 x264 project | |
3 | ;* Copyright (C) 2008-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Holger Lubitz <holger@lubitz.org> |
6 | 6 | ;* Loren Merritt <lorenm@u.washington.edu> |
920 | 920 | fi |
921 | 921 | fi |
922 | 922 | |
923 | if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" -o $ARCH = "PARISC" -o $ARCH = "MIPS" -o $ARCH = "AARCH64" \) ] ; then | |
923 | if [ $shared = yes ] ; then | |
924 | 924 | pic="yes" |
925 | 925 | fi |
926 | 926 | |
1298 | 1298 | avs="no" |
1299 | 1299 | # cygwin can use avisynth if it can use LoadLibrary |
1300 | 1300 | if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then |
1301 | avs="avisynth" | |
1301 | avs="yes" | |
1302 | 1302 | define HAVE_AVS |
1303 | define USE_AVXSYNTH 0 | |
1304 | 1303 | elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then |
1305 | # AvxSynth currently only supports Linux and OSX | |
1306 | avs="avxsynth" | |
1304 | avs="yes" | |
1307 | 1305 | define HAVE_AVS |
1308 | define USE_AVXSYNTH 1 | |
1309 | 1306 | AVS_LIBS="-ldl" |
1310 | 1307 | LDFLAGSCLI="$AVS_LIBS $LDFLAGSCLI" |
1308 | elif [ "$SYS" = "FREEBSD" -o "$SYS" = "OPENBSD" -o "$SYS" = "NETBSD" -o "$SYS" = "HAIKU" ] ; then | |
1309 | avs="yes" | |
1310 | define HAVE_AVS | |
1311 | # dlopen is exported from libc on both *BSD and Haiku | |
1311 | 1312 | fi |
1312 | 1313 | fi |
1313 | 1314 |
32 | 32 | * 16% reset cabac contexts |
33 | 33 | * 6% deblocking between slices (you don't strictly have to turn this off just for standard compliance, but you do if you want to use slices for decoder multithreading) |
34 | 34 | * 2% cabac neighbors (cbp, skip, etc) |
35 | The proportional cost of redundant headers should certainly depend on bitrate (since the header size is constant and everything else depends on bitrate). Deblocking should too (due to varing deblock strength). | |
35 | The proportional cost of redundant headers should certainly depend on bitrate (since the header size is constant and everything else depends on bitrate). Deblocking should too (due to varying deblock strength). | |
36 | 36 | But none of the proportions should depend strongly on the number of slices: some are triggered per slice while some are triggered per macroblock-that's-on-the-edge-of-a-slice, but as long as there's no more than 1 slice per row, the relative frequency of those two conditions is determined solely by the image width. |
37 | 37 | |
38 | 38 |
0 | 0 | /***************************************************************************** |
1 | 1 | * analyse.c: macroblock analysis |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
1345 | 1345 | i_maxref = ref;\ |
1346 | 1346 | } |
1347 | 1347 | |
1348 | /* early termination: if 16x16 chose ref 0, then evalute no refs older | |
1348 | /* early termination: if 16x16 chose ref 0, then evaluate no refs older | |
1349 | 1349 | * than those used by the neighbors */ |
1350 | 1350 | if( a->b_early_terminate && (i_maxref > 0 && (a->l0.me16x16.i_ref == 0 || a->l0.me16x16.i_ref == h->mb.ref_blind_dupe) && |
1351 | 1351 | h->mb.i_mb_type_top > 0 && h->mb.i_mb_type_left[0] > 0) ) |
2172 | 2172 | ALIGNED_ARRAY_16( pixel, pix,[2],[8*8] ); |
2173 | 2173 | int i_maxref[2] = {h->mb.pic.i_fref[0]-1, h->mb.pic.i_fref[1]-1}; |
2174 | 2174 | |
2175 | /* early termination: if 16x16 chose ref 0, then evalute no refs older | |
2175 | /* early termination: if 16x16 chose ref 0, then evaluate no refs older | |
2176 | 2176 | * than those used by the neighbors */ |
2177 | 2177 | #define CHECK_NEIGHBOUR(i)\ |
2178 | 2178 | {\ |
0 | 0 | /***************************************************************************** |
1 | 1 | * analyse.h: macroblock analysis |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * api.c: bit depth independent interface |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Vittorio Giovara <vittorio.giovara@gmail.com> |
6 | 6 | * Luca Barbato <lu_zero@gentoo.org> |
0 | 0 | /***************************************************************************** |
1 | 1 | * cabac.c: cabac bitstream writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * cavlc.c: cavlc bitstream writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * encoder.c: top-level encoder functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
205 | 205 | sh->i_disable_deblocking_filter_idc = param->b_sliced_threads ? 2 : 0; |
206 | 206 | else |
207 | 207 | sh->i_disable_deblocking_filter_idc = 1; |
208 | sh->i_alpha_c0_offset = param->i_deblocking_filter_alphac0 << 1; | |
209 | sh->i_beta_offset = param->i_deblocking_filter_beta << 1; | |
208 | sh->i_alpha_c0_offset = param->i_deblocking_filter_alphac0 * 2; | |
209 | sh->i_beta_offset = param->i_deblocking_filter_beta * 2; | |
210 | 210 | } |
211 | 211 | |
212 | 212 | static void slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal_ref_idc ) |
410 | 410 | filler += 32; // add padding for safety |
411 | 411 | return bitstream_check_buffer_internal( h, filler, 0, -1 ); |
412 | 412 | } |
413 | ||
414 | #if HAVE_THREAD | |
415 | static void encoder_thread_init( x264_t *h ) | |
416 | { | |
417 | if( h->param.i_sync_lookahead ) | |
418 | x264_lower_thread_priority( 10 ); | |
419 | } | |
420 | #endif | |
421 | 413 | |
422 | 414 | /**************************************************************************** |
423 | 415 | * |
716 | 708 | return -1; |
717 | 709 | } |
718 | 710 | |
719 | int type = h->param.i_avcintra_class == 200 ? 2 : | |
711 | int type = h->param.i_avcintra_class == 480 ? 4 : | |
712 | h->param.i_avcintra_class == 300 ? 3 : | |
713 | h->param.i_avcintra_class == 200 ? 2 : | |
720 | 714 | h->param.i_avcintra_class == 100 ? 1 : |
721 | 715 | h->param.i_avcintra_class == 50 ? 0 : -1; |
722 | 716 | if( type < 0 ) |
724 | 718 | x264_log( h, X264_LOG_ERROR, "Invalid AVC-Intra class\n" ); |
725 | 719 | return -1; |
726 | 720 | } |
727 | ||
728 | /* [50/100/200][res][fps] */ | |
721 | else if( type > 2 && h->param.i_avcintra_flavor != X264_AVCINTRA_FLAVOR_SONY ) | |
722 | { | |
723 | x264_log( h, X264_LOG_ERROR, "AVC-Intra %d only supported by Sony XAVC flavor\n", h->param.i_avcintra_class ); | |
724 | return -1; | |
725 | } | |
726 | ||
727 | /* [50/100/200/300/480][res][fps] */ | |
729 | 728 | static const struct |
730 | 729 | { |
731 | 730 | uint16_t fps_num; |
732 | 731 | uint16_t fps_den; |
733 | 732 | uint8_t interlaced; |
734 | 733 | uint16_t frame_size; |
734 | const uint8_t *cqm_4iy; | |
735 | 735 | const uint8_t *cqm_4ic; |
736 | 736 | const uint8_t *cqm_8iy; |
737 | } avcintra_lut[3][2][7] = | |
738 | { | |
739 | {{{ 60000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
740 | { 50, 1, 0, 1100, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
741 | { 30000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
742 | { 25, 1, 0, 1100, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
743 | { 24000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}, | |
744 | {{ 30000, 1001, 1, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, | |
745 | { 25, 1, 1, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, | |
746 | { 60000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
747 | { 30000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
748 | { 50, 1, 0, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
749 | { 25, 1, 0, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
750 | { 24000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}}, | |
751 | {{{ 60000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
752 | { 50, 1, 0, 2224, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
753 | { 30000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
754 | { 25, 1, 0, 2224, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
755 | { 24000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, | |
756 | {{ 30000, 1001, 1, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
757 | { 25, 1, 1, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
758 | { 60000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
759 | { 30000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
760 | { 50, 1, 0, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
761 | { 25, 1, 0, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
762 | { 24000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, | |
763 | {{{ 60000, 1001, 0, 3724, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
764 | { 50, 1, 0, 4472, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, | |
765 | {{ 30000, 1001, 1, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
766 | { 25, 1, 1, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
767 | { 60000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
768 | { 30000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
769 | { 50, 1, 0, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
770 | { 25, 1, 0, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
771 | { 24000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}} | |
737 | } avcintra_lut[5][2][7] = | |
738 | { | |
739 | {{{ 60000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
740 | { 50, 1, 0, 1100, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
741 | { 30000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
742 | { 25, 1, 0, 1100, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
743 | { 24000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}, | |
744 | {{ 30000, 1001, 1, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, | |
745 | { 25, 1, 1, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, | |
746 | { 60000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
747 | { 30000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
748 | { 50, 1, 0, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
749 | { 25, 1, 0, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, | |
750 | { 24000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}}, | |
751 | {{{ 60000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
752 | { 50, 1, 0, 2224, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
753 | { 30000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
754 | { 25, 1, 0, 2224, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
755 | { 24000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, | |
756 | {{ 30000, 1001, 1, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
757 | { 25, 1, 1, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
758 | { 60000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
759 | { 30000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
760 | { 50, 1, 0, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
761 | { 25, 1, 0, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
762 | { 24000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, | |
763 | {{{ 60000, 1001, 0, 3724, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, | |
764 | { 50, 1, 0, 4472, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, | |
765 | {{ 30000, 1001, 1, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
766 | { 25, 1, 1, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, | |
767 | { 60000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
768 | { 30000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
769 | { 50, 1, 0, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
770 | { 25, 1, 0, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, | |
771 | { 24000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, | |
772 | {{{ 60000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
773 | { 50, 1, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
774 | { 30000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
775 | { 25, 1, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
776 | { 24000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }}}, | |
777 | {{{ 60000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
778 | { 50, 1, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
779 | { 30000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
780 | { 25, 1, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, | |
781 | { 24000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }}} | |
772 | 782 | }; |
773 | 783 | |
774 | 784 | int res = -1; |
775 | 785 | if( i_csp >= X264_CSP_I420 && i_csp < X264_CSP_I422 && !type ) |
776 | 786 | { |
777 | if( h->param.i_width == 1440 && h->param.i_height == 1080 ) res = 1; | |
778 | else if( h->param.i_width == 960 && h->param.i_height == 720 ) res = 0; | |
787 | if( h->param.i_width == 1440 && h->param.i_height == 1080 ) res = 1; | |
788 | else if( h->param.i_width == 960 && h->param.i_height == 720 ) res = 0; | |
779 | 789 | } |
780 | 790 | else if( i_csp >= X264_CSP_I422 && i_csp < X264_CSP_I444 && type ) |
781 | 791 | { |
782 | if( h->param.i_width == 1920 && h->param.i_height == 1080 ) res = 1; | |
783 | else if( h->param.i_width == 1280 && h->param.i_height == 720 ) res = 0; | |
792 | if( type < 3 ) | |
793 | { | |
794 | if( h->param.i_width == 1920 && h->param.i_height == 1080 ) res = 1; | |
795 | else if( h->param.i_width == 2048 && h->param.i_height == 1080 ) res = 1; | |
796 | else if( h->param.i_width == 1280 && h->param.i_height == 720 ) res = 0; | |
797 | } | |
798 | else | |
799 | { | |
800 | if( h->param.i_width == 3840 && h->param.i_height == 2160 ) res = 0; | |
801 | else if( h->param.i_width == 4096 && h->param.i_height == 2160 ) res = 0; | |
802 | } | |
784 | 803 | } |
785 | 804 | else |
786 | 805 | { |
821 | 840 | } |
822 | 841 | if( i == 7 ) |
823 | 842 | { |
824 | x264_log( h, X264_LOG_ERROR, "FPS %d/%d%c not compatible with AVC-Intra\n", | |
825 | h->param.i_fps_num, h->param.i_fps_den, PARAM_INTERLACED ? 'i' : 'p' ); | |
843 | x264_log( h, X264_LOG_ERROR, "FPS %d/%d%c not compatible with AVC-Intra %d\n", | |
844 | h->param.i_fps_num, h->param.i_fps_den, PARAM_INTERLACED ? 'i' : 'p', h->param.i_avcintra_class ); | |
826 | 845 | return -1; |
827 | 846 | } |
828 | 847 | |
842 | 861 | h->param.b_pic_struct = 0; |
843 | 862 | h->param.analyse.b_transform_8x8 = 1; |
844 | 863 | h->param.analyse.intra = X264_ANALYSE_I8x8; |
845 | h->param.analyse.i_chroma_qp_offset = res && type ? 3 : 4; | |
864 | h->param.analyse.i_chroma_qp_offset = type > 2 ? -4 : res && type ? 3 : 4; | |
846 | 865 | h->param.b_cabac = !type; |
847 | 866 | h->param.rc.i_vbv_buffer_size = avcintra_lut[type][res][i].frame_size; |
848 | 867 | h->param.rc.i_vbv_max_bitrate = |
851 | 870 | h->param.rc.f_vbv_buffer_init = 1.0; |
852 | 871 | h->param.rc.b_filler = 1; |
853 | 872 | h->param.i_cqm_preset = X264_CQM_CUSTOM; |
854 | memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof(h->param.cqm_4iy) ); | |
873 | memcpy( h->param.cqm_4iy, avcintra_lut[type][res][i].cqm_4iy, sizeof(h->param.cqm_4iy) ); | |
855 | 874 | memcpy( h->param.cqm_4ic, avcintra_lut[type][res][i].cqm_4ic, sizeof(h->param.cqm_4ic) ); |
856 | 875 | memcpy( h->param.cqm_8iy, avcintra_lut[type][res][i].cqm_8iy, sizeof(h->param.cqm_8iy) ); |
857 | 876 | |
1544 | 1563 | h->i_frame_num = 0; |
1545 | 1564 | |
1546 | 1565 | if( h->param.i_avcintra_class ) |
1547 | h->i_idr_pic_id = 5; | |
1566 | h->i_idr_pic_id = h->param.i_avcintra_class > 200 ? 4 : 5; | |
1548 | 1567 | else |
1549 | 1568 | h->i_idr_pic_id = 0; |
1550 | 1569 | |
1715 | 1734 | CHECKED_MALLOC( h->reconfig_h, sizeof(x264_t) ); |
1716 | 1735 | |
1717 | 1736 | if( h->param.i_threads > 1 && |
1718 | x264_threadpool_init( &h->threadpool, h->param.i_threads, (void*)encoder_thread_init, h ) ) | |
1737 | x264_threadpool_init( &h->threadpool, h->param.i_threads ) ) | |
1719 | 1738 | goto fail; |
1720 | 1739 | if( h->param.i_lookahead_threads > 1 && |
1721 | x264_threadpool_init( &h->lookaheadpool, h->param.i_lookahead_threads, NULL, NULL ) ) | |
1740 | x264_threadpool_init( &h->lookaheadpool, h->param.i_lookahead_threads ) ) | |
1722 | 1741 | goto fail; |
1723 | 1742 | |
1724 | 1743 | #if HAVE_OPENCL |
3664 | 3683 | int total_len = 256; |
3665 | 3684 | /* Sony XAVC uses an oversized PPS instead of SEI padding */ |
3666 | 3685 | if( h->param.i_avcintra_flavor == X264_AVCINTRA_FLAVOR_SONY ) |
3667 | total_len += h->param.i_height == 1080 ? 18*512 : 10*512; | |
3686 | total_len += h->param.i_height >= 1080 ? 18*512 : 10*512; | |
3668 | 3687 | h->out.nal[h->out.i_nal-1].i_padding = total_len - h->out.nal[h->out.i_nal-1].i_payload - NALU_OVERHEAD; |
3669 | 3688 | } |
3670 | 3689 | overhead += h->out.nal[h->out.i_nal-1].i_payload + h->out.nal[h->out.i_nal-1].i_padding + NALU_OVERHEAD; |
0 | 0 | /***************************************************************************** |
1 | 1 | * lookahead.c: high-level lookahead functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 Avail Media and x264 project | |
3 | * Copyright (C) 2010-2022 Avail Media and x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Michael Kazmier <mkazmier@availmedia.com> |
6 | 6 | * Alex Giladi <agiladi@availmedia.com> |
88 | 88 | |
89 | 89 | REALIGN_STACK static void *lookahead_thread( x264_t *h ) |
90 | 90 | { |
91 | while( !h->lookahead->b_exit_thread ) | |
91 | while( 1 ) | |
92 | 92 | { |
93 | 93 | x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex ); |
94 | if( h->lookahead->b_exit_thread ) | |
95 | { | |
96 | x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex ); | |
97 | break; | |
98 | } | |
94 | 99 | x264_pthread_mutex_lock( &h->lookahead->next.mutex ); |
95 | 100 | int shift = X264_MIN( h->lookahead->next.i_max_size - h->lookahead->next.i_size, h->lookahead->ifbuf.i_size ); |
96 | 101 | lookahead_shift( &h->lookahead->next, &h->lookahead->ifbuf, shift ); |
0 | 0 | /***************************************************************************** |
1 | 1 | * macroblock.c: macroblock encoding |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
1043 | 1043 | if( M32( mvp ) ) |
1044 | 1044 | h->mc.mc_chroma( h->mb.pic.p_fdec[1], h->mb.pic.p_fdec[2], FDEC_STRIDE, |
1045 | 1045 | h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1], |
1046 | mvp[0], mvp[1]<<chroma422, 8, chroma422?16:8 ); | |
1046 | mvp[0], mvp[1] * (1<<chroma422), 8, chroma422?16:8 ); | |
1047 | 1047 | else |
1048 | 1048 | h->mc.load_deinterleave_chroma_fdec( h->mb.pic.p_fdec[1], h->mb.pic.p_fref[0][0][4], |
1049 | 1049 | h->mb.pic.i_stride[1], chroma422?16:8 ); |
0 | 0 | /***************************************************************************** |
1 | 1 | * macroblock.h: macroblock encoding |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * me.c: motion estimation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
57 | 57 | static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel ); |
58 | 58 | |
59 | 59 | #define BITS_MVD( mx, my )\ |
60 | (p_cost_mvx[(mx)<<2] + p_cost_mvy[(my)<<2]) | |
60 | (p_cost_mvx[(mx)*4] + p_cost_mvy[(my)*4]) | |
61 | 61 | |
62 | 62 | #define COST_MV( mx, my )\ |
63 | 63 | do\ |
131 | 131 | p_fref_w + (m1x) + (m1y)*stride,\ |
132 | 132 | p_fref_w + (m2x) + (m2y)*stride,\ |
133 | 133 | stride, costs );\ |
134 | costs[0] += p_cost_mvx[(m0x)<<2]; /* no cost_mvy */\ | |
135 | costs[1] += p_cost_mvx[(m1x)<<2];\ | |
136 | costs[2] += p_cost_mvx[(m2x)<<2];\ | |
134 | costs[0] += p_cost_mvx[(m0x)*4]; /* no cost_mvy */\ | |
135 | costs[1] += p_cost_mvx[(m1x)*4];\ | |
136 | costs[2] += p_cost_mvx[(m2x)*4];\ | |
137 | 137 | COPY3_IF_LT( bcost, costs[0], bmx, m0x, bmy, m0y );\ |
138 | 138 | COPY3_IF_LT( bcost, costs[1], bmx, m1x, bmy, m1y );\ |
139 | 139 | COPY3_IF_LT( bcost, costs[2], bmx, m2x, bmy, m2y );\ |
175 | 175 | } |
176 | 176 | |
177 | 177 | #define FPEL(mv) (((mv)+2)>>2) /* Convert subpel MV to fullpel with rounding... */ |
178 | #define SPEL(mv) ((mv)<<2) /* ... and the reverse. */ | |
178 | #define SPEL(mv) ((mv)*4) /* ... and the reverse. */ | |
179 | 179 | #define SPELx2(mv) (SPEL(mv)&0xFFFCFFFC) /* for two packed MVs */ |
180 | 180 | |
181 | 181 | void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_halfpel_thresh ) |
200 | 200 | int mv_x_max = h->mb.mv_limit_fpel[1][0]; |
201 | 201 | int mv_y_max = h->mb.mv_limit_fpel[1][1]; |
202 | 202 | /* Special version of pack to allow shortcuts in CHECK_MVRANGE */ |
203 | #define pack16to32_mask2(mx,my) ((mx<<16)|(my&0x7FFF)) | |
203 | #define pack16to32_mask2(mx,my) (((uint32_t)(mx)<<16)|((uint32_t)(my)&0x7FFF)) | |
204 | 204 | uint32_t mv_min = pack16to32_mask2( -mv_x_min, -mv_y_min ); |
205 | 205 | uint32_t mv_max = pack16to32_mask2( mv_x_max, mv_y_max )|0x8000; |
206 | 206 | uint32_t pmv, bpred_mv = 0; |
332 | 332 | COPY1_IF_LT( bcost, (costs[3]<<4)+12 ); |
333 | 333 | if( !(bcost&15) ) |
334 | 334 | break; |
335 | bmx -= (bcost<<28)>>30; | |
336 | bmy -= (bcost<<30)>>30; | |
335 | bmx -= (int32_t)((uint32_t)bcost<<28)>>30; | |
336 | bmy -= (int32_t)((uint32_t)bcost<<30)>>30; | |
337 | 337 | bcost &= ~15; |
338 | 338 | } while( --i && CHECK_MVRANGE(bmx, bmy) ); |
339 | 339 | bcost >>= 4; |
605 | 605 | if( dir ) |
606 | 606 | { |
607 | 607 | bmx = omx + i*(dir>>4); |
608 | bmy = omy + i*((dir<<28)>>28); | |
608 | bmy = omy + i*((int32_t)((uint32_t)dir<<28)>>28); | |
609 | 609 | } |
610 | 610 | } |
611 | 611 | } while( ++i <= i_me_range>>2 ); |
660 | 660 | for( int my = min_y; my <= max_y; my++ ) |
661 | 661 | { |
662 | 662 | int i; |
663 | int ycost = p_cost_mvy[my<<2]; | |
663 | int ycost = p_cost_mvy[my*4]; | |
664 | 664 | if( bsad <= ycost ) |
665 | 665 | continue; |
666 | 666 | bsad -= ycost; |
752 | 752 | for( int my = min_y; my <= max_y; my++ ) |
753 | 753 | { |
754 | 754 | int i; |
755 | int ycost = p_cost_mvy[my<<2]; | |
755 | int ycost = p_cost_mvy[my*4]; | |
756 | 756 | if( bcost <= ycost ) |
757 | 757 | continue; |
758 | 758 | bcost -= ycost; |
775 | 775 | uint32_t bmv_spel = SPELx2(bmv); |
776 | 776 | if( h->mb.i_subpel_refine < 3 ) |
777 | 777 | { |
778 | m->cost_mv = p_cost_mvx[bmx<<2] + p_cost_mvy[bmy<<2]; | |
778 | m->cost_mv = p_cost_mvx[bmx*4] + p_cost_mvy[bmy*4]; | |
779 | 779 | m->cost = bcost; |
780 | 780 | /* compute the real cost */ |
781 | 781 | if( bmv == pmv ) m->cost += m->cost_mv; |
914 | 914 | COPY1_IF_LT( bcost, (costs[3]<<6)+48 ); |
915 | 915 | if( !(bcost&63) ) |
916 | 916 | break; |
917 | bmx -= (bcost<<26)>>29; | |
918 | bmy -= (bcost<<29)>>29; | |
917 | bmx -= (int32_t)((uint32_t)bcost<<26)>>29; | |
918 | bmy -= (int32_t)((uint32_t)bcost<<29)>>29; | |
919 | 919 | bcost &= ~63; |
920 | 920 | } |
921 | 921 | bcost >>= 6; |
979 | 979 | COPY1_IF_LT( bcost, (costs[1]<<4)+3 ); |
980 | 980 | COPY1_IF_LT( bcost, (costs[2]<<4)+4 ); |
981 | 981 | COPY1_IF_LT( bcost, (costs[3]<<4)+12 ); |
982 | bmx -= (bcost<<28)>>30; | |
983 | bmy -= (bcost<<30)>>30; | |
982 | bmx -= (int32_t)((uint32_t)bcost<<28)>>30; | |
983 | bmy -= (int32_t)((uint32_t)bcost<<30)>>30; | |
984 | 984 | bcost >>= 4; |
985 | 985 | } |
986 | 986 |
0 | 0 | /***************************************************************************** |
1 | 1 | * me.h: motion estimation |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * ratecontrol.c: ratecontrol |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Michael Niedermayer <michaelni@gmx.at> |
607 | 607 | COPY2_IF_GT( max, refcount[i], bestref, i ); |
608 | 608 | |
609 | 609 | /* FIXME: If there are duplicates from frames other than ref0 then it is possible |
610 | * that the optimal ordering doesnt place every duplicate. */ | |
610 | * that the optimal ordering doesn't place every duplicate. */ | |
611 | 611 | |
612 | 612 | refcount[bestref] = -1; |
613 | 613 | h->fref[0][ref] = frames[bestref]; |
1660 | 1660 | float b1 = bits_so_far + predict_row_size_to_end( h, y, rc->qpm ) + size_of_other_slices; |
1661 | 1661 | float trust_coeff = x264_clip3f( bits_so_far / slice_size_planned, 0.0, 1.0 ); |
1662 | 1662 | |
1663 | /* Don't increase the row QPs until a sufficent amount of the bits of the frame have been processed, in case a flat */ | |
1663 | /* Don't increase the row QPs until a sufficient amount of the bits of the frame have been processed, in case a flat */ | |
1664 | 1664 | /* area at the top of the frame was measured inaccurately. */ |
1665 | 1665 | if( trust_coeff < 0.05f ) |
1666 | 1666 | qp_max = qp_absolute_max = prev_row_qp; |
0 | 0 | /***************************************************************************** |
1 | 1 | * ratecontrol.h: ratecontrol |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
0 | 0 | /***************************************************************************** |
1 | 1 | * rdo.c: rate-distortion optimization |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Fiona Glaser <fiona@x264.com> |
140 | 140 | int dc = h->pixf.sad[size]( fdec, FDEC_STRIDE, (pixel*)x264_zero, 0 ) >> 1; |
141 | 141 | satd = abs(h->pixf.satd[size]( fdec, FDEC_STRIDE, (pixel*)x264_zero, 0 ) - dc - cached_satd( h, size, x, y )); |
142 | 142 | } |
143 | satd = (satd * h->mb.i_psy_rd * h->mb.i_psy_rd_lambda + 128) >> 8; | |
143 | int64_t tmp = ((int64_t)satd * h->mb.i_psy_rd * h->mb.i_psy_rd_lambda + 128) >> 8; | |
144 | satd = X264_MIN( tmp, COST_MAX ); | |
144 | 145 | } |
145 | 146 | return h->pixf.ssd[size](fenc, FENC_STRIDE, fdec, FDEC_STRIDE) + satd; |
146 | 147 | } |
469 | 470 | |
470 | 471 | /* Optimize rounding for DC coefficients in DC-only luma 4x4/8x8 blocks. */ |
471 | 472 | int d = sign_coef - ((SIGN(unquant_abs_level, sign_coef) + 8)&~15); |
472 | uint64_t score = (uint64_t)d*d * coef_weight; | |
473 | uint64_t score = (int64_t)d*d * coef_weight; | |
473 | 474 | |
474 | 475 | /* code the proposed level, and count how much entropy it would take */ |
475 | 476 | if( abs_level ) |
732 | 733 | trellis_level_t level_tree[64*8*2]; |
733 | 734 | int levels_used = 1; |
734 | 735 | /* init trellis */ |
735 | trellis_node_t nodes[2][8]; | |
736 | trellis_node_t nodes[2][8] = {0}; | |
736 | 737 | trellis_node_t *nodes_cur = nodes[0]; |
737 | 738 | trellis_node_t *nodes_prev = nodes[1]; |
738 | 739 | trellis_node_t *bnode; |
739 | for( int j = 1; j < 4; j++ ) | |
740 | for( int j = 1; j < 8; j++ ) | |
740 | 741 | nodes_cur[j].score = TRELLIS_SCORE_MAX; |
741 | 742 | nodes_cur[0].score = TRELLIS_SCORE_BIAS; |
742 | 743 | nodes_cur[0].level_idx = 0; |
766 | 767 | if( !quant_coefs[i] )\ |
767 | 768 | {\ |
768 | 769 | /* no need to calculate ssd of 0s: it's the same in all nodes.\ |
769 | * no need to modify level_tree for ctx=0: it starts with an infinite loop of 0s. | |
770 | * no need to modify level_tree for ctx=0: it starts with an infinite loop of 0s.\ | |
770 | 771 | * subtracting from one score is equivalent to adding to the rest. */\ |
771 | 772 | if( !ctx_hi )\ |
772 | 773 | {\ |
823 | 824 | int predicted_coef = orig_coef - sign_coef;\ |
824 | 825 | int psy_value = abs(unquant_abs_level + SIGN(predicted_coef, sign_coef));\ |
825 | 826 | int psy_weight = coef_weight1[zigzag[i]] * h->mb.i_psy_trellis;\ |
826 | ssd1[k] = (uint64_t)d*d * coef_weight2[zigzag[i]] - psy_weight * psy_value;\ | |
827 | int64_t tmp = (int64_t)d*d * coef_weight2[zigzag[i]] - (int64_t)psy_weight * psy_value;\ | |
828 | ssd1[k] = (uint64_t)tmp;\ | |
827 | 829 | }\ |
828 | 830 | else\ |
829 | 831 | /* FIXME: for i16x16 dc is this weight optimal? */\ |
830 | ssd1[k] = (uint64_t)d*d * (dc?256:coef_weight2[zigzag[i]]);\ | |
832 | ssd1[k] = (int64_t)d*d * (dc?256:coef_weight2[zigzag[i]]);\ | |
831 | 833 | ssd0[k] = ssd1[k];\ |
832 | 834 | if( !i && !dc && !ctx_hi )\ |
833 | 835 | {\ |
834 | 836 | /* Optimize rounding for DC coefficients in DC-only luma 4x4/8x8 blocks. */\ |
835 | 837 | d = sign_coef - ((SIGN(unquant_abs_level, sign_coef) + 8)&~15);\ |
836 | ssd0[k] = (uint64_t)d*d * coef_weight2[zigzag[i]];\ | |
838 | ssd0[k] = (int64_t)d*d * coef_weight2[zigzag[i]];\ | |
837 | 839 | }\ |
838 | 840 | }\ |
839 | 841 | \ |
924 | 926 | ALIGNED_ARRAY_16( dctcoef, coefs,[16] ); |
925 | 927 | const uint32_t *coef_weight1 = b_8x8 ? x264_dct8_weight_tab : x264_dct4_weight_tab; |
926 | 928 | const uint32_t *coef_weight2 = b_8x8 ? x264_dct8_weight2_tab : x264_dct4_weight2_tab; |
927 | int delta_distortion[16]; | |
929 | int64_t delta_distortion[16]; | |
928 | 930 | int64_t score = 1ULL<<62; |
929 | 931 | int i, j; |
930 | 932 | const int f = 1<<15; |
951 | 953 | |
952 | 954 | /* Find last non-zero coefficient. */ |
953 | 955 | for( i = end; i >= start; i -= step ) |
954 | if( (unsigned)(dct[zigzag[i]] * (dc?quant_mf[0]>>1:quant_mf[zigzag[i]]) + f-1) >= 2*f ) | |
956 | if( abs(dct[zigzag[i]]) * (dc?quant_mf[0]>>1:quant_mf[zigzag[i]]) >= f ) | |
955 | 957 | break; |
956 | 958 | |
957 | 959 | if( i < start ) |
984 | 986 | int unquant0 = (((dc?unquant_mf[0]<<1:unquant_mf[zigzag[j]]) * (nearest_quant-1) + 128) >> 8); |
985 | 987 | int d1 = abs_coef - unquant1; |
986 | 988 | int d0 = abs_coef - unquant0; |
987 | delta_distortion[i] = (d0*d0 - d1*d1) * (dc?256:coef_weight2[zigzag[j]]); | |
989 | delta_distortion[i] = (int64_t)(d0*d0 - d1*d1) * (dc?256:coef_weight2[zigzag[j]]); | |
988 | 990 | |
989 | 991 | /* Psy trellis: bias in favor of higher AC coefficients in the reconstructed frame. */ |
990 | 992 | if( h->mb.i_psy_trellis && j && !dc && !b_chroma ) |
1022 | 1024 | while( 1 ) |
1023 | 1025 | { |
1024 | 1026 | int64_t iter_score = score; |
1025 | int iter_distortion_delta = 0; | |
1027 | int64_t iter_distortion_delta = 0; | |
1026 | 1028 | int iter_coef = -1; |
1027 | 1029 | int iter_mask = coef_mask; |
1028 | 1030 | int iter_round = round_mask; |
1037 | 1039 | int old_coef = coefs[i]; |
1038 | 1040 | int new_coef = quant_coefs[round_change][i]; |
1039 | 1041 | int cur_mask = (coef_mask&~(1 << i))|(!!new_coef << i); |
1040 | int cur_distortion_delta = delta_distortion[i] * (round_change ? -1 : 1); | |
1042 | int64_t cur_distortion_delta = delta_distortion[i] * (round_change ? -1 : 1); | |
1041 | 1043 | int64_t cur_score = cur_distortion_delta; |
1042 | 1044 | coefs[i] = new_coef; |
1043 | 1045 |
0 | 0 | /***************************************************************************** |
1 | 1 | * set: header writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
240 | 240 | sps->vui.i_log2_max_mv_length_vertical = (int)log2f( X264_MAX( 1, param->analyse.i_mv_range*4-1 ) ) + 1; |
241 | 241 | } |
242 | 242 | |
243 | sps->b_avcintra = !!param->i_avcintra_class; | |
243 | sps->b_avcintra_hd = param->i_avcintra_class && param->i_avcintra_class <= 200; | |
244 | sps->b_avcintra_4k = param->i_avcintra_class > 200; | |
244 | 245 | sps->i_cqm_preset = param->i_cqm_preset; |
245 | 246 | } |
246 | 247 | |
324 | 325 | bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_chroma_minus8 |
325 | 326 | bs_write1( s, sps->b_qpprime_y_zero_transform_bypass ); |
326 | 327 | /* Exactly match the AVC-Intra bitstream */ |
327 | bs_write1( s, sps->b_avcintra ); // seq_scaling_matrix_present_flag | |
328 | if( sps->b_avcintra ) | |
328 | bs_write1( s, sps->b_avcintra_hd ); // seq_scaling_matrix_present_flag | |
329 | if( sps->b_avcintra_hd ) | |
329 | 330 | { |
330 | 331 | scaling_list_write( s, sps, CQM_4IY ); |
331 | 332 | scaling_list_write( s, sps, CQM_4IC ); |
523 | 524 | bs_write1( s, pps->b_constrained_intra_pred ); |
524 | 525 | bs_write1( s, pps->b_redundant_pic_cnt ); |
525 | 526 | |
526 | int b_scaling_list = !sps->b_avcintra && sps->i_cqm_preset != X264_CQM_FLAT; | |
527 | int b_scaling_list = !sps->b_avcintra_hd && sps->i_cqm_preset != X264_CQM_FLAT; | |
527 | 528 | if( pps->b_transform_8x8_mode || b_scaling_list ) |
528 | 529 | { |
529 | 530 | bs_write1( s, pps->b_transform_8x8_mode ); |
532 | 533 | { |
533 | 534 | scaling_list_write( s, sps, CQM_4IY ); |
534 | 535 | scaling_list_write( s, sps, CQM_4IC ); |
535 | bs_write1( s, 0 ); // Cr = Cb | |
536 | scaling_list_write( s, sps, CQM_4PY ); | |
537 | scaling_list_write( s, sps, CQM_4PC ); | |
538 | bs_write1( s, 0 ); // Cr = Cb | |
536 | if( sps->b_avcintra_4k ) | |
537 | { | |
538 | scaling_list_write( s, sps, CQM_4IC ); | |
539 | bs_write1( s, 0 ); // no inter | |
540 | bs_write1( s, 0 ); // no inter | |
541 | bs_write1( s, 0 ); // no inter | |
542 | } | |
543 | else | |
544 | { | |
545 | bs_write1( s, 0 ); // Cr = Cb | |
546 | scaling_list_write( s, sps, CQM_4PY ); | |
547 | scaling_list_write( s, sps, CQM_4PC ); | |
548 | bs_write1( s, 0 ); // Cr = Cb | |
549 | } | |
539 | 550 | if( pps->b_transform_8x8_mode ) |
540 | 551 | { |
541 | 552 | scaling_list_write( s, sps, CQM_8IY+4 ); |
542 | scaling_list_write( s, sps, CQM_8PY+4 ); | |
553 | if( sps->b_avcintra_4k ) | |
554 | bs_write1( s, 0 ); // no inter | |
555 | else | |
556 | scaling_list_write( s, sps, CQM_8PY+4 ); | |
543 | 557 | if( sps->i_chroma_format_idc == CHROMA_444 ) |
544 | 558 | { |
545 | 559 | scaling_list_write( s, sps, CQM_8IC+4 ); |
593 | 607 | |
594 | 608 | memcpy( payload, uuid, 16 ); |
595 | 609 | sprintf( payload+16, "x264 - core %d%s - H.264/MPEG-4 AVC codec - " |
596 | "Copy%s 2003-2021 - http://www.videolan.org/x264.html - options: %s", | |
610 | "Copy%s 2003-2022 - http://www.videolan.org/x264.html - options: %s", | |
597 | 611 | X264_BUILD, X264_VERSION, HAVE_GPL?"left":"right", opts ); |
598 | 612 | length = strlen(payload)+1; |
599 | 613 | |
850 | 864 | return 0; |
851 | 865 | } |
852 | 866 | |
867 | #undef ERROR | |
853 | 868 | #define ERROR(...)\ |
854 | 869 | {\ |
855 | 870 | if( verbose )\ |
0 | 0 | /***************************************************************************** |
1 | 1 | * set.h: header writing |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * slicetype-cl.c: OpenCL slicetype decision code (lowres lookahead) |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2012-2021 x264 project | |
3 | * Copyright (C) 2012-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steve Borho <sborho@multicorewareinc.com> |
6 | 6 | * |
282 | 282 | return 0; |
283 | 283 | } |
284 | 284 | |
285 | /* This function was tested emprically on a number of AMD and NV GPUs. Making a | |
285 | /* This function was tested empirically on a number of AMD and NV GPUs. Making a | |
286 | 286 | * function which returns perfect launch dimensions is impossible; some |
287 | 287 | * applications will have self-tuning code to try many possible variables and |
288 | 288 | * measure the runtime. Here we simply make an educated guess based on what we |
0 | 0 | /***************************************************************************** |
1 | 1 | * slicetype-cl.h: OpenCL slicetype decision code (lowres lookahead) |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2017-2021 x264 project | |
3 | * Copyright (C) 2017-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * slicetype.c: lookahead analysis |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Fiona Glaser <fiona@x264.com> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * example.c: libx264 API usage example |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | // Avisynth C Interface Version 0.20 |
1 | 1 | // Copyright 2003 Kevin Atkinson |
2 | ||
3 | // Copyright 2020 AviSynth+ project | |
2 | 4 | |
3 | 5 | // This program is free software; you can redistribute it and/or modify |
4 | 6 | // it under the terms of the GNU General Public License as published by |
12 | 14 | // |
13 | 15 | // You should have received a copy of the GNU General Public License |
14 | 16 | // along with this program; if not, write to the Free Software |
15 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | |
17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
18 | // MA 02110-1301 USA, or visit | |
16 | 19 | // http://www.gnu.org/copyleft/gpl.html . |
17 | 20 | // |
18 | 21 | // As a special exception, I give you permission to link to the |
30 | 33 | // export plugins, or graphical user interfaces. |
31 | 34 | |
32 | 35 | // NOTE: this is a partial update of the Avisynth C interface to recognize |
33 | // new color spaces added in Avisynth 2.60. By no means is this document | |
34 | // completely Avisynth 2.60 compliant. | |
36 | // new color spaces and interface elements added in Avisynth 2.60 and AviSynth+. | |
37 | // This interface is not 100% Avisynth+ CPP interface equivalent. | |
38 | ||
39 | // 170103: added new CPU constants (FMA4, AVX512xx) | |
40 | // 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64. | |
41 | // 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access | |
42 | // 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access | |
43 | // 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init | |
44 | // 180524: avs_is_same_colorspace VideoInfo parameters to const | |
45 | // 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff | |
46 | // 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions | |
47 | // 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define) | |
48 | // 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN | |
49 | // 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference) | |
50 | // 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions: | |
51 | // if they are not loadable, they will work in a classic Avisynth compatible mode | |
52 | // Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead | |
53 | // Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel) | |
54 | // Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL | |
55 | // 202002xx non-Windows friendly additions | |
56 | // 20200305 avs_vsprintf parameter type change: (void *) to va_list | |
57 | // 20200330: (remove test SIZETMOD define for clarity) | |
58 | // 20200513: user must use explicite #define AVS26_FALLBACK_SIMULATION for having fallback helpers in dynamic loaded library section | |
59 | // 20200513: Follow AviSynth+ V8 interface additions | |
60 | // AVS_VideoFrame struct extended with placeholder for frame property pointer | |
61 | // avs_subframe_planar_a | |
62 | // avs_copy_frame_props | |
63 | // avs_get_frame_props_ro, avs_get_frame_props_rw | |
64 | // avs_prop_num_keys, avs_prop_get_key, avs_prop_num_elements, avs_prop_get_type, avs_prop_get_data_size | |
65 | // avs_prop_get_int, avs_prop_get_float, avs_prop_get_data, avs_prop_get_clip, avs_prop_get_frame, avs_prop_get_int_array, avs_prop_get_float_array | |
66 | // avs_prop_set_int, avs_prop_set_float, avs_prop_set_data, avs_prop_set_clip, avs_prop_set_frame, avs_prop_set_int_array, avs_prop_set_float_array | |
67 | // avs_prop_delete_key, avs_clear_map | |
68 | // avs_new_video_frame_p, avs_new_video_frame_p_a | |
69 | // avs_get_env_property (internal system properties), AVS_AEP_xxx (AvsEnvProperty) enums | |
70 | // avs_get_var_try, avs_get_var_bool, avs_get_var_int, avs_get_var_double, avs_get_var_string, avs_get_var_long | |
71 | // avs_pool_allocate, avs_pool_free | |
72 | ||
35 | 73 | |
36 | 74 | #ifndef __AVISYNTH_C__ |
37 | 75 | #define __AVISYNTH_C__ |
76 | ||
77 | #ifndef AVS_CONFIG_H | |
78 | #define AVS_CONFIG_H | |
79 | ||
80 | // Undefine this to get cdecl calling convention | |
81 | #define AVSC_USE_STDCALL 1 | |
82 | ||
83 | // NOTE TO PLUGIN AUTHORS: | |
84 | // Because AVS_FRAME_ALIGN can be substantially higher than the alignment | |
85 | // a plugin actually needs, plugins should not use AVS_FRAME_ALIGN to check for | |
86 | // alignment. They should always request the exact alignment value they need. | |
87 | // This is to make sure that plugins work over the widest range of AviSynth | |
88 | // builds possible. | |
89 | #define AVS_FRAME_ALIGN 64 | |
90 | ||
91 | #if defined(_M_AMD64) || defined(__x86_64) | |
92 | # define AVS_X86_64 | |
93 | #elif defined(_M_IX86) || defined(__i386__) | |
94 | # define AVS_X86_32 | |
95 | // VS2017 introduced _M_ARM64 | |
96 | #elif defined(_M_ARM64) || defined(__aarch64__) | |
97 | # define AVS_ARM64 | |
98 | #elif defined(_M_ARM) || defined(__arm__) | |
99 | # define AVS_ARM32 | |
100 | #elif defined(__PPC64__) | |
101 | # define AVS_PPC64 | |
102 | #elif defined(_M_PPC) || defined(__PPC__) || defined(__POWERPC__) | |
103 | # define AVS_PPC32 | |
104 | #elif defined(__riscv) | |
105 | # define AVS_RISCV | |
106 | #elif defined(__sparc_v9__) | |
107 | # define AVS_SPARC | |
108 | #endif | |
109 | ||
110 | // VC++ LLVM-Clang-cl MinGW-Gnu | |
111 | // AVS_MSVC x x | |
112 | // AVS_MSVC_PURE x | |
113 | // AVS_CLANG x | |
114 | // AVS_GCC x | |
115 | ||
116 | #if defined(__clang__) | |
117 | // Check clang first. clang-cl also defines __MSC_VER | |
118 | // We set AVS_MSVC because they are mostly compatible | |
119 | # define AVS_CLANG | |
120 | #if defined(_MSC_VER) | |
121 | # define AVS_MSVC | |
122 | #endif | |
123 | #elif defined(_MSC_VER) | |
124 | # define AVS_MSVC | |
125 | # define AVS_MSVC_PURE | |
126 | #elif defined(__GNUC__) | |
127 | # define AVS_GCC | |
128 | #endif | |
129 | ||
130 | #if defined(_WIN32) || defined(__CYGWIN__) | |
131 | # define AVS_WINDOWS | |
132 | #elif defined(__linux__) | |
133 | # define AVS_LINUX | |
134 | # define AVS_POSIX | |
135 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) | |
136 | # define AVS_BSD | |
137 | # define AVS_POSIX | |
138 | #elif defined(__APPLE__) | |
139 | # define AVS_MACOS | |
140 | # define AVS_POSIX | |
141 | #elif defined(__HAIKU__) | |
142 | # define AVS_HAIKU | |
143 | # define AVS_POSIX | |
144 | #endif | |
145 | ||
146 | #ifndef AVS_MSVC | |
147 | // GCC and Clang can be used on big endian systems, MSVC can't. | |
148 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | |
149 | # define AVS_ENDIANNESS "little" | |
150 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
151 | # define AVS_ENDIANNESS "big" | |
152 | # else | |
153 | # define AVS_ENDIANNESS "middle" | |
154 | # endif | |
155 | #else | |
156 | #define AVS_ENDIANNESS "little" | |
157 | #endif | |
158 | ||
159 | #endif //AVS_CONFIG_H | |
160 | ||
161 | #ifndef AVS_CAPI_H | |
162 | #define AVS_CAPI_H | |
163 | ||
164 | #ifdef AVS_POSIX | |
165 | // this is also defined in avs/posix.h | |
166 | #ifndef AVS_HAIKU | |
167 | #define __declspec(x) | |
168 | #endif | |
169 | #endif | |
38 | 170 | |
39 | 171 | #ifdef __cplusplus |
40 | 172 | # define EXTERN_C extern "C" |
42 | 174 | # define EXTERN_C |
43 | 175 | #endif |
44 | 176 | |
45 | #define AVSC_USE_STDCALL 1 | |
46 | ||
47 | #ifndef AVSC_USE_STDCALL | |
48 | # define AVSC_CC __cdecl | |
49 | #else | |
50 | # define AVSC_CC __stdcall | |
51 | #endif | |
177 | #ifdef AVS_WINDOWS | |
178 | #ifdef BUILDING_AVSCORE | |
179 | # if defined(AVS_GCC) && defined(AVS_X86_32) | |
180 | # define AVSC_CC | |
181 | # else // MSVC builds and 64-bit GCC | |
182 | # ifndef AVSC_USE_STDCALL | |
183 | # define AVSC_CC __cdecl | |
184 | # else | |
185 | # define AVSC_CC __stdcall | |
186 | # endif | |
187 | # endif | |
188 | #else // needed for programs that talk to AviSynth+ | |
189 | # ifndef AVSC_WIN32_GCC32 // see comment below | |
190 | # ifndef AVSC_USE_STDCALL | |
191 | # define AVSC_CC __cdecl | |
192 | # else | |
193 | # define AVSC_CC __stdcall | |
194 | # endif | |
195 | # else | |
196 | # define AVSC_CC | |
197 | # endif | |
198 | #endif | |
199 | # else | |
200 | # define AVSC_CC | |
201 | #endif | |
202 | ||
203 | // On 64-bit Windows, there's only one calling convention, | |
204 | // so there is no difference between MSVC and GCC. On 32-bit, | |
205 | // this isn't true. The convention that GCC needs to use to | |
206 | // even build AviSynth+ as 32-bit makes anything that uses | |
207 | // it incompatible with 32-bit MSVC builds of AviSynth+. | |
208 | // The AVSC_WIN32_GCC32 define is meant to provide a user | |
209 | // switchable way to make builds of FFmpeg to test 32-bit | |
210 | // GCC builds of AviSynth+ without having to screw around | |
211 | // with alternate headers, while still default to the usual | |
212 | // situation of using 32-bit MSVC builds of AviSynth+. | |
213 | ||
214 | // Hopefully, this situation will eventually be resolved | |
215 | // and a broadly compatible solution will arise so the | |
216 | // same 32-bit FFmpeg build can handle either MSVC or GCC | |
217 | // builds of AviSynth+. | |
52 | 218 | |
53 | 219 | #define AVSC_INLINE static __inline |
54 | 220 | |
55 | #ifdef AVISYNTH_C_EXPORTS | |
56 | # define AVSC_EXPORT __declspec(dllexport) | |
221 | #ifdef BUILDING_AVSCORE | |
222 | #ifdef AVS_WINDOWS | |
223 | # ifndef AVS_STATIC_LIB | |
224 | # define AVSC_EXPORT __declspec(dllexport) | |
225 | # else | |
226 | # define AVSC_EXPORT | |
227 | # endif | |
57 | 228 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name |
58 | 229 | #else |
59 | # define AVSC_EXPORT __declspec(dllimport) | |
230 | # define AVSC_EXPORT EXTERN_C | |
231 | # define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name | |
232 | #endif | |
233 | #else | |
234 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) | |
235 | # ifndef AVS_STATIC_LIB | |
236 | # define AVSC_IMPORT __declspec(dllimport) | |
237 | # else | |
238 | # define AVSC_IMPORT | |
239 | # endif | |
60 | 240 | # ifndef AVSC_NO_DECLSPEC |
61 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name | |
241 | # define AVSC_API(ret, name) EXTERN_C AVSC_IMPORT ret AVSC_CC name | |
62 | 242 | # else |
63 | 243 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) |
64 | 244 | # endif |
65 | 245 | #endif |
66 | 246 | |
67 | typedef unsigned char BYTE; | |
68 | #ifdef __GNUC__ | |
69 | typedef long long int INT64; | |
70 | #else | |
71 | typedef __int64 INT64; | |
72 | #endif | |
73 | ||
247 | #endif //AVS_CAPI_H | |
248 | ||
249 | #ifndef AVS_TYPES_H | |
250 | #define AVS_TYPES_H | |
251 | ||
252 | // Define all types necessary for interfacing with avisynth.dll | |
253 | #include <stdint.h> | |
254 | ||
255 | // Raster types used by VirtualDub & Avisynth | |
256 | typedef uint8_t BYTE; | |
257 | ||
258 | #endif //AVS_TYPES_H | |
74 | 259 | |
75 | 260 | ///////////////////////////////////////////////////////////////////// |
76 | 261 | // |
77 | 262 | // Constants |
78 | 263 | // |
79 | 264 | |
80 | #ifndef __AVISYNTH_6_H__ | |
81 | enum { AVISYNTH_INTERFACE_VERSION = 6 }; | |
265 | #ifndef __AVISYNTH_9_H__ | |
266 | enum { | |
267 | AVISYNTH_INTERFACE_CLASSIC_VERSION = 6, | |
268 | AVISYNTH_INTERFACE_VERSION = 9, | |
269 | AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps | |
270 | }; | |
82 | 271 | #endif |
83 | 272 | |
84 | 273 | enum {AVS_SAMPLE_INT8 = 1<<0, |
104 | 293 | AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED}; |
105 | 294 | |
106 | 295 | // Colorspace properties. |
107 | enum {AVS_CS_BGR = 1<<28, | |
108 | AVS_CS_YUV = 1<<29, | |
109 | AVS_CS_INTERLEAVED = 1<<30, | |
110 | AVS_CS_PLANAR = 1<<31, | |
111 | ||
112 | AVS_CS_SHIFT_SUB_WIDTH = 0, | |
113 | AVS_CS_SHIFT_SUB_HEIGHT = 8, | |
114 | AVS_CS_SHIFT_SAMPLE_BITS = 16, | |
115 | ||
116 | AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, | |
117 | AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 | |
118 | AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 | |
119 | AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 | |
120 | ||
121 | AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 | |
122 | AVS_CS_UPLANEFIRST = 1 << 4, // I420 | |
123 | ||
124 | AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, | |
125 | AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 | |
126 | AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 | |
127 | AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 | |
128 | ||
129 | AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, | |
130 | AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, | |
131 | AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS, | |
132 | AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS, | |
133 | ||
134 | AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK, | |
135 | AVS_CS_PLANAR_FILTER = ~( AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST )}; | |
136 | ||
137 | // Specific colorformats | |
296 | enum { | |
297 | AVS_CS_YUVA = 1 << 27, | |
298 | AVS_CS_BGR = 1 << 28, | |
299 | AVS_CS_YUV = 1 << 29, | |
300 | AVS_CS_INTERLEAVED = 1 << 30, | |
301 | AVS_CS_PLANAR = 1 << 31, | |
302 | ||
303 | AVS_CS_SHIFT_SUB_WIDTH = 0, | |
304 | AVS_CS_SHIFT_SUB_HEIGHT = 8, | |
305 | AVS_CS_SHIFT_SAMPLE_BITS = 16, | |
306 | ||
307 | AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, | |
308 | AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 | |
309 | AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 | |
310 | AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 | |
311 | ||
312 | AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 | |
313 | AVS_CS_UPLANEFIRST = 1 << 4, // I420 | |
314 | ||
315 | AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, | |
316 | AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 | |
317 | AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 | |
318 | AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 | |
319 | ||
320 | AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, | |
321 | AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, | |
322 | AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS, | |
323 | AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS, | |
324 | AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS, | |
325 | AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS, | |
326 | AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS, | |
327 | ||
328 | AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK, | |
329 | AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST), | |
330 | ||
331 | AVS_CS_RGB_TYPE = 1 << 0, | |
332 | AVS_CS_RGBA_TYPE = 1 << 1, | |
333 | ||
334 | AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0 planar | |
335 | AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2 planar | |
336 | AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // 4:4:4 planar | |
337 | AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0) | |
338 | AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB | |
339 | AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA | |
340 | AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0:A planar | |
341 | AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2:A planar | |
342 | AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1 }; // 4:4:4:A planar | |
343 | ||
344 | ||
345 | // Specific color formats | |
138 | 346 | enum { |
139 | 347 | AVS_CS_UNKNOWN = 0, |
140 | AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
141 | AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
348 | AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
349 | AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
142 | 350 | AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED, |
143 | 351 | // AVS_CS_YV12 = 1<<3 Reserved |
144 | 352 | // AVS_CS_I420 = 1<<4 Reserved |
145 | 353 | AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED, |
146 | 354 | |
147 | AVS_CS_YV24 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // YVU 4:4:4 planar | |
148 | AVS_CS_YV16 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:2 planar | |
149 | AVS_CS_YV12 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:0 planar | |
355 | AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YUV 4:4:4 planar | |
356 | AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:2 planar | |
357 | AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:0 planar | |
150 | 358 | AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar |
151 | 359 | AVS_CS_IYUV = AVS_CS_I420, |
152 | AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:1 planar | |
153 | AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:0 planar | |
154 | AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar | |
360 | AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YUV 4:1:1 planar | |
361 | AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YUV 4:1:0 planar | |
362 | AVS_CS_Y8 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar | |
363 | ||
364 | //------------------------- | |
365 | // AVS16: new planar constants go live! Experimental PF 160613 | |
366 | // 10-12-14-16 bit + planar RGB + BGR48/64 160725 | |
367 | AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples | |
368 | AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples | |
369 | AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples | |
370 | AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples | |
371 | ||
372 | AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples | |
373 | AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples | |
374 | AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples | |
375 | AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples | |
376 | ||
377 | AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples | |
378 | AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples | |
379 | AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples | |
380 | AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples | |
381 | ||
382 | AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples | |
383 | AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples | |
384 | AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples | |
385 | AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples | |
386 | ||
387 | // 32 bit samples (float) | |
388 | AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples | |
389 | AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples | |
390 | AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples | |
391 | AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples | |
392 | ||
393 | // RGB packed | |
394 | AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit | |
395 | AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit | |
396 | // no packed 32 bit (float) support for these legacy types | |
397 | ||
398 | // RGB planar | |
399 | AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples | |
400 | AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples | |
401 | AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples | |
402 | AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples | |
403 | AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples | |
404 | AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples | |
405 | ||
406 | // RGBA planar | |
407 | AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples | |
408 | AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples | |
409 | AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples | |
410 | AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples | |
411 | AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples | |
412 | AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples | |
413 | ||
414 | // Planar YUVA | |
415 | AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples | |
416 | AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples | |
417 | AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples | |
418 | ||
419 | AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples | |
420 | AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples | |
421 | AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples | |
422 | ||
423 | AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples | |
424 | AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples | |
425 | AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples | |
426 | ||
427 | AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples | |
428 | AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples | |
429 | AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples | |
430 | ||
431 | AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples | |
432 | AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples | |
433 | AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples | |
434 | ||
435 | AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples | |
436 | AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples | |
437 | AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples | |
438 | ||
155 | 439 | }; |
156 | 440 | |
157 | 441 | enum { |
179 | 463 | |
180 | 464 | enum { |
181 | 465 | // New 2.6 explicitly defined cache hints. |
182 | AVS_CACHE_NOTHING=10, // Do not cache video. | |
183 | AVS_CACHE_WINDOW=11, // Hard protect upto X frames within a range of X from the current frame N. | |
184 | AVS_CACHE_GENERIC=12, // LRU cache upto X frames. | |
185 | AVS_CACHE_FORCE_GENERIC=13, // LRU cache upto X frames, override any previous CACHE_WINDOW. | |
186 | ||
187 | AVS_CACHE_GET_POLICY=30, // Get the current policy. | |
188 | AVS_CACHE_GET_WINDOW=31, // Get the current window h_span. | |
189 | AVS_CACHE_GET_RANGE=32, // Get the current generic frame range. | |
190 | ||
191 | AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache. | |
192 | AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio. | |
193 | AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte intial cache. | |
194 | AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte intial cache. | |
195 | ||
196 | AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy. | |
197 | AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size. | |
198 | ||
199 | AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N. | |
200 | AVS_CACHE_PREFETCH_GO=101, // Action video prefetches. | |
201 | ||
202 | AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section). | |
203 | AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start. | |
204 | AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start. | |
205 | AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length. | |
206 | AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section). | |
207 | AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches. | |
208 | ||
209 | AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode. | |
210 | AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size. | |
211 | AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode. | |
212 | AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size. | |
213 | ||
214 | AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost. | |
215 | AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only). | |
216 | AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit). | |
217 | AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast) | |
218 | AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time) | |
219 | AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow) | |
220 | ||
221 | AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safetyness. | |
222 | AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default! | |
223 | AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default! | |
224 | AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance. | |
225 | AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded. | |
226 | ||
227 | AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern. | |
228 | AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic. | |
229 | AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost) | |
230 | AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost) | |
231 | }; | |
232 | ||
233 | #define AVS_FRAME_ALIGN 16 | |
466 | AVS_CACHE_NOTHING = 10, // Do not cache video. | |
467 | AVS_CACHE_WINDOW = 11, // Hard protect up to X frames within a range of X from the current frame N. | |
468 | AVS_CACHE_GENERIC = 12, // LRU cache up to X frames. | |
469 | AVS_CACHE_FORCE_GENERIC = 13, // LRU cache up to X frames, override any previous CACHE_WINDOW. | |
470 | ||
471 | AVS_CACHE_GET_POLICY = 30, // Get the current policy. | |
472 | AVS_CACHE_GET_WINDOW = 31, // Get the current window h_span. | |
473 | AVS_CACHE_GET_RANGE = 32, // Get the current generic frame range. | |
474 | ||
475 | AVS_CACHE_AUDIO = 50, // Explicitly do cache audio, X byte cache. | |
476 | AVS_CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio. | |
477 | AVS_CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache. | |
478 | AVS_CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache. | |
479 | ||
480 | AVS_CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy. | |
481 | AVS_CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size. | |
482 | ||
483 | AVS_CACHE_PREFETCH_FRAME = 100, // Queue request to prefetch frame N. | |
484 | AVS_CACHE_PREFETCH_GO = 101, // Action video prefetches. | |
485 | ||
486 | AVS_CACHE_PREFETCH_AUDIO_BEGIN = 120, // Begin queue request transaction to prefetch audio (take critical section). | |
487 | AVS_CACHE_PREFETCH_AUDIO_STARTLO = 121, // Set low 32 bits of start. | |
488 | AVS_CACHE_PREFETCH_AUDIO_STARTHI = 122, // Set high 32 bits of start. | |
489 | AVS_CACHE_PREFETCH_AUDIO_COUNT = 123, // Set low 32 bits of length. | |
490 | AVS_CACHE_PREFETCH_AUDIO_COMMIT = 124, // Enqueue request transaction to prefetch audio (release critical section). | |
491 | AVS_CACHE_PREFETCH_AUDIO_GO = 125, // Action audio prefetches. | |
492 | ||
493 | AVS_CACHE_GETCHILD_CACHE_MODE = 200, // Cache ask Child for desired video cache mode. | |
494 | AVS_CACHE_GETCHILD_CACHE_SIZE = 201, // Cache ask Child for desired video cache size. | |
495 | AVS_CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode. | |
496 | AVS_CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size. | |
497 | ||
498 | AVS_CACHE_GETCHILD_COST = 220, // Cache ask Child for estimated processing cost. | |
499 | AVS_CACHE_COST_ZERO = 221, // Child response of zero cost (ptr arithmetic only). | |
500 | AVS_CACHE_COST_UNIT = 222, // Child response of unit cost (less than or equal 1 full frame blit). | |
501 | AVS_CACHE_COST_LOW = 223, // Child response of light cost. (Fast) | |
502 | AVS_CACHE_COST_MED = 224, // Child response of medium cost. (Real time) | |
503 | AVS_CACHE_COST_HI = 225, // Child response of heavy cost. (Slow) | |
504 | ||
505 | AVS_CACHE_GETCHILD_THREAD_MODE = 240, // Cache ask Child for thread safety. | |
506 | AVS_CACHE_THREAD_UNSAFE = 241, // Only 1 thread allowed for all instances. 2.5 filters default! | |
507 | AVS_CACHE_THREAD_CLASS = 242, // Only 1 thread allowed for each instance. 2.6 filters default! | |
508 | AVS_CACHE_THREAD_SAFE = 243, // Allow all threads in any instance. | |
509 | AVS_CACHE_THREAD_OWN = 244, // Safe but limit to 1 thread, internally threaded. | |
510 | ||
511 | AVS_CACHE_GETCHILD_ACCESS_COST = 260, // Cache ask Child for preferred access pattern. | |
512 | AVS_CACHE_ACCESS_RAND = 261, // Filter is access order agnostic. | |
513 | AVS_CACHE_ACCESS_SEQ0 = 262, // Filter prefers sequential access (low cost) | |
514 | AVS_CACHE_ACCESS_SEQ1 = 263, // Filter needs sequential access (high cost) | |
515 | ||
516 | AVS_CACHE_AVSPLUS_CONSTANTS = 500, // Smaller values are reserved for classic Avisynth | |
517 | ||
518 | AVS_CACHE_DONT_CACHE_ME = 501, // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request | |
519 | AVS_CACHE_SET_MIN_CAPACITY = 502, | |
520 | AVS_CACHE_SET_MAX_CAPACITY = 503, | |
521 | AVS_CACHE_GET_MIN_CAPACITY = 504, | |
522 | AVS_CACHE_GET_MAX_CAPACITY = 505, | |
523 | AVS_CACHE_GET_SIZE = 506, | |
524 | AVS_CACHE_GET_REQUESTED_CAP = 507, | |
525 | AVS_CACHE_GET_CAPACITY = 508, | |
526 | AVS_CACHE_GET_MTMODE = 509, | |
527 | ||
528 | AVS_CACHE_IS_CACHE_REQ = 510, | |
529 | AVS_CACHE_IS_CACHE_ANS = 511, | |
530 | AVS_CACHE_IS_MTGUARD_REQ = 512, | |
531 | AVS_CACHE_IS_MTGUARD_ANS = 513, | |
532 | ||
533 | AVS_CACHE_AVSPLUS_CUDA_CONSTANTS = 600, | |
534 | ||
535 | AVS_CACHE_GET_DEV_TYPE = 601, // Device types a filter can return | |
536 | AVS_CACHE_GET_CHILD_DEV_TYPE = 602, // Device types a fitler can receive | |
537 | ||
538 | AVS_CACHE_USER_CONSTANTS = 1000 // Smaller values are reserved for the core | |
539 | ||
540 | }; | |
541 | ||
542 | ||
543 | ||
544 | // enums for frame property functions | |
545 | // AVSPropTypes | |
546 | enum { | |
547 | AVS_PROPTYPE_UNSET = 'u', | |
548 | AVS_PROPTYPE_INT = 'i', | |
549 | AVS_PROPTYPE_FLOAT = 'f', | |
550 | AVS_PROPTYPE_DATA = 's', | |
551 | AVS_PROPTYPE_CLIP = 'c', | |
552 | AVS_PROPTYPE_FRAME = 'v' | |
553 | }; | |
554 | ||
555 | // AVSGetPropErrors for avs_prop_get_... | |
556 | enum { | |
557 | AVS_GETPROPERROR_UNSET = 1, | |
558 | AVS_GETPROPERROR_TYPE = 2, | |
559 | AVS_GETPROPERROR_INDEX = 4 | |
560 | }; | |
561 | ||
562 | // AVSPropAppendMode for avs_prop_set_... | |
563 | enum { | |
564 | AVS_PROPAPPENDMODE_REPLACE = 0, | |
565 | AVS_PROPAPPENDMODE_APPEND = 1, | |
566 | AVS_PROPAPPENDMODE_TOUCH = 2 | |
567 | }; | |
568 | ||
569 | // AvsEnvProperty for avs_get_env_property | |
570 | enum | |
571 | { | |
572 | AVS_AEP_PHYSICAL_CPUS = 1, | |
573 | AVS_AEP_LOGICAL_CPUS = 2, | |
574 | AVS_AEP_THREADPOOL_THREADS = 3, | |
575 | AVS_AEP_FILTERCHAIN_THREADS = 4, | |
576 | AVS_AEP_THREAD_ID = 5, | |
577 | AVS_AEP_VERSION = 6, | |
578 | AVS_AEP_HOST_SYSTEM_ENDIANNESS = 7, | |
579 | AVS_AEP_INTERFACE_VERSION = 8, | |
580 | AVS_AEP_INTERFACE_BUGFIX = 9, | |
581 | ||
582 | // Neo additionals | |
583 | AVS_AEP_NUM_DEVICES = 901, | |
584 | AVS_AEP_FRAME_ALIGN = 902, | |
585 | AVS_AEP_PLANE_ALIGN = 903, | |
586 | ||
587 | AVS_AEP_SUPPRESS_THREAD = 921, | |
588 | AVS_AEP_GETFRAME_RECURSIVE = 922 | |
589 | }; | |
590 | ||
591 | // enum AvsAllocType for avs_allocate | |
592 | enum { | |
593 | AVS_ALLOCTYPE_NORMAL_ALLOC = 1, | |
594 | AVS_ALLOCTYPE_POOLED_ALLOC = 2 | |
595 | }; | |
596 | ||
597 | #ifdef BUILDING_AVSCORE | |
598 | AVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0); | |
599 | ||
600 | struct AVS_ScriptEnvironment { | |
601 | IScriptEnvironment * env; | |
602 | const char * error; | |
603 | AVS_ScriptEnvironment(IScriptEnvironment * e = 0) | |
604 | : env(e), error(0) {} | |
605 | }; | |
606 | #endif | |
234 | 607 | |
235 | 608 | typedef struct AVS_Clip AVS_Clip; |
236 | 609 | typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment; |
240 | 613 | // AVS_VideoInfo |
241 | 614 | // |
242 | 615 | |
243 | // AVS_VideoInfo is layed out identicly to VideoInfo | |
616 | // AVS_VideoInfo is laid out identically to VideoInfo | |
244 | 617 | typedef struct AVS_VideoInfo { |
245 | 618 | int width, height; // width=0 means no video |
246 | 619 | unsigned fps_numerator, fps_denominator; |
250 | 623 | |
251 | 624 | int audio_samples_per_second; // 0 means no audio |
252 | 625 | int sample_type; |
253 | INT64 num_audio_samples; | |
626 | int64_t num_audio_samples; | |
254 | 627 | int nchannels; |
255 | 628 | |
256 | // Imagetype properties | |
629 | // Image type properties | |
257 | 630 | |
258 | 631 | int image_type; |
259 | 632 | } AVS_VideoInfo; |
280 | 653 | AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) |
281 | 654 | { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } |
282 | 655 | |
283 | AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); | |
284 | ||
285 | AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); | |
286 | ||
287 | AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p); | |
656 | AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444 | |
657 | ||
658 | AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422 | |
659 | ||
660 | AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420 | |
288 | 661 | |
289 | 662 | AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p); |
290 | 663 | |
291 | AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); | |
664 | AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y | |
292 | 665 | |
293 | 666 | #ifdef AVSC_NO_DECLSPEC |
294 | 667 | AVSC_INLINE int avs_is_yv24(const AVS_VideoInfo * p) |
295 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV24 & AVS_CS_PLANAR_FILTER); } | |
668 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV24 & AVS_CS_PLANAR_FILTER); } | |
296 | 669 | |
297 | 670 | AVSC_INLINE int avs_is_yv16(const AVS_VideoInfo * p) |
298 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV16 & AVS_CS_PLANAR_FILTER); } | |
671 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV16 & AVS_CS_PLANAR_FILTER); } | |
299 | 672 | |
300 | 673 | AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo * p) |
301 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV12 & AVS_CS_PLANAR_FILTER); } | |
674 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV12 & AVS_CS_PLANAR_FILTER); } | |
302 | 675 | |
303 | 676 | AVSC_INLINE int avs_is_yv411(const AVS_VideoInfo * p) |
304 | 677 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV411 & AVS_CS_PLANAR_FILTER); } |
305 | 678 | |
306 | 679 | AVSC_INLINE int avs_is_y8(const AVS_VideoInfo * p) |
307 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_Y8 & AVS_CS_PLANAR_FILTER); } | |
308 | #endif | |
309 | ||
310 | #if 1 // AviSynth+ extension | |
311 | AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p); | |
312 | ||
313 | AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p); | |
314 | ||
315 | AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); | |
316 | ||
317 | AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); | |
318 | ||
319 | AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); | |
320 | ||
321 | AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); | |
322 | ||
323 | AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); | |
324 | ||
325 | AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); | |
326 | ||
327 | AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); | |
328 | ||
329 | AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); | |
330 | ||
331 | AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p); | |
332 | ||
333 | AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p); | |
334 | ||
335 | AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p); | |
336 | ||
337 | AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p); | |
338 | ||
339 | AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p); | |
340 | ||
341 | AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p); | |
342 | ||
343 | AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p); | |
344 | ||
345 | AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p); | |
346 | ||
347 | AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p); | |
348 | ||
349 | AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p); | |
350 | #endif | |
351 | ||
680 | { return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_Y8 & AVS_CS_PLANAR_FILTER); } | |
681 | #endif | |
682 | ||
683 | AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane); | |
684 | ||
685 | AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane); | |
686 | ||
687 | AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p); | |
688 | ||
689 | AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels); | |
690 | ||
691 | AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane); | |
692 | ||
693 | AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi); | |
694 | ||
695 | AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space); | |
696 | ||
697 | // no API for these, inline helper functions | |
352 | 698 | AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) |
353 | { return ((p->image_type & property)==property ); } | |
699 | { | |
700 | return ((p->image_type & property) == property); | |
701 | } | |
354 | 702 | |
355 | 703 | AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p) |
356 | { return !!(p->pixel_type & AVS_CS_PLANAR); } | |
357 | ||
358 | AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space); | |
704 | { | |
705 | return !!(p->pixel_type & AVS_CS_PLANAR); | |
706 | } | |
359 | 707 | |
360 | 708 | AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p) |
361 | { return !!(p->image_type & AVS_IT_FIELDBASED); } | |
709 | { | |
710 | return !!(p->image_type & AVS_IT_FIELDBASED); | |
711 | } | |
362 | 712 | |
363 | 713 | AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p) |
364 | { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); } | |
714 | { | |
715 | return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); | |
716 | } | |
365 | 717 | |
366 | 718 | AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p) |
367 | { return !!(p->image_type & AVS_IT_BFF); } | |
719 | { | |
720 | return !!(p->image_type & AVS_IT_BFF); | |
721 | } | |
368 | 722 | |
369 | 723 | AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p) |
370 | { return !!(p->image_type & AVS_IT_TFF); } | |
371 | ||
372 | AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane); | |
373 | ||
374 | AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane); | |
375 | ||
376 | ||
377 | AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p); | |
378 | ||
379 | AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels); | |
380 | ||
381 | AVSC_API(int, avs_row_size_p)(const AVS_VideoInfo * p, int plane); | |
382 | ||
383 | #ifndef AVSC_NO_DECLSPEC | |
384 | AVSC_INLINE int avs_row_size(const AVS_VideoInfo * p) | |
385 | { return avs_row_size_p(p, 0); } | |
386 | #endif | |
387 | ||
388 | AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi); | |
724 | { | |
725 | return !!(p->image_type & AVS_IT_TFF); | |
726 | } | |
389 | 727 | |
390 | 728 | AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p) |
391 | 729 | { return p->audio_samples_per_second; } |
392 | ||
393 | 730 | |
394 | 731 | AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p) |
395 | 732 | { |
402 | 739 | default: return 0; |
403 | 740 | } |
404 | 741 | } |
742 | ||
405 | 743 | AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p) |
406 | { return p->nchannels*avs_bytes_per_channel_sample(p);} | |
407 | ||
408 | AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames) | |
409 | { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } | |
410 | ||
411 | AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) | |
412 | { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); } | |
413 | ||
414 | AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes) | |
744 | { return p->nchannels*avs_bytes_per_channel_sample(p); } | |
745 | ||
746 | AVSC_INLINE int64_t avs_audio_samples_from_frames(const AVS_VideoInfo * p, int64_t frames) | |
747 | { return ((int64_t)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } | |
748 | ||
749 | AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, int64_t samples) | |
750 | { return (int)(samples * (int64_t)p->fps_numerator / (int64_t)p->fps_denominator / (int64_t)p->audio_samples_per_second); } | |
751 | ||
752 | AVSC_INLINE int64_t avs_audio_samples_from_bytes(const AVS_VideoInfo * p, int64_t bytes) | |
415 | 753 | { return bytes / avs_bytes_per_audio_sample(p); } |
416 | 754 | |
417 | AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) | |
755 | AVSC_INLINE int64_t avs_bytes_from_audio_samples(const AVS_VideoInfo * p, int64_t samples) | |
418 | 756 | { return samples * avs_bytes_per_audio_sample(p); } |
419 | 757 | |
420 | 758 | AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p) |
421 | 759 | { return p->nchannels; } |
422 | 760 | |
423 | 761 | AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p) |
424 | { return p->sample_type;} | |
762 | { return p->sample_type; } | |
425 | 763 | |
426 | 764 | // useful mutator |
765 | // Note: these are video format properties, neither frame properties, nor system properties | |
427 | 766 | AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property) |
428 | 767 | { p->image_type|=property; } |
429 | 768 | |
443 | 782 | p->fps_denominator = denominator/x; |
444 | 783 | } |
445 | 784 | |
446 | AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y) | |
785 | AVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y) | |
447 | 786 | { |
448 | 787 | return (x->pixel_type == y->pixel_type) |
449 | 788 | || (avs_is_yv12(x) && avs_is_yv12(y)); |
450 | 789 | } |
790 | ||
791 | // AviSynth+ extensions | |
792 | AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p); | |
793 | ||
794 | AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p); | |
795 | ||
796 | AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444 | |
797 | AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422 | |
798 | AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420 | |
799 | AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // deprecated, use avs_is_y | |
800 | AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444 | |
801 | AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422 | |
802 | AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420 | |
803 | AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // deprecated, use avs_is_y | |
804 | ||
805 | AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p); | |
806 | ||
807 | AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p); | |
808 | ||
809 | AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p); | |
810 | ||
811 | AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p); | |
812 | ||
813 | AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p); | |
814 | ||
815 | AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p); | |
816 | ||
817 | AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p); | |
818 | ||
819 | AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p); | |
820 | ||
821 | AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p); | |
822 | ||
823 | AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p); | |
824 | ||
825 | // end of Avisynth+ specific | |
451 | 826 | |
452 | 827 | ///////////////////////////////////////////////////////////////////// |
453 | 828 | // |
460 | 835 | // to be reused. The instances are deleted when the corresponding AVS |
461 | 836 | // file is closed. |
462 | 837 | |
463 | // AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer | |
838 | // AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer | |
464 | 839 | // DO NOT USE THIS STRUCTURE DIRECTLY |
465 | 840 | typedef struct AVS_VideoFrameBuffer { |
466 | 841 | BYTE * data; |
470 | 845 | volatile long sequence_number; |
471 | 846 | |
472 | 847 | volatile long refcount; |
848 | ||
849 | void* device; // avs+ | |
473 | 850 | } AVS_VideoFrameBuffer; |
474 | 851 | |
475 | 852 | // VideoFrame holds a "window" into a VideoFrameBuffer. |
476 | 853 | |
477 | // AVS_VideoFrame is layed out identicly to IVideoFrame | |
854 | // AVS_VideoFrame is laid out identically to IVideoFrame | |
478 | 855 | // DO NOT USE THIS STRUCTURE DIRECTLY |
479 | 856 | typedef struct AVS_VideoFrame { |
480 | 857 | volatile long refcount; |
481 | 858 | AVS_VideoFrameBuffer * vfb; |
482 | int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture. | |
483 | int row_sizeUV, heightUV; | |
859 | int offset; | |
860 | int pitch, row_size, height; | |
861 | int offsetU, offsetV; | |
862 | int pitchUV; // U&V offsets are from top of picture. | |
863 | int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane. | |
864 | // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable) | |
865 | // the decision on existence of UV is checked by zero pitch | |
866 | // AVS+ extension, avisynth.h: class does not break plugins if appended here | |
867 | int offsetA; | |
868 | int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none | |
869 | void* properties; // frame properties | |
484 | 870 | } AVS_VideoFrame; |
485 | 871 | |
486 | 872 | // Access functions for AVS_VideoFrame |
487 | 873 | AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane); |
488 | 874 | |
875 | AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane); | |
876 | ||
877 | AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane); | |
878 | ||
879 | AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane); | |
880 | ||
489 | 881 | #ifdef AVSC_NO_DECLSPEC |
490 | AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) { | |
491 | switch (plane) { | |
492 | case AVS_PLANAR_U: | |
493 | case AVS_PLANAR_V: | |
494 | return p->pitchUV; | |
495 | } | |
496 | return p->pitch; | |
497 | } | |
498 | #endif | |
499 | ||
500 | AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { | |
501 | return avs_get_pitch_p(p, 0);} | |
502 | ||
503 | AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane); | |
504 | ||
505 | AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { | |
506 | return p->row_size; } | |
507 | ||
508 | AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane); | |
509 | ||
510 | AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { | |
511 | return p->height;} | |
512 | ||
513 | AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane); | |
514 | ||
515 | #ifdef AVSC_NO_DECLSPEC | |
516 | AVSC_INLINE const BYTE* avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane) { | |
517 | switch (plane) { | |
518 | case AVS_PLANAR_U: return p->vfb->data + p->offsetU; | |
519 | case AVS_PLANAR_V: return p->vfb->data + p->offsetV; | |
520 | default: return p->vfb->data + p->offset; | |
521 | } | |
522 | } | |
523 | #endif | |
524 | ||
525 | AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) { | |
526 | return avs_get_read_ptr_p(p, 0);} | |
882 | AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) | |
883 | { | |
884 | switch (plane) { | |
885 | case AVS_PLANAR_U: case AVS_PLANAR_V: | |
886 | return p->pitchUV; | |
887 | case AVS_PLANAR_A: | |
888 | return p->pitchA; | |
889 | } | |
890 | return p->pitch; // Y, G, B, R | |
891 | } | |
892 | ||
893 | AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame * p, int plane) | |
894 | { | |
895 | switch (plane) { | |
896 | case AVS_PLANAR_U: case AVS_PLANAR_V: | |
897 | return (p->pitchUV) ? p->row_sizeUV : 0; | |
898 | case AVS_PLANAR_A: | |
899 | return (p->pitchA) ? p->row_sizeA : 0; | |
900 | } | |
901 | return p->row_size; | |
902 | } | |
903 | ||
904 | AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame * p, int plane) | |
905 | { | |
906 | switch (plane) { | |
907 | case AVS_PLANAR_U: case AVS_PLANAR_V: | |
908 | return (p->pitchUV) ? p->heightUV : 0; | |
909 | case AVS_PLANAR_A: | |
910 | return (p->pitchA) ? p->height : 0; | |
911 | } | |
912 | return p->height; // Y, G, B, R, A | |
913 | } | |
914 | ||
915 | AVSC_INLINE const BYTE * avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane) | |
916 | { | |
917 | switch (plane) { // G is first. Then B,R order like U,V | |
918 | case AVS_PLANAR_U: case AVS_PLANAR_B: | |
919 | return p->vfb->data + p->offsetU; | |
920 | case AVS_PLANAR_V: case AVS_PLANAR_R: | |
921 | return p->vfb->data + p->offsetV; | |
922 | case AVS_PLANAR_A: | |
923 | return p->vfb->data + p->offsetA; | |
924 | } | |
925 | return p->vfb->data + p->offset; // Y, G | |
926 | } | |
927 | #endif | |
527 | 928 | |
528 | 929 | AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p); |
529 | 930 | |
931 | // V9 | |
932 | AVSC_API(int, avs_is_property_writable)(const AVS_VideoFrame* p); | |
933 | ||
530 | 934 | AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane); |
531 | ||
532 | #ifndef AVSC_NO_DECLSPEC | |
533 | AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) { | |
534 | return avs_get_write_ptr_p(p, 0);} | |
535 | #endif | |
536 | 935 | |
537 | 936 | AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *); |
538 | 937 | // makes a shallow copy of a video frame |
539 | 938 | AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *); |
540 | 939 | |
940 | // no API for these, inline helper functions | |
941 | AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) | |
942 | {return avs_get_pitch_p(p, 0);} | |
943 | ||
944 | AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) | |
945 | {return avs_get_row_size_p(p, 0);} | |
946 | ||
947 | AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) | |
948 | {return avs_get_height_p(p, 0);} | |
949 | ||
950 | AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) | |
951 | {return avs_get_read_ptr_p(p, 0);} | |
952 | ||
541 | 953 | #ifndef AVSC_NO_DECLSPEC |
954 | // this inline function is calling an API function | |
955 | AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) | |
956 | {return avs_get_write_ptr_p(p, 0);} | |
957 | #endif | |
958 | ||
959 | #ifndef AVSC_NO_DECLSPEC | |
960 | // this inline function is calling an API function | |
542 | 961 | AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f) |
543 | 962 | {avs_release_video_frame(f);} |
963 | #endif | |
964 | ||
965 | #ifndef AVSC_NO_DECLSPEC | |
966 | // this inline function is calling an API function | |
544 | 967 | AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f) |
545 | 968 | {return avs_copy_video_frame(f);} |
546 | 969 | #endif |
970 | ||
971 | // Interface V8: frame properties | |
972 | // AVS_Map is just a placeholder for AVSMap | |
973 | typedef struct AVS_Map { | |
974 | void* data; | |
975 | } AVS_Map; | |
976 | ||
547 | 977 | |
548 | 978 | ///////////////////////////////////////////////////////////////////// |
549 | 979 | // |
551 | 981 | // |
552 | 982 | |
553 | 983 | // Treat AVS_Value as a fat pointer. That is use avs_copy_value |
554 | // and avs_release_value appropiaty as you would if AVS_Value was | |
984 | // and avs_release_value appropriately as you would if AVS_Value was | |
555 | 985 | // a pointer. |
556 | 986 | |
557 | 987 | // To maintain source code compatibility with future versions of the |
558 | 988 | // avisynth_c API don't use the AVS_Value directly. Use the helper |
559 | 989 | // functions below. |
560 | 990 | |
561 | // AVS_Value is layed out identicly to AVSValue | |
991 | // AVS_Value is laid out identically to AVSValue | |
562 | 992 | typedef struct AVS_Value AVS_Value; |
563 | 993 | struct AVS_Value { |
564 | short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong | |
994 | short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong, or fu'n'ction | |
565 | 995 | // for some function e'rror |
566 | 996 | short array_size; |
567 | 997 | union { |
571 | 1001 | float floating_pt; |
572 | 1002 | const char * string; |
573 | 1003 | const AVS_Value * array; |
1004 | void * function; // not supported on C interface | |
1005 | #ifdef AVS_X86_64 | |
1006 | // if ever, only x64 will support. It breaks struct size on 32 bit | |
1007 | int64_t longlong; // 8 bytes | |
1008 | double double_pt; // 8 bytes | |
1009 | #endif | |
574 | 1010 | } d; |
575 | 1011 | }; |
576 | 1012 | |
577 | // AVS_Value should be initilized with avs_void. | |
1013 | // AVS_Value should be initialized with avs_void. | |
578 | 1014 | // Should also set to avs_void after the value is released |
579 | // with avs_copy_value. Consider it the equalvent of setting | |
1015 | // with avs_copy_value. Consider it the equivalent of setting | |
580 | 1016 | // a pointer to NULL |
581 | 1017 | static const AVS_Value avs_void = {'v'}; |
582 | 1018 | |
583 | 1019 | AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src); |
584 | 1020 | AVSC_API(void, avs_release_value)(AVS_Value); |
585 | ||
1021 | AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); | |
1022 | AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); | |
1023 | ||
1024 | ||
1025 | // no API for these, inline helper functions | |
586 | 1026 | AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; } |
587 | 1027 | AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; } |
588 | 1028 | AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; } |
591 | 1031 | AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; } |
592 | 1032 | AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; } |
593 | 1033 | AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; } |
594 | ||
595 | AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); | |
596 | AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); | |
597 | 1034 | |
598 | 1035 | AVSC_INLINE int avs_as_bool(AVS_Value v) |
599 | 1036 | { return v.d.boolean; } |
621 | 1058 | AVSC_INLINE AVS_Value avs_new_value_string(const char * v0) |
622 | 1059 | { AVS_Value v; v.type = 's'; v.d.string = v0; return v; } |
623 | 1060 | AVSC_INLINE AVS_Value avs_new_value_float(float v0) |
624 | { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;} | |
1061 | { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v; } | |
625 | 1062 | AVSC_INLINE AVS_Value avs_new_value_error(const char * v0) |
626 | 1063 | { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; } |
627 | 1064 | #ifndef AVSC_NO_DECLSPEC |
1065 | // this inline function is calling an API function | |
628 | 1066 | AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) |
629 | 1067 | { AVS_Value v; avs_set_to_clip(&v, v0); return v; } |
630 | 1068 | #endif |
631 | 1069 | AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) |
632 | 1070 | { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; } |
1071 | // end of inline helper functions | |
633 | 1072 | |
634 | 1073 | ///////////////////////////////////////////////////////////////////// |
635 | 1074 | // |
652 | 1091 | // return field parity if field_based, else parity of first field in frame |
653 | 1092 | |
654 | 1093 | AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf, |
655 | INT64 start, INT64 count); | |
1094 | int64_t start, int64_t count); | |
656 | 1095 | // start and count are in samples |
657 | 1096 | |
658 | 1097 | AVSC_API(int, avs_set_cache_hints)(AVS_Clip *, |
672 | 1111 | AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n); |
673 | 1112 | int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n); |
674 | 1113 | int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, |
675 | INT64 start, INT64 count); | |
1114 | int64_t start, int64_t count); | |
676 | 1115 | int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, |
677 | 1116 | int frame_range); |
678 | 1117 | void (AVSC_CC * free_filter)(AVS_FilterInfo *); |
686 | 1125 | |
687 | 1126 | // Create a new filter |
688 | 1127 | // fi is set to point to the AVS_FilterInfo so that you can |
689 | // modify it once it is initilized. | |
1128 | // modify it once it is initialized. | |
690 | 1129 | // store_child should generally be set to true. If it is not |
691 | 1130 | // set than ALL methods (the function pointers) must be defined |
692 | 1131 | // If it is set than you do not need to worry about freeing the child |
717 | 1156 | AVS_CPUF_SSSE3 = 0x200, // Core 2 |
718 | 1157 | AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield |
719 | 1158 | AVS_CPUF_SSE4_1 = 0x400, |
720 | //AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer | |
1159 | AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer | |
721 | 1160 | AVS_CPUF_SSE4_2 = 0x1000, // Nehalem |
722 | //AVS_CPUF_AVX2 = 0x2000, // Haswell | |
723 | //AVS_CPUF_AVX512 = 0x4000, // Knights Landing | |
1161 | // AVS+ | |
1162 | AVS_CPUF_AVX2 = 0x2000, // Haswell | |
1163 | AVS_CPUF_FMA3 = 0x4000, | |
1164 | AVS_CPUF_F16C = 0x8000, | |
1165 | AVS_CPUF_MOVBE = 0x10000, // Big Endian Move | |
1166 | AVS_CPUF_POPCNT = 0x20000, | |
1167 | AVS_CPUF_AES = 0x40000, | |
1168 | AVS_CPUF_FMA4 = 0x80000, | |
1169 | ||
1170 | AVS_CPUF_AVX512F = 0x100000, // AVX-512 Foundation. | |
1171 | AVS_CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions | |
1172 | AVS_CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch | |
1173 | AVS_CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal | |
1174 | AVS_CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection | |
1175 | AVS_CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions | |
1176 | AVS_CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions | |
1177 | AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit | |
1178 | AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI | |
724 | 1179 | }; |
725 | 1180 | |
726 | 1181 | |
727 | 1182 | AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error |
728 | 1183 | |
729 | AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *); | |
1184 | AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *); | |
730 | 1185 | AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version); |
731 | 1186 | |
732 | 1187 | AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length); |
733 | 1188 | AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...); |
734 | 1189 | |
735 | AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val); | |
736 | // note: val is really a va_list; I hope everyone typedefs va_list to a pointer | |
1190 | AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val); | |
737 | 1191 | |
738 | 1192 | AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *, |
739 | 1193 | const char * name, const char * params, |
755 | 1209 | //void avs_push_context(AVS_ScriptEnvironment *, int level=0); |
756 | 1210 | //void avs_pop_context(AVS_ScriptEnvironment *); |
757 | 1211 | |
1212 | // partially deprecated, from V8 use avs_new_video_frame_p_a (frame property copy) | |
758 | 1213 | AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *, |
759 | 1214 | const AVS_VideoInfo * vi, int align); |
760 | // align should be at least 16 | |
761 | ||
1215 | // align should be at least 16 for classic Avisynth | |
1216 | // Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided | |
1217 | ||
1218 | // no API for these, inline helper functions | |
762 | 1219 | #ifndef AVSC_NO_DECLSPEC |
763 | AVSC_INLINE | |
764 | AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, | |
1220 | // partially deprecated, from V8 use avs_new_video_frame_p (frame property copy) | |
1221 | // this inline function is calling an API function | |
1222 | AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, | |
765 | 1223 | const AVS_VideoInfo * vi) |
766 | 1224 | {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} |
767 | 1225 | |
768 | AVSC_INLINE | |
769 | AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, | |
1226 | // an older compatibility alias | |
1227 | // this inline function is calling an API function | |
1228 | AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, | |
770 | 1229 | const AVS_VideoInfo * vi) |
771 | 1230 | {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} |
772 | 1231 | #endif |
773 | ||
1232 | // end of inline helper functions | |
774 | 1233 | |
775 | 1234 | AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf); |
1235 | ||
1236 | // V9 | |
1237 | AVSC_API(int, avs_make_property_writable)(AVS_ScriptEnvironment*, AVS_VideoFrame** pvf); | |
776 | 1238 | |
777 | 1239 | AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height); |
778 | 1240 | |
781 | 1243 | |
782 | 1244 | AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height); |
783 | 1245 | // The returned video frame must be be released |
1246 | AVSC_API(AVS_VideoFrame*, avs_subframe_planar)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); | |
1247 | // The returned video frame must be be released | |
1248 | // see also avs_subframe_planar_a in interface V8 | |
784 | 1249 | |
785 | 1250 | AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem); |
786 | 1251 | |
798 | 1263 | |
799 | 1264 | AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *); |
800 | 1265 | |
801 | ||
802 | AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); | |
1266 | /////////////////////////////////////////////////////////////////////////////// | |
1267 | // | |
1268 | // Avisynth+ V8 interface elements | |
1269 | // | |
1270 | ||
1271 | AVSC_API(AVS_VideoFrame*, avs_subframe_planar_a)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA); | |
803 | 1272 | // The returned video frame must be be released |
804 | 1273 | |
1274 | AVSC_API(void, avs_copy_frame_props)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* src, AVS_VideoFrame* dst); | |
1275 | AVSC_API(const AVS_Map*, avs_get_frame_props_ro)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* frame); | |
1276 | AVSC_API(AVS_Map*, avs_get_frame_props_rw)(AVS_ScriptEnvironment* p, AVS_VideoFrame* frame); | |
1277 | AVSC_API(int, avs_prop_num_keys)(AVS_ScriptEnvironment* p, const AVS_Map* map); | |
1278 | AVSC_API(const char*, avs_prop_get_key)(AVS_ScriptEnvironment* p, const AVS_Map* map, int index); | |
1279 | AVSC_API(int, avs_prop_num_elements)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key); | |
1280 | ||
1281 | // see AVS_PROPTYPE_... enums | |
1282 | AVSC_API(char, avs_prop_get_type)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key); | |
1283 | ||
1284 | // see AVS_GETPROPERROR_... enums | |
1285 | AVSC_API(int64_t, avs_prop_get_int)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1286 | AVSC_API(double, avs_prop_get_float)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1287 | AVSC_API(const char*, avs_prop_get_data)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1288 | AVSC_API(int, avs_prop_get_data_size)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1289 | AVSC_API(AVS_Clip*, avs_prop_get_clip)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1290 | AVSC_API(const AVS_VideoFrame*, avs_prop_get_frame)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error); | |
1291 | ||
1292 | AVSC_API(int, avs_prop_delete_key)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key); | |
1293 | ||
1294 | // see AVS_PROPAPPENDMODE_... enums | |
1295 | AVSC_API(int, avs_prop_set_int)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, int64_t i, int append); | |
1296 | AVSC_API(int, avs_prop_set_float)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, double d, int append); | |
1297 | AVSC_API(int, avs_prop_set_data)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const char* d, int length, int append); | |
1298 | AVSC_API(int, avs_prop_set_clip)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, AVS_Clip* clip, int append); | |
1299 | AVSC_API(int, avs_prop_set_frame)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const AVS_VideoFrame* frame, int append); | |
1300 | ||
1301 | AVSC_API(const int64_t*, avs_prop_get_int_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error); | |
1302 | AVSC_API(const double*, avs_prop_get_float_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error); | |
1303 | AVSC_API(int, avs_prop_set_int_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const int64_t* i, int size); | |
1304 | AVSC_API(int, avs_prop_set_float_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const double* d, int size); | |
1305 | ||
1306 | AVSC_API(void, avs_clear_map)(AVS_ScriptEnvironment* p, AVS_Map* map); | |
1307 | ||
1308 | // with frame property source | |
1309 | AVSC_API(AVS_VideoFrame*, avs_new_video_frame_p)(AVS_ScriptEnvironment*, | |
1310 | const AVS_VideoInfo* vi, AVS_VideoFrame* propSrc); | |
1311 | ||
1312 | // with frame property source | |
1313 | AVSC_API(AVS_VideoFrame*, avs_new_video_frame_p_a)(AVS_ScriptEnvironment*, | |
1314 | const AVS_VideoInfo* vi, AVS_VideoFrame* propSrc, int align); | |
1315 | ||
1316 | // Generic query to ask for various system properties, see AVS_AEP_xxx enums | |
1317 | AVSC_API(size_t, avs_get_env_property)(AVS_ScriptEnvironment*, int avs_aep_prop); | |
1318 | ||
1319 | // buffer pool, see AVS_ALLOCTYPE enums | |
1320 | AVSC_API(void *, avs_pool_allocate)(AVS_ScriptEnvironment*, size_t nBytes, size_t alignment, int avs_alloc_type); | |
1321 | AVSC_API(void, avs_pool_free)(AVS_ScriptEnvironment*, void *ptr); | |
1322 | ||
1323 | // Interface V8 | |
1324 | // Returns TRUE (1) and the requested variable. If the method fails, returns 0 (FALSE) and does not touch 'val'. | |
1325 | // The returned AVS_Value *val value must be be released with avs_release_value only on success | |
1326 | // AVS_Value *val is not caller allocated | |
1327 | AVSC_API(int, avs_get_var_try)(AVS_ScriptEnvironment*, const char* name, AVS_Value* val); | |
1328 | ||
1329 | // Interface V8 | |
1330 | // Return the value of the requested variable. | |
1331 | // If the variable was not found or had the wrong type, | |
1332 | // return the supplied default value. | |
1333 | AVSC_API(int, avs_get_var_bool)(AVS_ScriptEnvironment*, const char* name, int def); | |
1334 | AVSC_API(int, avs_get_var_int)(AVS_ScriptEnvironment*, const char* name, int def); | |
1335 | AVSC_API(double, avs_get_var_double)(AVS_ScriptEnvironment*, const char* name, double def); | |
1336 | AVSC_API(const char*, avs_get_var_string)(AVS_ScriptEnvironment*, const char* name, const char* def); | |
1337 | AVSC_API(int64_t, avs_get_var_long)(AVS_ScriptEnvironment*, const char* name, int64_t def); | |
1338 | ||
1339 | #if defined(AVS_WINDOWS) | |
1340 | // The following stuff is only relevant for Windows DLL handling; Linux does it completely differently. | |
805 | 1341 | #ifdef AVSC_NO_DECLSPEC |
806 | // use LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport) | |
1342 | // This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport) | |
1343 | // When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct | |
1344 | // AVSC_INLINE functions which call onto an API functions should be treated specially (todo) | |
1345 | ||
807 | 1346 | /* |
808 | 1347 | The following functions needs to have been declared, probably from windows.h |
809 | 1348 | |
810 | 1349 | void* malloc(size_t) |
811 | 1350 | void free(void*); |
812 | 1351 | |
813 | HMODULE LoadLibrary(const char*); | |
1352 | HMODULE LoadLibraryA(const char*); | |
814 | 1353 | void* GetProcAddress(HMODULE, const char*); |
815 | 1354 | FreeLibrary(HMODULE); |
816 | 1355 | */ |
819 | 1358 | typedef struct AVS_Library AVS_Library; |
820 | 1359 | |
821 | 1360 | #define AVSC_DECLARE_FUNC(name) name##_func name |
1361 | ||
1362 | // AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx | |
1363 | // e.g. "AVSC_DECLARE_FUNC(avs_add_function);" | |
1364 | // is a shortcut for "avs_add_function_func avs_add_function;" | |
1365 | ||
1366 | // Note: AVSC_INLINE functions which call into API, | |
1367 | // are guarded by #ifndef AVSC_NO_DECLSPEC | |
1368 | // They should call the appropriate library-> API entry | |
822 | 1369 | |
823 | 1370 | struct AVS_Library { |
824 | 1371 | HMODULE handle; |
873 | 1420 | AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling); |
874 | 1421 | AVSC_DECLARE_FUNC(avs_bits_per_pixel); |
875 | 1422 | AVSC_DECLARE_FUNC(avs_bytes_from_pixels); |
876 | AVSC_DECLARE_FUNC(avs_row_size_p); | |
1423 | AVSC_DECLARE_FUNC(avs_row_size); | |
877 | 1424 | AVSC_DECLARE_FUNC(avs_bmp_size); |
878 | 1425 | AVSC_DECLARE_FUNC(avs_get_pitch_p); |
879 | 1426 | AVSC_DECLARE_FUNC(avs_get_row_size_p); |
881 | 1428 | AVSC_DECLARE_FUNC(avs_get_read_ptr_p); |
882 | 1429 | AVSC_DECLARE_FUNC(avs_is_writable); |
883 | 1430 | AVSC_DECLARE_FUNC(avs_get_write_ptr_p); |
1431 | ||
1432 | // Avisynth+ specific | |
1433 | // Note: these functions are simulated/use fallback to existing functions | |
1434 | AVSC_DECLARE_FUNC(avs_is_rgb48); | |
1435 | AVSC_DECLARE_FUNC(avs_is_rgb64); | |
1436 | AVSC_DECLARE_FUNC(avs_is_yuv444p16); | |
1437 | AVSC_DECLARE_FUNC(avs_is_yuv422p16); | |
1438 | AVSC_DECLARE_FUNC(avs_is_yuv420p16); | |
1439 | AVSC_DECLARE_FUNC(avs_is_y16); | |
1440 | AVSC_DECLARE_FUNC(avs_is_yuv444ps); | |
1441 | AVSC_DECLARE_FUNC(avs_is_yuv422ps); | |
1442 | AVSC_DECLARE_FUNC(avs_is_yuv420ps); | |
1443 | AVSC_DECLARE_FUNC(avs_is_y32); | |
1444 | AVSC_DECLARE_FUNC(avs_is_444); | |
1445 | AVSC_DECLARE_FUNC(avs_is_422); | |
1446 | AVSC_DECLARE_FUNC(avs_is_420); | |
1447 | AVSC_DECLARE_FUNC(avs_is_y); | |
1448 | AVSC_DECLARE_FUNC(avs_is_yuva); | |
1449 | AVSC_DECLARE_FUNC(avs_is_planar_rgb); | |
1450 | AVSC_DECLARE_FUNC(avs_is_planar_rgba); | |
1451 | AVSC_DECLARE_FUNC(avs_num_components); | |
1452 | AVSC_DECLARE_FUNC(avs_component_size); | |
1453 | AVSC_DECLARE_FUNC(avs_bits_per_component); | |
1454 | ||
1455 | /////////////////////////////////////////////////////////////////////////////// | |
1456 | // Avisynth+ new interface elements from interface version 8 | |
1457 | // avs_subframe_planar with alpha support | |
1458 | AVSC_DECLARE_FUNC(avs_subframe_planar_a); | |
1459 | ||
1460 | // frame properties | |
1461 | AVSC_DECLARE_FUNC(avs_copy_frame_props); | |
1462 | AVSC_DECLARE_FUNC(avs_get_frame_props_ro); | |
1463 | AVSC_DECLARE_FUNC(avs_get_frame_props_rw); | |
1464 | AVSC_DECLARE_FUNC(avs_prop_num_keys); | |
1465 | AVSC_DECLARE_FUNC(avs_prop_get_key); | |
1466 | AVSC_DECLARE_FUNC(avs_prop_num_elements); | |
1467 | AVSC_DECLARE_FUNC(avs_prop_get_type); | |
1468 | AVSC_DECLARE_FUNC(avs_prop_get_int); | |
1469 | AVSC_DECLARE_FUNC(avs_prop_get_float); | |
1470 | AVSC_DECLARE_FUNC(avs_prop_get_data); | |
1471 | AVSC_DECLARE_FUNC(avs_prop_get_data_size); | |
1472 | AVSC_DECLARE_FUNC(avs_prop_get_clip); | |
1473 | AVSC_DECLARE_FUNC(avs_prop_get_frame); | |
1474 | AVSC_DECLARE_FUNC(avs_prop_delete_key); | |
1475 | AVSC_DECLARE_FUNC(avs_prop_set_int); | |
1476 | AVSC_DECLARE_FUNC(avs_prop_set_float); | |
1477 | AVSC_DECLARE_FUNC(avs_prop_set_data); | |
1478 | AVSC_DECLARE_FUNC(avs_prop_set_clip); | |
1479 | AVSC_DECLARE_FUNC(avs_prop_set_frame); | |
1480 | ||
1481 | AVSC_DECLARE_FUNC(avs_prop_get_int_array); | |
1482 | AVSC_DECLARE_FUNC(avs_prop_get_float_array); | |
1483 | AVSC_DECLARE_FUNC(avs_prop_set_int_array); | |
1484 | AVSC_DECLARE_FUNC(avs_prop_set_float_array); | |
1485 | ||
1486 | AVSC_DECLARE_FUNC(avs_clear_map); | |
1487 | ||
1488 | // NewVideoFrame with frame properties | |
1489 | AVSC_DECLARE_FUNC(avs_new_video_frame_p); | |
1490 | AVSC_DECLARE_FUNC(avs_new_video_frame_p_a); | |
1491 | ||
1492 | AVSC_DECLARE_FUNC(avs_get_env_property); | |
1493 | ||
1494 | AVSC_DECLARE_FUNC(avs_get_var_try); | |
1495 | AVSC_DECLARE_FUNC(avs_get_var_bool); | |
1496 | AVSC_DECLARE_FUNC(avs_get_var_int); | |
1497 | AVSC_DECLARE_FUNC(avs_get_var_double); | |
1498 | AVSC_DECLARE_FUNC(avs_get_var_string); | |
1499 | AVSC_DECLARE_FUNC(avs_get_var_long); | |
1500 | ||
1501 | AVSC_DECLARE_FUNC(avs_pool_allocate); | |
1502 | AVSC_DECLARE_FUNC(avs_pool_free); | |
1503 | ||
1504 | // V9 | |
1505 | AVSC_DECLARE_FUNC(avs_is_property_writable); | |
1506 | AVSC_DECLARE_FUNC(avs_make_property_writable); | |
884 | 1507 | }; |
885 | 1508 | |
886 | 1509 | #undef AVSC_DECLARE_FUNC |
887 | 1510 | |
1511 | #ifdef AVS26_FALLBACK_SIMULATION | |
1512 | // Helper functions for fallback simulation | |
1513 | // Avisynth+ extensions do not exist in classic Avisynth so they are simulated | |
1514 | AVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p) | |
1515 | { | |
1516 | return 0; | |
1517 | } | |
1518 | ||
1519 | // Avisynth+ extensions do not exist in classic Avisynth so they are simulated | |
1520 | AVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p) | |
1521 | { | |
1522 | switch (p->pixel_type) { | |
1523 | case AVS_CS_UNKNOWN: | |
1524 | return 0; | |
1525 | case AVS_CS_RAW32: | |
1526 | case AVS_CS_Y8: | |
1527 | return 1; | |
1528 | case AVS_CS_BGR32: | |
1529 | return 4; // not planar but return the count | |
1530 | default: | |
1531 | return 3; | |
1532 | } | |
1533 | } | |
1534 | ||
1535 | // Avisynth+ extensions do not exist in classic Avisynth so they are simulated | |
1536 | AVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p) | |
1537 | { | |
1538 | return 1; | |
1539 | } | |
1540 | ||
1541 | // Avisynth+ extensions do not exist in classic Avisynth so they are simulated | |
1542 | AVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p) | |
1543 | { | |
1544 | return 8; | |
1545 | } | |
1546 | // End of helper functions for fallback simulation | |
1547 | #endif // AVS26_FALLBACK_SIMULATION | |
1548 | ||
1549 | // avs_load_library() allocates an array for API procedure entries | |
1550 | // reads and fills the entries with live procedure addresses. | |
1551 | // AVSC_INLINE helpers which are calling into API procedures are not treated here (todo) | |
888 | 1552 | |
889 | 1553 | AVSC_INLINE AVS_Library * avs_load_library() { |
890 | 1554 | AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library)); |
891 | 1555 | if (library == NULL) |
892 | 1556 | return NULL; |
893 | library->handle = LoadLibrary("avisynth"); | |
1557 | library->handle = LoadLibraryA("avisynth"); | |
894 | 1558 | if (library->handle == NULL) |
895 | 1559 | goto fail; |
896 | 1560 | |
901 | 1565 | if (library->name == NULL)\ |
902 | 1566 | goto fail;\ |
903 | 1567 | } |
1568 | ||
1569 | #ifdef AVS26_FALLBACK_SIMULATION | |
1570 | // When an API function is not loadable, let's try a replacement | |
1571 | // Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods | |
1572 | /* | |
1573 | Avisynth+ When method is missing (classic Avisynth) | |
1574 | avs_is_rgb48 constant false | |
1575 | avs_is_rgb64 constant false | |
1576 | avs_is_444 avs_is_yv24 | |
1577 | avs_is_422 avs_is_yv16 | |
1578 | avs_is_420 avs_is_yv12 | |
1579 | avs_is_y avs_is_y8 | |
1580 | avs_is_yuva constant false | |
1581 | avs_is_planar_rgb constant false | |
1582 | avs_is_planar_rgba constant false | |
1583 | avs_num_components special: avs_num_components_fake Y8:1 RGB32:4 else 3 | |
1584 | avs_component_size constant 1 (1 bytes/component) | |
1585 | avs_bits_per_component constant 8 (8 bits/component) | |
1586 | */ | |
1587 | ||
1588 | // try to load an alternative function | |
1589 | #define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\ | |
1590 | library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ | |
1591 | if (library->name == NULL)\ | |
1592 | library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\ | |
1593 | if (library->name == NULL)\ | |
1594 | goto fail;\ | |
1595 | } | |
1596 | ||
1597 | // try to assign a replacement function | |
1598 | #define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\ | |
1599 | library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ | |
1600 | if (library->name == NULL)\ | |
1601 | library->name = name2;\ | |
1602 | if (library->name == NULL)\ | |
1603 | goto fail;\ | |
1604 | } | |
1605 | #endif // AVS26_FALLBACK_SIMULATION | |
904 | 1606 | |
905 | 1607 | AVSC_LOAD_FUNC(avs_add_function); |
906 | 1608 | AVSC_LOAD_FUNC(avs_at_exit); |
924 | 1626 | AVSC_LOAD_FUNC(avs_make_writable); |
925 | 1627 | AVSC_LOAD_FUNC(avs_new_c_filter); |
926 | 1628 | AVSC_LOAD_FUNC(avs_new_video_frame_a); |
1629 | ||
1630 | ||
1631 | ||
927 | 1632 | AVSC_LOAD_FUNC(avs_release_clip); |
928 | 1633 | AVSC_LOAD_FUNC(avs_release_value); |
929 | 1634 | AVSC_LOAD_FUNC(avs_release_video_frame); |
952 | 1657 | AVSC_LOAD_FUNC(avs_get_plane_height_subsampling); |
953 | 1658 | AVSC_LOAD_FUNC(avs_bits_per_pixel); |
954 | 1659 | AVSC_LOAD_FUNC(avs_bytes_from_pixels); |
955 | AVSC_LOAD_FUNC(avs_row_size_p); | |
1660 | AVSC_LOAD_FUNC(avs_row_size); | |
956 | 1661 | AVSC_LOAD_FUNC(avs_bmp_size); |
957 | 1662 | AVSC_LOAD_FUNC(avs_get_pitch_p); |
958 | 1663 | AVSC_LOAD_FUNC(avs_get_row_size_p); |
961 | 1666 | AVSC_LOAD_FUNC(avs_is_writable); |
962 | 1667 | AVSC_LOAD_FUNC(avs_get_write_ptr_p); |
963 | 1668 | |
1669 | // Avisynth+ specific | |
1670 | #ifdef AVS26_FALLBACK_SIMULATION | |
1671 | // replace with fallback fn when does not exist | |
1672 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false); | |
1673 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false); | |
1674 | AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24); | |
1675 | AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16); | |
1676 | AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12); | |
1677 | AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8); | |
1678 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false); | |
1679 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false); | |
1680 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false); | |
1681 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback); | |
1682 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback); | |
1683 | AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback); | |
1684 | #else | |
1685 | // Avisynth+ specific | |
1686 | AVSC_LOAD_FUNC(avs_is_rgb48); | |
1687 | AVSC_LOAD_FUNC(avs_is_rgb64); | |
1688 | AVSC_LOAD_FUNC(avs_is_444); | |
1689 | AVSC_LOAD_FUNC(avs_is_422); | |
1690 | AVSC_LOAD_FUNC(avs_is_420); | |
1691 | AVSC_LOAD_FUNC(avs_is_y); | |
1692 | AVSC_LOAD_FUNC(avs_is_yuva); | |
1693 | AVSC_LOAD_FUNC(avs_is_planar_rgb); | |
1694 | AVSC_LOAD_FUNC(avs_is_planar_rgba); | |
1695 | AVSC_LOAD_FUNC(avs_num_components); | |
1696 | AVSC_LOAD_FUNC(avs_component_size); | |
1697 | AVSC_LOAD_FUNC(avs_bits_per_component); | |
1698 | #endif | |
1699 | // Avisynth+ interface V8, no backward compatible simulation | |
1700 | AVSC_LOAD_FUNC(avs_subframe_planar_a); | |
1701 | // frame properties | |
1702 | AVSC_LOAD_FUNC(avs_copy_frame_props); | |
1703 | AVSC_LOAD_FUNC(avs_get_frame_props_ro); | |
1704 | AVSC_LOAD_FUNC(avs_get_frame_props_rw); | |
1705 | AVSC_LOAD_FUNC(avs_prop_num_keys); | |
1706 | AVSC_LOAD_FUNC(avs_prop_get_key); | |
1707 | AVSC_LOAD_FUNC(avs_prop_num_elements); | |
1708 | AVSC_LOAD_FUNC(avs_prop_get_type); | |
1709 | AVSC_LOAD_FUNC(avs_prop_get_int); | |
1710 | AVSC_LOAD_FUNC(avs_prop_get_float); | |
1711 | AVSC_LOAD_FUNC(avs_prop_get_data); | |
1712 | AVSC_LOAD_FUNC(avs_prop_get_data_size); | |
1713 | AVSC_LOAD_FUNC(avs_prop_get_clip); | |
1714 | AVSC_LOAD_FUNC(avs_prop_get_frame); | |
1715 | AVSC_LOAD_FUNC(avs_prop_delete_key); | |
1716 | AVSC_LOAD_FUNC(avs_prop_set_int); | |
1717 | AVSC_LOAD_FUNC(avs_prop_set_float); | |
1718 | AVSC_LOAD_FUNC(avs_prop_set_data); | |
1719 | AVSC_LOAD_FUNC(avs_prop_set_clip); | |
1720 | AVSC_LOAD_FUNC(avs_prop_set_frame); | |
1721 | ||
1722 | AVSC_LOAD_FUNC(avs_prop_get_int_array); | |
1723 | AVSC_LOAD_FUNC(avs_prop_get_float_array); | |
1724 | AVSC_LOAD_FUNC(avs_prop_set_int_array); | |
1725 | AVSC_LOAD_FUNC(avs_prop_set_float_array); | |
1726 | ||
1727 | AVSC_LOAD_FUNC(avs_clear_map); | |
1728 | ||
1729 | // NewVideoFrame with frame properties | |
1730 | AVSC_LOAD_FUNC(avs_new_video_frame_p); | |
1731 | AVSC_LOAD_FUNC(avs_new_video_frame_p_a); | |
1732 | ||
1733 | AVSC_LOAD_FUNC(avs_get_env_property); | |
1734 | ||
1735 | AVSC_LOAD_FUNC(avs_get_var_try); | |
1736 | AVSC_LOAD_FUNC(avs_get_var_bool); | |
1737 | AVSC_LOAD_FUNC(avs_get_var_int); | |
1738 | AVSC_LOAD_FUNC(avs_get_var_double); | |
1739 | AVSC_LOAD_FUNC(avs_get_var_string); | |
1740 | AVSC_LOAD_FUNC(avs_get_var_long); | |
1741 | ||
1742 | AVSC_LOAD_FUNC(avs_pool_allocate); | |
1743 | AVSC_LOAD_FUNC(avs_pool_free); | |
1744 | ||
964 | 1745 | #undef __AVSC_STRINGIFY |
965 | 1746 | #undef AVSC_STRINGIFY |
966 | 1747 | #undef AVSC_LOAD_FUNC |
1748 | #undef AVSC_LOAD_FUNC_FALLBACK | |
1749 | #undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED | |
967 | 1750 | |
968 | 1751 | return library; |
969 | 1752 | |
980 | 1763 | } |
981 | 1764 | #endif |
982 | 1765 | |
983 | #endif | |
1766 | #endif // AVS_WINDOWS | |
1767 | ||
1768 | #endif |
0 | // Avisynth C Interface Version 0.20 | |
1 | // Copyright 2003 Kevin Atkinson | |
2 | ||
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. | |
7 | // | |
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. | |
12 | // | |
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., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | |
16 | // http://www.gnu.org/copyleft/gpl.html . | |
17 | // | |
18 | // As a special exception, I give you permission to link to the | |
19 | // Avisynth C interface with independent modules that communicate with | |
20 | // the Avisynth C interface solely through the interfaces defined in | |
21 | // avisynth_c.h, regardless of the license terms of these independent | |
22 | // modules, and to copy and distribute the resulting combined work | |
23 | // under terms of your choice, provided that every copy of the | |
24 | // combined work is accompanied by a complete copy of the source code | |
25 | // of the Avisynth C interface and Avisynth itself (with the version | |
26 | // used to produce the combined work), being distributed under the | |
27 | // terms of the GNU General Public License plus this exception. An | |
28 | // independent module is a module which is not derived from or based | |
29 | // on Avisynth C Interface, such as 3rd-party filters, import and | |
30 | // export plugins, or graphical user interfaces. | |
31 | ||
32 | #ifndef __AVXSYNTH_C__ | |
33 | #define __AVXSYNTH_C__ | |
34 | ||
35 | #include <stdarg.h> | |
36 | #include <stdint.h> | |
37 | ||
38 | typedef int64_t INT64; | |
39 | #define __stdcall | |
40 | #define __declspec(x) | |
41 | ||
42 | #ifdef __cplusplus | |
43 | # define EXTERN_C extern "C" | |
44 | #else | |
45 | # define EXTERN_C | |
46 | #endif | |
47 | ||
48 | #define AVSC_USE_STDCALL 1 | |
49 | ||
50 | #ifndef AVSC_USE_STDCALL | |
51 | # define AVSC_CC __cdecl | |
52 | #else | |
53 | # define AVSC_CC __stdcall | |
54 | #endif | |
55 | ||
56 | #define AVSC_INLINE static __inline | |
57 | ||
58 | #ifdef AVISYNTH_C_EXPORTS | |
59 | # define AVSC_EXPORT EXTERN_C | |
60 | # define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name | |
61 | #else | |
62 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) | |
63 | # ifndef AVSC_NO_DECLSPEC | |
64 | # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name | |
65 | # else | |
66 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) | |
67 | # endif | |
68 | #endif | |
69 | ||
70 | ||
71 | ///////////////////////////////////////////////////////////////////// | |
72 | // | |
73 | // Constants | |
74 | // | |
75 | ||
76 | #ifndef __AVXSYNTH_H__ | |
77 | enum { AVISYNTH_INTERFACE_VERSION = 3 }; | |
78 | #endif | |
79 | ||
80 | enum {AVS_SAMPLE_INT8 = 1<<0, | |
81 | AVS_SAMPLE_INT16 = 1<<1, | |
82 | AVS_SAMPLE_INT24 = 1<<2, | |
83 | AVS_SAMPLE_INT32 = 1<<3, | |
84 | AVS_SAMPLE_FLOAT = 1<<4}; | |
85 | ||
86 | enum {AVS_PLANAR_Y=1<<0, | |
87 | AVS_PLANAR_U=1<<1, | |
88 | AVS_PLANAR_V=1<<2, | |
89 | AVS_PLANAR_ALIGNED=1<<3, | |
90 | AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED, | |
91 | AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED, | |
92 | AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED}; | |
93 | ||
94 | // Colorspace properties. | |
95 | enum {AVS_CS_BGR = 1<<28, | |
96 | AVS_CS_YUV = 1<<29, | |
97 | AVS_CS_INTERLEAVED = 1<<30, | |
98 | AVS_CS_PLANAR = 1<<31}; | |
99 | ||
100 | // Specific colorformats | |
101 | enum { | |
102 | AVS_CS_UNKNOWN = 0, | |
103 | AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
104 | AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED, | |
105 | AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED, | |
106 | AVS_CS_YV12 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR, // y-v-u, planar | |
107 | AVS_CS_I420 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR, // y-u-v, planar | |
108 | AVS_CS_IYUV = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR // same as above | |
109 | }; | |
110 | ||
111 | enum { | |
112 | AVS_IT_BFF = 1<<0, | |
113 | AVS_IT_TFF = 1<<1, | |
114 | AVS_IT_FIELDBASED = 1<<2}; | |
115 | ||
116 | enum { | |
117 | AVS_FILTER_TYPE=1, | |
118 | AVS_FILTER_INPUT_COLORSPACE=2, | |
119 | AVS_FILTER_OUTPUT_TYPE=9, | |
120 | AVS_FILTER_NAME=4, | |
121 | AVS_FILTER_AUTHOR=5, | |
122 | AVS_FILTER_VERSION=6, | |
123 | AVS_FILTER_ARGS=7, | |
124 | AVS_FILTER_ARGS_INFO=8, | |
125 | AVS_FILTER_ARGS_DESCRIPTION=10, | |
126 | AVS_FILTER_DESCRIPTION=11}; | |
127 | ||
128 | enum { //SUBTYPES | |
129 | AVS_FILTER_TYPE_AUDIO=1, | |
130 | AVS_FILTER_TYPE_VIDEO=2, | |
131 | AVS_FILTER_OUTPUT_TYPE_SAME=3, | |
132 | AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4}; | |
133 | ||
134 | enum { | |
135 | AVS_CACHE_NOTHING=0, | |
136 | AVS_CACHE_RANGE=1, | |
137 | AVS_CACHE_ALL=2, | |
138 | AVS_CACHE_AUDIO=3, | |
139 | AVS_CACHE_AUDIO_NONE=4, | |
140 | AVS_CACHE_AUDIO_AUTO=5 | |
141 | }; | |
142 | ||
143 | #define AVS_FRAME_ALIGN 16 | |
144 | ||
145 | typedef struct AVS_Clip AVS_Clip; | |
146 | typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment; | |
147 | ||
148 | ///////////////////////////////////////////////////////////////////// | |
149 | // | |
150 | // AVS_VideoInfo | |
151 | // | |
152 | ||
153 | // AVS_VideoInfo is layed out identicly to VideoInfo | |
154 | typedef struct AVS_VideoInfo { | |
155 | int width, height; // width=0 means no video | |
156 | unsigned fps_numerator, fps_denominator; | |
157 | int num_frames; | |
158 | ||
159 | int pixel_type; | |
160 | ||
161 | int audio_samples_per_second; // 0 means no audio | |
162 | int sample_type; | |
163 | INT64 num_audio_samples; | |
164 | int nchannels; | |
165 | ||
166 | // Imagetype properties | |
167 | ||
168 | int image_type; | |
169 | } AVS_VideoInfo; | |
170 | ||
171 | // useful functions of the above | |
172 | AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p) | |
173 | { return (p->width!=0); } | |
174 | ||
175 | AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p) | |
176 | { return (p->audio_samples_per_second!=0); } | |
177 | ||
178 | AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p) | |
179 | { return !!(p->pixel_type&AVS_CS_BGR); } | |
180 | ||
181 | AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) | |
182 | { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties | |
183 | ||
184 | AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p) | |
185 | { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; } | |
186 | ||
187 | AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) | |
188 | { return !!(p->pixel_type&AVS_CS_YUV ); } | |
189 | ||
190 | AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) | |
191 | { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } | |
192 | ||
193 | AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo * p) | |
194 | { return ((p->pixel_type & AVS_CS_YV12) == AVS_CS_YV12)||((p->pixel_type & AVS_CS_I420) == AVS_CS_I420); } | |
195 | ||
196 | AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo * p, int c_space) | |
197 | { return ((p->pixel_type & c_space) == c_space); } | |
198 | ||
199 | AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) | |
200 | { return ((p->pixel_type & property)==property ); } | |
201 | ||
202 | AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p) | |
203 | { return !!(p->pixel_type & AVS_CS_PLANAR); } | |
204 | ||
205 | AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p) | |
206 | { return !!(p->image_type & AVS_IT_FIELDBASED); } | |
207 | ||
208 | AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p) | |
209 | { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); } | |
210 | ||
211 | AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p) | |
212 | { return !!(p->image_type & AVS_IT_BFF); } | |
213 | ||
214 | AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p) | |
215 | { return !!(p->image_type & AVS_IT_TFF); } | |
216 | ||
217 | AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo * p) | |
218 | { | |
219 | switch (p->pixel_type) { | |
220 | case AVS_CS_BGR24: return 24; | |
221 | case AVS_CS_BGR32: return 32; | |
222 | case AVS_CS_YUY2: return 16; | |
223 | case AVS_CS_YV12: | |
224 | case AVS_CS_I420: return 12; | |
225 | default: return 0; | |
226 | } | |
227 | } | |
228 | AVSC_INLINE int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels) | |
229 | { return pixels * (avs_bits_per_pixel(p)>>3); } // Will work on planar images, but will return only luma planes | |
230 | ||
231 | AVSC_INLINE int avs_row_size(const AVS_VideoInfo * p) | |
232 | { return avs_bytes_from_pixels(p,p->width); } // Also only returns first plane on planar images | |
233 | ||
234 | AVSC_INLINE int avs_bmp_size(const AVS_VideoInfo * vi) | |
235 | { if (avs_is_planar(vi)) {int p = vi->height * ((avs_row_size(vi)+3) & ~3); p+=p>>1; return p; } return vi->height * ((avs_row_size(vi)+3) & ~3); } | |
236 | ||
237 | AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p) | |
238 | { return p->audio_samples_per_second; } | |
239 | ||
240 | ||
241 | AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p) | |
242 | { | |
243 | switch (p->sample_type) { | |
244 | case AVS_SAMPLE_INT8: return sizeof(signed char); | |
245 | case AVS_SAMPLE_INT16: return sizeof(signed short); | |
246 | case AVS_SAMPLE_INT24: return 3; | |
247 | case AVS_SAMPLE_INT32: return sizeof(signed int); | |
248 | case AVS_SAMPLE_FLOAT: return sizeof(float); | |
249 | default: return 0; | |
250 | } | |
251 | } | |
252 | AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p) | |
253 | { return p->nchannels*avs_bytes_per_channel_sample(p);} | |
254 | ||
255 | AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames) | |
256 | { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } | |
257 | ||
258 | AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) | |
259 | { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); } | |
260 | ||
261 | AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes) | |
262 | { return bytes / avs_bytes_per_audio_sample(p); } | |
263 | ||
264 | AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) | |
265 | { return samples * avs_bytes_per_audio_sample(p); } | |
266 | ||
267 | AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p) | |
268 | { return p->nchannels; } | |
269 | ||
270 | AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p) | |
271 | { return p->sample_type;} | |
272 | ||
273 | // useful mutator | |
274 | AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property) | |
275 | { p->image_type|=property; } | |
276 | ||
277 | AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property) | |
278 | { p->image_type&=~property; } | |
279 | ||
280 | AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased) | |
281 | { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; } | |
282 | ||
283 | AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator) | |
284 | { | |
285 | unsigned x=numerator, y=denominator; | |
286 | while (y) { // find gcd | |
287 | unsigned t = x%y; x = y; y = t; | |
288 | } | |
289 | p->fps_numerator = numerator/x; | |
290 | p->fps_denominator = denominator/x; | |
291 | } | |
292 | ||
293 | AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y) | |
294 | { | |
295 | return (x->pixel_type == y->pixel_type) | |
296 | || (avs_is_yv12(x) && avs_is_yv12(y)); | |
297 | } | |
298 | ||
299 | ///////////////////////////////////////////////////////////////////// | |
300 | // | |
301 | // AVS_VideoFrame | |
302 | // | |
303 | ||
304 | // VideoFrameBuffer holds information about a memory block which is used | |
305 | // for video data. For efficiency, instances of this class are not deleted | |
306 | // when the refcount reaches zero; instead they're stored in a linked list | |
307 | // to be reused. The instances are deleted when the corresponding AVS | |
308 | // file is closed. | |
309 | ||
310 | // AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer | |
311 | // DO NOT USE THIS STRUCTURE DIRECTLY | |
312 | typedef struct AVS_VideoFrameBuffer { | |
313 | unsigned char * data; | |
314 | int data_size; | |
315 | // sequence_number is incremented every time the buffer is changed, so | |
316 | // that stale views can tell they're no longer valid. | |
317 | long sequence_number; | |
318 | ||
319 | long refcount; | |
320 | } AVS_VideoFrameBuffer; | |
321 | ||
322 | // VideoFrame holds a "window" into a VideoFrameBuffer. | |
323 | ||
324 | // AVS_VideoFrame is layed out identicly to IVideoFrame | |
325 | // DO NOT USE THIS STRUCTURE DIRECTLY | |
326 | typedef struct AVS_VideoFrame { | |
327 | int refcount; | |
328 | AVS_VideoFrameBuffer * vfb; | |
329 | int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture. | |
330 | } AVS_VideoFrame; | |
331 | ||
332 | // Access functions for AVS_VideoFrame | |
333 | AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { | |
334 | return p->pitch;} | |
335 | ||
336 | AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) { | |
337 | switch (plane) { | |
338 | case AVS_PLANAR_U: case AVS_PLANAR_V: return p->pitchUV;} | |
339 | return p->pitch;} | |
340 | ||
341 | AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { | |
342 | return p->row_size; } | |
343 | ||
344 | AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame * p, int plane) { | |
345 | int r; | |
346 | switch (plane) { | |
347 | case AVS_PLANAR_U: case AVS_PLANAR_V: | |
348 | if (p->pitchUV) return p->row_size>>1; | |
349 | else return 0; | |
350 | case AVS_PLANAR_U_ALIGNED: case AVS_PLANAR_V_ALIGNED: | |
351 | if (p->pitchUV) { | |
352 | r = ((p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)) )>>1; // Aligned rowsize | |
353 | if (r < p->pitchUV) | |
354 | return r; | |
355 | return p->row_size>>1; | |
356 | } else return 0; | |
357 | case AVS_PLANAR_Y_ALIGNED: | |
358 | r = (p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)); // Aligned rowsize | |
359 | if (r <= p->pitch) | |
360 | return r; | |
361 | return p->row_size; | |
362 | } | |
363 | return p->row_size; | |
364 | } | |
365 | ||
366 | AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { | |
367 | return p->height;} | |
368 | ||
369 | AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame * p, int plane) { | |
370 | switch (plane) { | |
371 | case AVS_PLANAR_U: case AVS_PLANAR_V: | |
372 | if (p->pitchUV) return p->height>>1; | |
373 | return 0; | |
374 | } | |
375 | return p->height;} | |
376 | ||
377 | AVSC_INLINE const unsigned char* avs_get_read_ptr(const AVS_VideoFrame * p) { | |
378 | return p->vfb->data + p->offset;} | |
379 | ||
380 | AVSC_INLINE const unsigned char* avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane) | |
381 | { | |
382 | switch (plane) { | |
383 | case AVS_PLANAR_U: return p->vfb->data + p->offsetU; | |
384 | case AVS_PLANAR_V: return p->vfb->data + p->offsetV; | |
385 | default: return p->vfb->data + p->offset;} | |
386 | } | |
387 | ||
388 | AVSC_INLINE int avs_is_writable(const AVS_VideoFrame * p) { | |
389 | return (p->refcount == 1 && p->vfb->refcount == 1);} | |
390 | ||
391 | AVSC_INLINE unsigned char* avs_get_write_ptr(const AVS_VideoFrame * p) | |
392 | { | |
393 | if (avs_is_writable(p)) { | |
394 | ++p->vfb->sequence_number; | |
395 | return p->vfb->data + p->offset; | |
396 | } else | |
397 | return 0; | |
398 | } | |
399 | ||
400 | AVSC_INLINE unsigned char* avs_get_write_ptr_p(const AVS_VideoFrame * p, int plane) | |
401 | { | |
402 | if (plane==AVS_PLANAR_Y && avs_is_writable(p)) { | |
403 | ++p->vfb->sequence_number; | |
404 | return p->vfb->data + p->offset; | |
405 | } else if (plane==AVS_PLANAR_Y) { | |
406 | return 0; | |
407 | } else { | |
408 | switch (plane) { | |
409 | case AVS_PLANAR_U: return p->vfb->data + p->offsetU; | |
410 | case AVS_PLANAR_V: return p->vfb->data + p->offsetV; | |
411 | default: return p->vfb->data + p->offset; | |
412 | } | |
413 | } | |
414 | } | |
415 | ||
416 | #if defined __cplusplus | |
417 | extern "C" | |
418 | { | |
419 | #endif // __cplusplus | |
420 | AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *); | |
421 | // makes a shallow copy of a video frame | |
422 | AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *); | |
423 | #if defined __cplusplus | |
424 | } | |
425 | #endif // __cplusplus | |
426 | ||
427 | #ifndef AVSC_NO_DECLSPEC | |
428 | AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f) | |
429 | {avs_release_video_frame(f);} | |
430 | AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f) | |
431 | {return avs_copy_video_frame(f);} | |
432 | #endif | |
433 | ||
434 | ///////////////////////////////////////////////////////////////////// | |
435 | // | |
436 | // AVS_Value | |
437 | // | |
438 | ||
439 | // Treat AVS_Value as a fat pointer. That is use avs_copy_value | |
440 | // and avs_release_value appropiaty as you would if AVS_Value was | |
441 | // a pointer. | |
442 | ||
443 | // To maintain source code compatibility with future versions of the | |
444 | // avisynth_c API don't use the AVS_Value directly. Use the helper | |
445 | // functions below. | |
446 | ||
447 | // AVS_Value is layed out identicly to AVSValue | |
448 | typedef struct AVS_Value AVS_Value; | |
449 | struct AVS_Value { | |
450 | short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong | |
451 | // for some function e'rror | |
452 | short array_size; | |
453 | union { | |
454 | void * clip; // do not use directly, use avs_take_clip | |
455 | char boolean; | |
456 | int integer; | |
457 | INT64 integer64; // match addition of __int64 to avxplugin.h | |
458 | float floating_pt; | |
459 | const char * string; | |
460 | const AVS_Value * array; | |
461 | } d; | |
462 | }; | |
463 | ||
464 | // AVS_Value should be initilized with avs_void. | |
465 | // Should also set to avs_void after the value is released | |
466 | // with avs_copy_value. Consider it the equalvent of setting | |
467 | // a pointer to NULL | |
468 | static const AVS_Value avs_void = {'v'}; | |
469 | ||
470 | AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src); | |
471 | AVSC_API(void, avs_release_value)(AVS_Value); | |
472 | ||
473 | AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; } | |
474 | AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; } | |
475 | AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; } | |
476 | AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; } | |
477 | AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; } | |
478 | AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; } | |
479 | AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; } | |
480 | AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; } | |
481 | ||
482 | #if defined __cplusplus | |
483 | extern "C" | |
484 | { | |
485 | #endif // __cplusplus | |
486 | AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); | |
487 | AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); | |
488 | #if defined __cplusplus | |
489 | } | |
490 | #endif // __cplusplus | |
491 | ||
492 | AVSC_INLINE int avs_as_bool(AVS_Value v) | |
493 | { return v.d.boolean; } | |
494 | AVSC_INLINE int avs_as_int(AVS_Value v) | |
495 | { return v.d.integer; } | |
496 | AVSC_INLINE const char * avs_as_string(AVS_Value v) | |
497 | { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; } | |
498 | AVSC_INLINE double avs_as_float(AVS_Value v) | |
499 | { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; } | |
500 | AVSC_INLINE const char * avs_as_error(AVS_Value v) | |
501 | { return avs_is_error(v) ? v.d.string : 0; } | |
502 | AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v) | |
503 | { return v.d.array; } | |
504 | AVSC_INLINE int avs_array_size(AVS_Value v) | |
505 | { return avs_is_array(v) ? v.array_size : 1; } | |
506 | AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index) | |
507 | { return avs_is_array(v) ? v.d.array[index] : v; } | |
508 | ||
509 | // only use these functions on am AVS_Value that does not already have | |
510 | // an active value. Remember, treat AVS_Value as a fat pointer. | |
511 | AVSC_INLINE AVS_Value avs_new_value_bool(int v0) | |
512 | { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; } | |
513 | AVSC_INLINE AVS_Value avs_new_value_int(int v0) | |
514 | { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; } | |
515 | AVSC_INLINE AVS_Value avs_new_value_string(const char * v0) | |
516 | { AVS_Value v; v.type = 's'; v.d.string = v0; return v; } | |
517 | AVSC_INLINE AVS_Value avs_new_value_float(float v0) | |
518 | { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;} | |
519 | AVSC_INLINE AVS_Value avs_new_value_error(const char * v0) | |
520 | { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; } | |
521 | #ifndef AVSC_NO_DECLSPEC | |
522 | AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) | |
523 | { AVS_Value v; avs_set_to_clip(&v, v0); return v; } | |
524 | #endif | |
525 | AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) | |
526 | { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; } | |
527 | ||
528 | ///////////////////////////////////////////////////////////////////// | |
529 | // | |
530 | // AVS_Clip | |
531 | // | |
532 | #if defined __cplusplus | |
533 | extern "C" | |
534 | { | |
535 | #endif // __cplusplus | |
536 | AVSC_API(void, avs_release_clip)(AVS_Clip *); | |
537 | AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *); | |
538 | ||
539 | AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error | |
540 | ||
541 | AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *); | |
542 | ||
543 | AVSC_API(int, avs_get_version)(AVS_Clip *); | |
544 | ||
545 | AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n); | |
546 | // The returned video frame must be released with avs_release_video_frame | |
547 | ||
548 | AVSC_API(int, avs_get_parity)(AVS_Clip *, int n); | |
549 | // return field parity if field_based, else parity of first field in frame | |
550 | ||
551 | AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf, | |
552 | INT64 start, INT64 count); | |
553 | // start and count are in samples | |
554 | ||
555 | AVSC_API(int, avs_set_cache_hints)(AVS_Clip *, | |
556 | int cachehints, size_t frame_range); | |
557 | #if defined __cplusplus | |
558 | } | |
559 | #endif // __cplusplus | |
560 | ||
561 | // This is the callback type used by avs_add_function | |
562 | typedef AVS_Value (AVSC_CC * AVS_ApplyFunc) | |
563 | (AVS_ScriptEnvironment *, AVS_Value args, void * user_data); | |
564 | ||
565 | typedef struct AVS_FilterInfo AVS_FilterInfo; | |
566 | struct AVS_FilterInfo | |
567 | { | |
568 | // these members should not be modified outside of the AVS_ApplyFunc callback | |
569 | AVS_Clip * child; | |
570 | AVS_VideoInfo vi; | |
571 | AVS_ScriptEnvironment * env; | |
572 | AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n); | |
573 | int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n); | |
574 | int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, | |
575 | INT64 start, INT64 count); | |
576 | int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, | |
577 | int frame_range); | |
578 | void (AVSC_CC * free_filter)(AVS_FilterInfo *); | |
579 | ||
580 | // Should be set when ever there is an error to report. | |
581 | // It is cleared before any of the above methods are called | |
582 | const char * error; | |
583 | // this is to store whatever and may be modified at will | |
584 | void * user_data; | |
585 | }; | |
586 | ||
587 | // Create a new filter | |
588 | // fi is set to point to the AVS_FilterInfo so that you can | |
589 | // modify it once it is initilized. | |
590 | // store_child should generally be set to true. If it is not | |
591 | // set than ALL methods (the function pointers) must be defined | |
592 | // If it is set than you do not need to worry about freeing the child | |
593 | // clip. | |
594 | #if defined __cplusplus | |
595 | extern "C" | |
596 | { | |
597 | #endif // __cplusplus | |
598 | AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e, | |
599 | AVS_FilterInfo * * fi, | |
600 | AVS_Value child, int store_child); | |
601 | #if defined __cplusplus | |
602 | } | |
603 | #endif // __cplusplus | |
604 | ||
605 | ||
606 | ///////////////////////////////////////////////////////////////////// | |
607 | // | |
608 | // AVS_ScriptEnvironment | |
609 | // | |
610 | ||
611 | // For GetCPUFlags. These are backwards-compatible with those in VirtualDub. | |
612 | enum { | |
613 | /* slowest CPU to support extension */ | |
614 | AVS_CPU_FORCE = 0x01, // N/A | |
615 | AVS_CPU_FPU = 0x02, // 386/486DX | |
616 | AVS_CPU_MMX = 0x04, // P55C, K6, PII | |
617 | AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon | |
618 | AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP | |
619 | AVS_CPU_SSE2 = 0x20, // PIV, Hammer | |
620 | AVS_CPU_3DNOW = 0x40, // K6-2 | |
621 | AVS_CPU_3DNOW_EXT = 0x80, // Athlon | |
622 | AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, | |
623 | // which only Hammer will have anyway) | |
624 | }; | |
625 | ||
626 | #if defined __cplusplus | |
627 | extern "C" | |
628 | { | |
629 | #endif // __cplusplus | |
630 | AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error | |
631 | ||
632 | AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *); | |
633 | AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version); | |
634 | ||
635 | AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length); | |
636 | AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...); | |
637 | ||
638 | AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val); | |
639 | // note: val is really a va_list; I hope everyone typedefs va_list to a pointer | |
640 | ||
641 | AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *, | |
642 | const char * name, const char * params, | |
643 | AVS_ApplyFunc apply, void * user_data); | |
644 | ||
645 | AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name); | |
646 | ||
647 | AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name, | |
648 | AVS_Value args, const char** arg_names); | |
649 | // The returned value must be be released with avs_release_value | |
650 | ||
651 | AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name); | |
652 | // The returned value must be be released with avs_release_value | |
653 | ||
654 | AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val); | |
655 | ||
656 | AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val); | |
657 | ||
658 | //void avs_push_context(AVS_ScriptEnvironment *, int level=0); | |
659 | //void avs_pop_context(AVS_ScriptEnvironment *); | |
660 | ||
661 | AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *, | |
662 | const AVS_VideoInfo * vi, int align); | |
663 | // align should be at least 16 | |
664 | #if defined __cplusplus | |
665 | } | |
666 | #endif // __cplusplus | |
667 | ||
668 | #ifndef AVSC_NO_DECLSPEC | |
669 | AVSC_INLINE | |
670 | AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, | |
671 | const AVS_VideoInfo * vi) | |
672 | {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} | |
673 | ||
674 | AVSC_INLINE | |
675 | AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, | |
676 | const AVS_VideoInfo * vi) | |
677 | {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} | |
678 | #endif | |
679 | ||
680 | #if defined __cplusplus | |
681 | extern "C" | |
682 | { | |
683 | #endif // __cplusplus | |
684 | AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf); | |
685 | ||
686 | AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, unsigned char* dstp, int dst_pitch, const unsigned char* srcp, int src_pitch, int row_size, int height); | |
687 | ||
688 | typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env); | |
689 | AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data); | |
690 | ||
691 | AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height); | |
692 | // The returned video frame must be be released | |
693 | ||
694 | AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem); | |
695 | ||
696 | AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir); | |
697 | ||
698 | // avisynth.dll exports this; it's a way to use it as a library, without | |
699 | // writing an AVS script or without going through AVIFile. | |
700 | AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version); | |
701 | #if defined __cplusplus | |
702 | } | |
703 | #endif // __cplusplus | |
704 | ||
705 | // this symbol is the entry point for the plugin and must | |
706 | // be defined | |
707 | AVSC_EXPORT | |
708 | const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env); | |
709 | ||
710 | ||
711 | #if defined __cplusplus | |
712 | extern "C" | |
713 | { | |
714 | #endif // __cplusplus | |
715 | AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *); | |
716 | ||
717 | ||
718 | AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); | |
719 | // The returned video frame must be be released | |
720 | #if defined __cplusplus | |
721 | } | |
722 | #endif // __cplusplus | |
723 | ||
724 | #endif //__AVXSYNTH_C__ |
0 | 0 | /***************************************************************************** |
1 | 1 | * intel_dispatcher.h: intel compiler cpu dispatcher override |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2014-2021 x264 project | |
3 | * Copyright (C) 2014-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * filters.c: common filter functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Diogo Franco <diogomfranco@gmail.com> |
6 | 6 | * Steven Walters <kemuri9@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * filters.h: common filter functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Diogo Franco <diogomfranco@gmail.com> |
6 | 6 | * Steven Walters <kemuri9@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * cache.c: cache video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * crop.c: crop video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * James Darnley <james.darnley@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * depth.c: bit-depth conversion video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Oskar Arvidsson <oskar@irock.se> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * fix_vfr_pts.c: vfr pts fixing video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * internal.c: video filter utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * internal.h: video filter utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * resize.c: resize video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
127 | 127 | flag = SWS_AREA; |
128 | 128 | else if( !strcasecmp( name, "bicublin" ) ) |
129 | 129 | flag = SWS_BICUBLIN; |
130 | else if( !strcasecmp( name, "guass" ) ) | |
130 | else if( !strcasecmp( name, "gauss" ) ) | |
131 | 131 | flag = SWS_GAUSS; |
132 | 132 | else if( !strcasecmp( name, "sinc" ) ) |
133 | 133 | flag = SWS_SINC; |
0 | 0 | /***************************************************************************** |
1 | 1 | * select_every.c: select-every video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * source.c: source video filter |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * video.c: video filters |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * video.h: video filters |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * avs.c: avisynth input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * Anton Mitrofanov <BugMaster@narod.ru> |
25 | 25 | |
26 | 26 | #include "input.h" |
27 | 27 | |
28 | #if USE_AVXSYNTH | |
29 | #include <dlfcn.h> | |
30 | #if SYS_MACOSX | |
31 | #define avs_open() dlopen( "libavxsynth.dylib", RTLD_NOW ) | |
32 | #else | |
33 | #define avs_open() dlopen( "libavxsynth.so", RTLD_NOW ) | |
34 | #endif | |
35 | #define avs_close dlclose | |
36 | #define avs_address dlsym | |
37 | #else | |
28 | #if SYS_WINDOWS || SYS_CYGWIN | |
29 | #include <windows.h> | |
38 | 30 | #define avs_open() LoadLibraryW( L"avisynth" ) |
39 | 31 | #define avs_close FreeLibrary |
40 | 32 | #define avs_address GetProcAddress |
33 | #else | |
34 | #include <dlfcn.h> | |
35 | #if SYS_MACOSX | |
36 | #define avs_open() dlopen( "libavisynth.dylib", RTLD_NOW ) | |
37 | #else | |
38 | #define avs_open() dlopen( "libavisynth.so", RTLD_NOW ) | |
39 | #endif | |
40 | #define avs_close dlclose | |
41 | #define avs_address dlsym | |
41 | 42 | #endif |
42 | 43 | |
43 | 44 | #define AVSC_NO_DECLSPEC |
44 | 45 | #undef EXTERN_C |
45 | #if USE_AVXSYNTH | |
46 | #include "extras/avxsynth_c.h" | |
47 | #else | |
48 | 46 | #include "extras/avisynth_c.h" |
49 | #endif | |
50 | 47 | #define AVSC_DECLARE_FUNC(name) name##_func name |
51 | 48 | |
52 | 49 | #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "avs", __VA_ARGS__ ) |
97 | 94 | AVSC_DECLARE_FUNC( avs_release_value ); |
98 | 95 | AVSC_DECLARE_FUNC( avs_release_video_frame ); |
99 | 96 | AVSC_DECLARE_FUNC( avs_take_clip ); |
100 | #if !USE_AVXSYNTH | |
97 | AVSC_DECLARE_FUNC( avs_is_yv24 ); | |
98 | AVSC_DECLARE_FUNC( avs_is_yv16 ); | |
99 | AVSC_DECLARE_FUNC( avs_is_yv12 ); | |
100 | AVSC_DECLARE_FUNC( avs_is_yv411 ); | |
101 | AVSC_DECLARE_FUNC( avs_is_y8 ); | |
102 | AVSC_DECLARE_FUNC( avs_get_pitch_p ); | |
103 | AVSC_DECLARE_FUNC( avs_get_read_ptr_p ); | |
101 | 104 | // AviSynth+ extension |
102 | 105 | AVSC_DECLARE_FUNC( avs_is_rgb48 ); |
103 | 106 | AVSC_DECLARE_FUNC( avs_is_rgb64 ); |
105 | 108 | AVSC_DECLARE_FUNC( avs_is_yuv422p16 ); |
106 | 109 | AVSC_DECLARE_FUNC( avs_is_yuv420p16 ); |
107 | 110 | AVSC_DECLARE_FUNC( avs_is_y16 ); |
108 | AVSC_DECLARE_FUNC( avs_is_yuv444ps ); | |
109 | AVSC_DECLARE_FUNC( avs_is_yuv422ps ); | |
110 | AVSC_DECLARE_FUNC( avs_is_yuv420ps ); | |
111 | AVSC_DECLARE_FUNC( avs_is_y32 ); | |
112 | 111 | AVSC_DECLARE_FUNC( avs_is_444 ); |
113 | 112 | AVSC_DECLARE_FUNC( avs_is_422 ); |
114 | 113 | AVSC_DECLARE_FUNC( avs_is_420 ); |
115 | 114 | AVSC_DECLARE_FUNC( avs_is_y ); |
116 | AVSC_DECLARE_FUNC( avs_is_yuva ); | |
117 | AVSC_DECLARE_FUNC( avs_is_planar_rgb ); | |
118 | AVSC_DECLARE_FUNC( avs_is_planar_rgba ); | |
119 | AVSC_DECLARE_FUNC( avs_num_components ); | |
120 | AVSC_DECLARE_FUNC( avs_component_size ); | |
121 | AVSC_DECLARE_FUNC( avs_bits_per_component ); | |
122 | #endif | |
123 | 115 | } func; |
124 | 116 | } avs_hnd_t; |
125 | 117 | |
141 | 133 | LOAD_AVS_FUNC( avs_release_value, 0 ); |
142 | 134 | LOAD_AVS_FUNC( avs_release_video_frame, 0 ); |
143 | 135 | LOAD_AVS_FUNC( avs_take_clip, 0 ); |
144 | #if !USE_AVXSYNTH | |
136 | LOAD_AVS_FUNC( avs_is_yv24, 1 ); | |
137 | LOAD_AVS_FUNC( avs_is_yv16, 1 ); | |
138 | LOAD_AVS_FUNC( avs_is_yv12, 1 ); | |
139 | LOAD_AVS_FUNC( avs_is_yv411, 1 ); | |
140 | LOAD_AVS_FUNC( avs_is_y8, 1 ); | |
141 | LOAD_AVS_FUNC( avs_get_pitch_p, 1 ); | |
142 | LOAD_AVS_FUNC( avs_get_read_ptr_p, 1 ); | |
145 | 143 | // AviSynth+ extension |
146 | 144 | LOAD_AVS_FUNC( avs_is_rgb48, 1 ); |
147 | 145 | LOAD_AVS_FUNC_ALIAS( avs_is_rgb48, "_avs_is_rgb48@4", 1 ); |
151 | 149 | LOAD_AVS_FUNC( avs_is_yuv422p16, 1 ); |
152 | 150 | LOAD_AVS_FUNC( avs_is_yuv420p16, 1 ); |
153 | 151 | LOAD_AVS_FUNC( avs_is_y16, 1 ); |
154 | LOAD_AVS_FUNC( avs_is_yuv444ps, 1 ); | |
155 | LOAD_AVS_FUNC( avs_is_yuv422ps, 1 ); | |
156 | LOAD_AVS_FUNC( avs_is_yuv420ps, 1 ); | |
157 | LOAD_AVS_FUNC( avs_is_y32, 1 ); | |
158 | 152 | LOAD_AVS_FUNC( avs_is_444, 1 ); |
159 | 153 | LOAD_AVS_FUNC( avs_is_422, 1 ); |
160 | 154 | LOAD_AVS_FUNC( avs_is_420, 1 ); |
161 | 155 | LOAD_AVS_FUNC( avs_is_y, 1 ); |
162 | LOAD_AVS_FUNC( avs_is_yuva, 1 ); | |
163 | LOAD_AVS_FUNC( avs_is_planar_rgb, 1 ); | |
164 | LOAD_AVS_FUNC( avs_is_planar_rgba, 1 ); | |
165 | LOAD_AVS_FUNC( avs_num_components, 1 ); | |
166 | LOAD_AVS_FUNC( avs_component_size, 1 ); | |
167 | LOAD_AVS_FUNC( avs_bits_per_component, 1 ); | |
168 | #endif | |
169 | 156 | return 0; |
170 | 157 | fail: |
171 | 158 | avs_close( h->library ); |
173 | 160 | return -1; |
174 | 161 | } |
175 | 162 | |
176 | /* AvxSynth doesn't have yv24, yv16, yv411, or y8, so disable them. */ | |
177 | #if USE_AVXSYNTH | |
178 | #define avs_is_yv24( vi ) (0) | |
179 | #define avs_is_yv16( vi ) (0) | |
180 | #define avs_is_yv411( vi ) (0) | |
181 | #define avs_is_y8( vi ) (0) | |
182 | /* AvxSynth doesn't support AviSynth+ pixel types. */ | |
183 | #define AVS_IS_AVISYNTHPLUS (0) | |
184 | #define AVS_IS_420( vi ) (0) | |
185 | #define AVS_IS_422( vi ) (0) | |
186 | #define AVS_IS_444( vi ) (0) | |
187 | #define AVS_IS_RGB48( vi ) (0) | |
188 | #define AVS_IS_RGB64( vi ) (0) | |
189 | #define AVS_IS_YUV420P16( vi ) (0) | |
190 | #define AVS_IS_YUV422P16( vi ) (0) | |
191 | #define AVS_IS_YUV444P16( vi ) (0) | |
192 | #define AVS_IS_Y( vi ) (0) | |
193 | #define AVS_IS_Y16( vi ) (0) | |
194 | #else | |
163 | #define AVS_IS_YV24( vi ) (h->func.avs_is_yv24 ? h->func.avs_is_yv24( vi ) : avs_is_yv24( vi )) | |
164 | #define AVS_IS_YV16( vi ) (h->func.avs_is_yv16 ? h->func.avs_is_yv16( vi ) : avs_is_yv16( vi )) | |
165 | #define AVS_IS_YV12( vi ) (h->func.avs_is_yv12 ? h->func.avs_is_yv12( vi ) : avs_is_yv12( vi )) | |
166 | #define AVS_IS_YV411( vi ) (h->func.avs_is_yv411 ? h->func.avs_is_yv411( vi ) : avs_is_yv411( vi )) | |
167 | #define AVS_IS_Y8( vi ) (h->func.avs_is_y8 ? h->func.avs_is_y8( vi ) : avs_is_y8( vi )) | |
168 | #define AVS_GET_PITCH_P( p, plane ) (h->func.avs_get_pitch_p ? h->func.avs_get_pitch_p( p, plane ) : avs_get_pitch_p( p, plane )) | |
169 | #define AVS_GET_READ_PTR_P( p, plane ) (h->func.avs_get_read_ptr_p ? h->func.avs_get_read_ptr_p( p, plane ) : avs_get_read_ptr_p( p, plane )) | |
170 | ||
195 | 171 | #define AVS_IS_AVISYNTHPLUS (h->func.avs_is_420 && h->func.avs_is_422 && h->func.avs_is_444) |
196 | #define AVS_IS_420( vi ) (h->func.avs_is_420 ? h->func.avs_is_420( vi ) : avs_is_yv12( vi )) | |
197 | #define AVS_IS_422( vi ) (h->func.avs_is_422 ? h->func.avs_is_422( vi ) : avs_is_yv16( vi )) | |
198 | #define AVS_IS_444( vi ) (h->func.avs_is_444 ? h->func.avs_is_444( vi ) : avs_is_yv24( vi )) | |
172 | #define AVS_IS_420( vi ) (h->func.avs_is_420 ? h->func.avs_is_420( vi ) : AVS_IS_YV12( vi )) | |
173 | #define AVS_IS_422( vi ) (h->func.avs_is_422 ? h->func.avs_is_422( vi ) : AVS_IS_YV16( vi )) | |
174 | #define AVS_IS_444( vi ) (h->func.avs_is_444 ? h->func.avs_is_444( vi ) : AVS_IS_YV24( vi )) | |
199 | 175 | #define AVS_IS_RGB48( vi ) (h->func.avs_is_rgb48 && h->func.avs_is_rgb48( vi )) |
200 | 176 | #define AVS_IS_RGB64( vi ) (h->func.avs_is_rgb64 && h->func.avs_is_rgb64( vi )) |
201 | 177 | #define AVS_IS_YUV420P16( vi ) (h->func.avs_is_yuv420p16 && h->func.avs_is_yuv420p16( vi )) |
202 | 178 | #define AVS_IS_YUV422P16( vi ) (h->func.avs_is_yuv422p16 && h->func.avs_is_yuv422p16( vi )) |
203 | 179 | #define AVS_IS_YUV444P16( vi ) (h->func.avs_is_yuv444p16 && h->func.avs_is_yuv444p16( vi )) |
204 | #define AVS_IS_Y( vi ) (h->func.avs_is_y ? h->func.avs_is_y( vi ) : avs_is_y8( vi )) | |
180 | #define AVS_IS_Y( vi ) (h->func.avs_is_y ? h->func.avs_is_y( vi ) : AVS_IS_Y8( vi )) | |
205 | 181 | #define AVS_IS_Y16( vi ) (h->func.avs_is_y16 && h->func.avs_is_y16( vi )) |
206 | #endif | |
207 | 182 | |
208 | 183 | /* generate a filter sequence to try based on the filename extension */ |
209 | 184 | static void avs_build_filter_sequence( char *filename_ext, const char *filter[AVS_MAX_SEQUENCE+1] ) |
210 | 185 | { |
211 | 186 | int i = 0; |
212 | #if USE_AVXSYNTH | |
213 | const char *all_purpose[] = { "FFVideoSource", 0 }; | |
214 | #else | |
187 | #if SYS_WINDOWS || SYS_CYGWIN | |
215 | 188 | const char *all_purpose[] = { "FFmpegSource2", "DSS2", "DirectShowSource", 0 }; |
216 | 189 | if( !strcasecmp( filename_ext, "avi" ) ) |
217 | 190 | filter[i++] = "AVISource"; |
219 | 192 | filter[i++] = "MPEG2Source"; |
220 | 193 | if( !strcasecmp( filename_ext, "dga" ) ) |
221 | 194 | filter[i++] = "AVCSource"; |
195 | #else | |
196 | const char *all_purpose[] = { "FFVideoSource", 0 }; | |
222 | 197 | #endif |
223 | 198 | for( int j = 0; all_purpose[j] && i < AVS_MAX_SEQUENCE; j++ ) |
224 | 199 | filter[i++] = all_purpose[j]; |
235 | 210 | |
236 | 211 | static float get_avs_version( avs_hnd_t *h ) |
237 | 212 | { |
238 | /* AvxSynth has its version defined starting at 4.0, even though it's based on | |
239 | AviSynth 2.5.8. This is troublesome for get_avs_version and working around | |
240 | the new colorspaces in 2.6. So if AvxSynth is detected, explicitly define | |
241 | the version as 2.58. */ | |
242 | #if USE_AVXSYNTH | |
243 | return 2.58f; | |
244 | #else | |
245 | 213 | FAIL_IF_ERROR( !h->func.avs_function_exists( h->env, "VersionNumber" ), "VersionNumber does not exist\n" ); |
246 | 214 | AVS_Value ver = h->func.avs_invoke( h->env, "VersionNumber", avs_new_value_array( NULL, 0 ), NULL ); |
247 | 215 | FAIL_IF_ERROR( avs_is_error( ver ), "unable to determine avisynth version: %s\n", avs_as_error( ver ) ); |
249 | 217 | float ret = avs_as_float( ver ); |
250 | 218 | h->func.avs_release_value( ver ); |
251 | 219 | return ret; |
252 | #endif | |
253 | 220 | } |
254 | 221 | |
255 | 222 | #ifdef _WIN32 |
501 | 468 | info->csp = X264_CSP_BGR | X264_CSP_VFLIP; |
502 | 469 | else if( AVS_IS_YUV444P16( vi ) ) |
503 | 470 | info->csp = X264_CSP_I444 | X264_CSP_HIGH_DEPTH; |
504 | else if( avs_is_yv24( vi ) ) | |
471 | else if( AVS_IS_YV24( vi ) ) | |
505 | 472 | info->csp = X264_CSP_I444; |
506 | 473 | else if( AVS_IS_YUV422P16( vi ) ) |
507 | 474 | info->csp = X264_CSP_I422 | X264_CSP_HIGH_DEPTH; |
508 | else if( avs_is_yv16( vi ) ) | |
475 | else if( AVS_IS_YV16( vi ) ) | |
509 | 476 | info->csp = X264_CSP_I422; |
510 | 477 | else if( AVS_IS_YUV420P16( vi ) ) |
511 | 478 | info->csp = X264_CSP_I420 | X264_CSP_HIGH_DEPTH; |
512 | else if( avs_is_yv12( vi ) ) | |
479 | else if( AVS_IS_YV12( vi ) ) | |
513 | 480 | info->csp = X264_CSP_I420; |
514 | 481 | else if( AVS_IS_Y16( vi ) ) |
515 | 482 | info->csp = X264_CSP_I400 | X264_CSP_HIGH_DEPTH; |
516 | else if( avs_is_y8( vi ) ) | |
483 | else if( AVS_IS_Y8( vi ) ) | |
517 | 484 | info->csp = X264_CSP_I400; |
518 | 485 | else if( avs_is_yuy2( vi ) ) |
519 | 486 | info->csp = X264_CSP_YUYV; |
520 | 487 | #if HAVE_SWSCALE |
521 | else if( avs_is_yv411( vi ) ) | |
488 | else if( AVS_IS_YV411( vi ) ) | |
522 | 489 | info->csp = AV_PIX_FMT_YUV411P | X264_CSP_OTHER; |
523 | 490 | #endif |
524 | 491 | else |
562 | 529 | for( int i = 0; i < pic->img.planes; i++ ) |
563 | 530 | { |
564 | 531 | /* explicitly cast away the const attribute to avoid a warning */ |
565 | pic->img.plane[i] = (uint8_t*)avs_get_read_ptr_p( frm, plane[i] ); | |
566 | pic->img.stride[i] = avs_get_pitch_p( frm, plane[i] ); | |
532 | pic->img.plane[i] = (uint8_t*)AVS_GET_READ_PTR_P( frm, plane[i] ); | |
533 | pic->img.stride[i] = AVS_GET_PITCH_P( frm, plane[i] ); | |
567 | 534 | } |
568 | 535 | return 0; |
569 | 536 | } |
0 | 0 | /***************************************************************************** |
1 | 1 | * ffms.c: ffmpegsource input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mike Gurlitz <mike.gurlitz@gmail.com> |
6 | 6 | * Steven Walters <kemuri9@gmail.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * input.c: common input functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Steven Walters <kemuri9@gmail.com> |
6 | 6 | * Henrik Gramner <henrik@gramner.com> |
0 | 0 | /***************************************************************************** |
1 | 1 | * input.h: file input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * lavf.c: libavformat input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mike Gurlitz <mike.gurlitz@gmail.com> |
6 | 6 | * Steven Walters <kemuri9@gmail.com> |
40 | 40 | AVFormatContext *lavf; |
41 | 41 | AVCodecContext *lavc; |
42 | 42 | AVFrame *frame; |
43 | AVPacket *pkt; | |
43 | 44 | int stream_id; |
44 | 45 | int next_frame; |
45 | 46 | int vfr_input; |
95 | 96 | return 0; |
96 | 97 | } |
97 | 98 | |
98 | AVPacket pkt; | |
99 | av_init_packet( &pkt ); | |
100 | pkt.data = NULL; | |
101 | pkt.size = 0; | |
99 | AVPacket *pkt = h->pkt; | |
102 | 100 | |
103 | 101 | while( i_frame >= h->next_frame ) |
104 | 102 | { |
108 | 106 | { |
109 | 107 | if( ret == AVERROR(EAGAIN) ) |
110 | 108 | { |
111 | while( !(ret = av_read_frame( h->lavf, &pkt )) && pkt.stream_index != h->stream_id ) | |
112 | av_packet_unref( &pkt ); | |
109 | while( !(ret = av_read_frame( h->lavf, pkt )) && pkt->stream_index != h->stream_id ) | |
110 | av_packet_unref( pkt ); | |
113 | 111 | |
114 | 112 | if( ret ) |
115 | 113 | ret = avcodec_send_packet( h->lavc, NULL ); |
116 | 114 | else |
117 | 115 | { |
118 | ret = avcodec_send_packet( h->lavc, &pkt ); | |
119 | av_packet_unref( &pkt ); | |
116 | ret = avcodec_send_packet( h->lavc, pkt ); | |
117 | av_packet_unref( pkt ); | |
120 | 118 | } |
121 | 119 | } |
122 | 120 | else if( ret == AVERROR_EOF ) |
174 | 172 | h->frame = av_frame_alloc(); |
175 | 173 | if( !h->frame ) |
176 | 174 | return -1; |
175 | h->pkt = av_packet_alloc(); | |
176 | if( !h->pkt ) | |
177 | return -1; | |
177 | 178 | |
178 | 179 | /* if resolution was passed in, place it and colorspace into options. this allows raw video support */ |
179 | 180 | AVDictionary *options = NULL; |
263 | 264 | lavf_hnd_t *h = handle; |
264 | 265 | avcodec_free_context( &h->lavc ); |
265 | 266 | avformat_close_input( &h->lavf ); |
267 | av_packet_free( &h->pkt ); | |
266 | 268 | av_frame_free( &h->frame ); |
267 | 269 | free( h ); |
268 | 270 | return 0; |
0 | 0 | /***************************************************************************** |
1 | 1 | * raw.c: raw input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * thread.c: threaded input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
62 | 62 | h->next_args->status = 0; |
63 | 63 | h->frame_total = info->num_frames; |
64 | 64 | |
65 | if( x264_threadpool_init( &h->pool, 1, NULL, NULL ) ) | |
65 | if( x264_threadpool_init( &h->pool, 1 ) ) | |
66 | 66 | return -1; |
67 | 67 | |
68 | 68 | *p_handle = h; |
0 | 0 | /***************************************************************************** |
1 | 1 | * timecode.c: timecode file input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2010-2021 x264 project | |
3 | * Copyright (C) 2010-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com> |
6 | 6 | * |
99 | 99 | double *timecodes = NULL; |
100 | 100 | double *fpss = NULL; |
101 | 101 | |
102 | ret = fscanf( tcfile_in, "# timecode format v%d", &tcfv ); | |
103 | FAIL_IF_ERROR( ret != 1 || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ); | |
102 | ret = fgets( buff, sizeof(buff), tcfile_in ) != NULL && | |
103 | (sscanf( buff, "# timecode format v%d", &tcfv ) == 1 || sscanf( buff, "# timestamp format v%d", &tcfv ) == 1); | |
104 | FAIL_IF_ERROR( !ret || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ); | |
104 | 105 | #define NO_TIMECODE_LINE (buff[0] == '#' || buff[0] == '\n' || buff[0] == '\r') |
105 | 106 | if( tcfv == 1 ) |
106 | 107 | { |
0 | 0 | /***************************************************************************** |
1 | 1 | * y4m.c: y4m input |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * flv.c: flv muxer |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Kieran Kunhya <kieran@kunhya.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * flv_bytestream.c: flv muxer utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Kieran Kunhya <kieran@kunhya.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * flv_bytestream.h: flv muxer utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Kieran Kunhya <kieran@kunhya.com> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * matroska.c: matroska muxer |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mike Matsnev <mike@haali.su> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * matroska_ebml.c: matroska muxer utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mike Matsnev <mike@haali.su> |
6 | 6 | * |
59 | 59 | int64_t cluster_tc_scaled; |
60 | 60 | int64_t frame_tc, max_frame_tc; |
61 | 61 | |
62 | char wrote_header, in_frame, keyframe, skippable; | |
62 | int8_t wrote_header, in_frame, keyframe, skippable; | |
63 | 63 | }; |
64 | 64 | |
65 | 65 | static mk_context *mk_create_context( mk_writer *w, mk_context *parent, unsigned id ) |
110 | 110 | c->d_max = dn; |
111 | 111 | } |
112 | 112 | |
113 | memcpy( (char*)c->data + c->d_cur, data, size ); | |
113 | memcpy( (uint8_t*)c->data + c->d_cur, data, size ); | |
114 | 114 | |
115 | 115 | c->d_cur = ns; |
116 | 116 | |
119 | 119 | |
120 | 120 | static int mk_write_id( mk_context *c, unsigned id ) |
121 | 121 | { |
122 | unsigned char c_id[4] = { id >> 24, id >> 16, id >> 8, id }; | |
122 | uint8_t c_id[4] = { id >> 24, id >> 16, id >> 8, id }; | |
123 | 123 | |
124 | 124 | if( c_id[0] ) |
125 | 125 | return mk_append_context_data( c, c_id, 4 ); |
132 | 132 | |
133 | 133 | static int mk_write_size( mk_context *c, unsigned size ) |
134 | 134 | { |
135 | unsigned char c_size[5] = { 0x08, size >> 24, size >> 16, size >> 8, size }; | |
135 | uint8_t c_size[5] = { 0x08, size >> 24, size >> 16, size >> 8, size }; | |
136 | 136 | |
137 | 137 | if( size < 0x7f ) |
138 | 138 | { |
159 | 159 | |
160 | 160 | static int mk_flush_context_id( mk_context *c ) |
161 | 161 | { |
162 | unsigned char ff = 0xff; | |
162 | uint8_t ff = 0xff; | |
163 | 163 | |
164 | 164 | if( !c->id ) |
165 | 165 | return 0; |
248 | 248 | return 0; |
249 | 249 | } |
250 | 250 | |
251 | static int mk_write_uint( mk_context *c, unsigned id, int64_t ui ) | |
252 | { | |
253 | unsigned char c_ui[8] = { ui >> 56, ui >> 48, ui >> 40, ui >> 32, ui >> 24, ui >> 16, ui >> 8, ui }; | |
251 | static int mk_write_uint( mk_context *c, unsigned id, uint64_t ui ) | |
252 | { | |
253 | uint8_t c_ui[8] = { ui >> 56, ui >> 48, ui >> 40, ui >> 32, ui >> 24, ui >> 16, ui >> 8, ui }; | |
254 | 254 | unsigned i = 0; |
255 | 255 | |
256 | 256 | CHECK( mk_write_id( c, id ) ); |
266 | 266 | union |
267 | 267 | { |
268 | 268 | float f; |
269 | unsigned u; | |
269 | uint32_t u; | |
270 | 270 | } u; |
271 | unsigned char c_f[4]; | |
271 | uint8_t c_f[4]; | |
272 | 272 | |
273 | 273 | u.f = f; |
274 | 274 | c_f[0] = u.u >> 24; |
407 | 407 | { |
408 | 408 | int64_t delta; |
409 | 409 | unsigned fsize; |
410 | unsigned char c_delta_flags[3]; | |
410 | uint8_t c_delta_flags[3]; | |
411 | 411 | |
412 | 412 | if( !w->in_frame ) |
413 | 413 | return 0; |
434 | 434 | CHECK( mk_write_size( w->cluster, fsize + 4 ) ); // Size |
435 | 435 | CHECK( mk_write_size( w->cluster, 1 ) ); // TrackNumber |
436 | 436 | |
437 | c_delta_flags[0] = delta >> 8; | |
438 | c_delta_flags[1] = delta; | |
437 | c_delta_flags[0] = (uint8_t)(delta >> 8); | |
438 | c_delta_flags[1] = (uint8_t)delta; | |
439 | 439 | c_delta_flags[2] = (w->keyframe << 7) | w->skippable; |
440 | 440 | CHECK( mk_append_context_data( w->cluster, c_delta_flags, 3 ) ); // Timecode, Flags |
441 | 441 | if( w->frame ) |
0 | 0 | /***************************************************************************** |
1 | 1 | * matroska_ebml.h: matroska muxer utilities |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2005-2021 x264 project | |
3 | * Copyright (C) 2005-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Mike Matsnev <mike@haali.su> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * mp4.c: mp4 muxer |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * mp4_lsmash.c: mp4 muxer using L-SMASH |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * output.h: x264 file output modules |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * raw.c: raw muxer |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | ;***************************************************************************** |
1 | 1 | ;* checkasm-a.asm: assembly check tool |
2 | 2 | ;***************************************************************************** |
3 | ;* Copyright (C) 2008-2021 x264 project | |
3 | ;* Copyright (C) 2008-2022 x264 project | |
4 | 4 | ;* |
5 | 5 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | ;* Henrik Gramner <henrik@gramner.com> |
0 | 0 | /**************************************************************************** |
1 | 1 | * checkasm-aarch64.S: assembly check tool |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Martin Storsjo <martin@martin.st> |
6 | 6 | * |
0 | 0 | /**************************************************************************** |
1 | 1 | * checkasm-arm.S: assembly check tool |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2015-2021 x264 project | |
3 | * Copyright (C) 2015-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Martin Storsjo <martin@martin.st> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * checkasm.c: assembly check tool |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
47 | 47 | /* pbuf3, pbuf4: point to buf3, buf4, just for type convenience */ |
48 | 48 | static pixel *pbuf3, *pbuf4; |
49 | 49 | |
50 | #if BIT_DEPTH > 8 | |
51 | #define FMT_PIXEL "%04x" | |
52 | #else | |
53 | #define FMT_PIXEL "%02x" | |
54 | #endif | |
55 | ||
56 | #define X264_ISDIGIT(x) isdigit((unsigned char)(x)) | |
57 | ||
50 | 58 | static int quiet = 0; |
51 | 59 | |
52 | 60 | #define report( name ) { \ |
141 | 149 | { |
142 | 150 | if( !*sa && !*sb ) |
143 | 151 | return 0; |
144 | if( isdigit( *sa ) && isdigit( *sb ) && isdigit( sa[1] ) != isdigit( sb[1] ) ) | |
145 | return isdigit( sa[1] ) - isdigit( sb[1] ); | |
152 | if( X264_ISDIGIT( *sa ) && X264_ISDIGIT( *sb ) && X264_ISDIGIT( sa[1] ) != X264_ISDIGIT( sb[1] ) ) | |
153 | return X264_ISDIGIT( sa[1] ) - X264_ISDIGIT( sb[1] ); | |
146 | 154 | if( *sa != *sb ) |
147 | 155 | return *sa - *sb; |
148 | 156 | } |
261 | 269 | * assembly function through x264_checkasm_call with added dummy arguments which forces all |
262 | 270 | * real arguments to be passed on the stack and not in registers. For 32-bit argument the |
263 | 271 | * upper half of the 64-bit register location on the stack will now contain junk. Note that |
264 | * this is dependant on compiler behaviour and that interrupts etc. at the wrong time may | |
272 | * this is dependent on compiler behaviour and that interrupts etc. at the wrong time may | |
265 | 273 | * overwrite the junk written to the stack so there's no guarantee that it will always |
266 | 274 | * detect all functions that assumes zero-extension. |
267 | 275 | */ |
650 | 658 | ok = 0; \ |
651 | 659 | fprintf( stderr, #name" [FAILED]\n" ); \ |
652 | 660 | for( int j=0; j<16; j++ ) \ |
653 | fprintf( stderr, "%02x ", fdec1[(j&3)+(j>>2)*FDEC_STRIDE] ); \ | |
661 | fprintf( stderr, FMT_PIXEL" ", fdec1[(j&3)+(j>>2)*FDEC_STRIDE] ); \ | |
654 | 662 | fprintf( stderr, "\n" ); \ |
655 | 663 | for( int j=0; j<16; j++ ) \ |
656 | fprintf( stderr, "%02x ", fdec2[(j&3)+(j>>2)*FDEC_STRIDE] ); \ | |
664 | fprintf( stderr, FMT_PIXEL" ", fdec2[(j&3)+(j>>2)*FDEC_STRIDE] ); \ | |
657 | 665 | fprintf( stderr, "\n" ); \ |
658 | 666 | break; \ |
659 | 667 | } \ |
710 | 718 | for( int j=0; j<8; j++ ) \ |
711 | 719 | { \ |
712 | 720 | for( int k=0; k<8; k++ ) \ |
713 | fprintf( stderr, "%02x ", fdec1[k+j*FDEC_STRIDE] ); \ | |
721 | fprintf( stderr, FMT_PIXEL" ", fdec1[k+j*FDEC_STRIDE] ); \ | |
714 | 722 | fprintf( stderr, "\n" ); \ |
715 | 723 | } \ |
716 | 724 | fprintf( stderr, "\n" ); \ |
717 | 725 | for( int j=0; j<8; j++ ) \ |
718 | 726 | { \ |
719 | 727 | for( int k=0; k<8; k++ ) \ |
720 | fprintf( stderr, "%02x ", fdec2[k+j*FDEC_STRIDE] ); \ | |
728 | fprintf( stderr, FMT_PIXEL" ", fdec2[k+j*FDEC_STRIDE] ); \ | |
721 | 729 | fprintf( stderr, "\n" ); \ |
722 | 730 | } \ |
723 | 731 | fprintf( stderr, "\n" ); \ |
839 | 847 | if( mvn_c != mvn_a || memcmp( mvs_c, mvs_a, mvn_c*sizeof(*mvs_c) ) ) |
840 | 848 | { |
841 | 849 | ok = 0; |
842 | printf( "thresh: %d\n", thresh ); | |
843 | printf( "c%d: ", i&3 ); | |
850 | fprintf( stderr, "thresh: %d\n", thresh ); | |
851 | fprintf( stderr, "c%d: ", i&3 ); | |
844 | 852 | for( int j = 0; j < mvn_c; j++ ) |
845 | printf( "%d ", mvs_c[j] ); | |
846 | printf( "\na%d: ", i&3 ); | |
853 | fprintf( stderr, "%d ", mvs_c[j] ); | |
854 | fprintf( stderr, "\na%d: ", i&3 ); | |
847 | 855 | for( int j = 0; j < mvn_a; j++ ) |
848 | printf( "%d ", mvs_a[j] ); | |
849 | printf( "\n\n" ); | |
856 | fprintf( stderr, "%d ", mvs_a[j] ); | |
857 | fprintf( stderr, "\n\n" ); | |
850 | 858 | } |
851 | 859 | } |
852 | 860 | report( "esa ads:" ); |
880 | 888 | h->param.analyse.i_luma_deadzone[0] = 0; |
881 | 889 | h->param.analyse.i_luma_deadzone[1] = 0; |
882 | 890 | h->param.analyse.b_transform_8x8 = 1; |
883 | for( int i = 0; i < 6; i++ ) | |
891 | for( int i = 0; i < 8; i++ ) | |
884 | 892 | h->sps->scaling_list[i] = x264_cqm_flat16; |
885 | 893 | x264_cqm_init( h ); |
886 | 894 | x264_quant_init( h, 0, &qf ); |
922 | 930 | ok = 0; \ |
923 | 931 | fprintf( stderr, #name " [FAILED]\n" ); \ |
924 | 932 | for( int k = 0; k < size; k++ )\ |
925 | printf( "%d ", ((dctcoef*)t1)[k] );\ | |
926 | printf("\n");\ | |
933 | fprintf( stderr, "%d ", ((dctcoef*)t1)[k] );\ | |
934 | fprintf( stderr, "\n" );\ | |
927 | 935 | for( int k = 0; k < size; k++ )\ |
928 | printf( "%d ", ((dctcoef*)t2)[k] );\ | |
929 | printf("\n");\ | |
936 | fprintf( stderr, "%d ", ((dctcoef*)t2)[k] );\ | |
937 | fprintf( stderr, "\n" );\ | |
930 | 938 | break; \ |
931 | 939 | } \ |
932 | 940 | call_c( dct_c.name, t1, enc, dec ); \ |
1159 | 1167 | call_a( zigzag_asm[interlace].name, t2, dct, buf4 ); \ |
1160 | 1168 | if( memcmp( t1, t2, size*sizeof(dctcoef) ) || memcmp( buf3, buf4, 10 ) ) \ |
1161 | 1169 | { \ |
1162 | ok = 0; printf("%d: %d %d %d %d\n%d %d %d %d\n\n",memcmp( t1, t2, size*sizeof(dctcoef) ),buf3[0], buf3[1], buf3[8], buf3[9], buf4[0], buf4[1], buf4[8], buf4[9]);break;\ | |
1170 | ok = 0; \ | |
1171 | fprintf( stderr, "%d: %d %d %d %d\n%d %d %d %d\n\n", memcmp( t1, t2, size*sizeof(dctcoef) ), buf3[0], buf3[1], buf3[8], buf3[9], buf4[0], buf4[1], buf4[8], buf4[9] ); \ | |
1172 | break; \ | |
1163 | 1173 | } \ |
1164 | 1174 | } \ |
1165 | 1175 | } |
1667 | 1677 | ok = 0; |
1668 | 1678 | fprintf( stderr, "hpel filter differs at plane %c line %d\n", "hvc"[i], j ); |
1669 | 1679 | for( int k = 0; k < 48; k++ ) |
1670 | printf( "%02x%s", dstc[i][j*64+k], (k+1)&3 ? "" : " " ); | |
1671 | printf( "\n" ); | |
1680 | fprintf( stderr, FMT_PIXEL"%s", dstc[i][j*64+k], (k+1)&3 ? "" : " " ); | |
1681 | fprintf( stderr, "\n" ); | |
1672 | 1682 | for( int k = 0; k < 48; k++ ) |
1673 | printf( "%02x%s", dsta[i][j*64+k], (k+1)&3 ? "" : " " ); | |
1674 | printf( "\n" ); | |
1683 | fprintf( stderr, FMT_PIXEL"%s", dsta[i][j*64+k], (k+1)&3 ? "" : " " ); | |
1684 | fprintf( stderr, "\n" ); | |
1675 | 1685 | break; |
1676 | 1686 | } |
1677 | 1687 | report( "hpel filter :" ); |
1697 | 1707 | ok = 0; |
1698 | 1708 | fprintf( stderr, "frame_init_lowres differs at plane %d line %d\n", j, i ); |
1699 | 1709 | for( int k = 0; k < w; k++ ) |
1700 | printf( "%d ", dstc[j][k+i*stride_lowres] ); | |
1701 | printf( "\n" ); | |
1710 | fprintf( stderr, "%d ", dstc[j][k+i*stride_lowres] ); | |
1711 | fprintf( stderr, "\n" ); | |
1702 | 1712 | for( int k = 0; k < w; k++ ) |
1703 | printf( "%d ", dsta[j][k+i*stride_lowres] ); | |
1704 | printf( "\n" ); | |
1713 | fprintf( stderr, "%d ", dsta[j][k+i*stride_lowres] ); | |
1714 | fprintf( stderr, "\n" ); | |
1705 | 1715 | break; |
1706 | 1716 | } |
1707 | 1717 | } |
1884 | 1894 | for( size_t size = 16; size < 512; size += 16 ) |
1885 | 1895 | { |
1886 | 1896 | for( size_t i = 0; i < size; i++ ) |
1887 | buf1[i] = rand(); | |
1897 | buf1[i] = (uint8_t)rand(); | |
1888 | 1898 | memset( buf4-1, 0xAA, size + 2 ); |
1889 | 1899 | call_c( mc_c.memcpy_aligned, buf3, buf1, size ); |
1890 | 1900 | call_a( mc_a.memcpy_aligned, buf4, buf1, size ); |
2018 | 2028 | for( int l = 0; l < 4; l++ ) |
2019 | 2029 | { |
2020 | 2030 | for( int m = 0; m < 4; m++ ) |
2021 | printf("%d ",bs[j][k][l][m]); | |
2022 | printf("\n"); | |
2031 | fprintf( stderr, "%d ",bs[j][k][l][m] ); | |
2032 | fprintf( stderr, "\n" ); | |
2023 | 2033 | } |
2024 | printf("\n"); | |
2034 | fprintf( stderr, "\n" ); | |
2025 | 2035 | } |
2026 | 2036 | break; |
2027 | 2037 | } |
2053 | 2063 | h->chroma_qp_table = i_chroma_qp_table + 12; |
2054 | 2064 | h->param.analyse.b_transform_8x8 = 1; |
2055 | 2065 | |
2056 | for( int i_cqm = 0; i_cqm < 4; i_cqm++ ) | |
2066 | static const uint8_t cqm_test4[16] = | |
2067 | { | |
2068 | 6,4,6,4, | |
2069 | 4,3,4,3, | |
2070 | 6,4,6,4, | |
2071 | 4,3,4,3 | |
2072 | }; | |
2073 | static const uint8_t cqm_test8[64] = | |
2074 | { | |
2075 | 3,3,4,3,3,3,4,3, | |
2076 | 3,3,4,3,3,3,4,3, | |
2077 | 4,4,5,4,4,4,5,4, | |
2078 | 3,3,4,3,3,3,4,3, | |
2079 | 3,3,4,3,3,3,4,3, | |
2080 | 3,3,4,3,3,3,4,3, | |
2081 | 4,4,5,4,4,4,5,4, | |
2082 | 3,3,4,3,3,3,4,3 | |
2083 | }; | |
2084 | ||
2085 | for( int i_cqm = 0; i_cqm < 6; i_cqm++ ) | |
2057 | 2086 | { |
2058 | 2087 | if( i_cqm == 0 ) |
2059 | 2088 | { |
2060 | for( int i = 0; i < 6; i++ ) | |
2089 | for( int i = 0; i < 8; i++ ) | |
2061 | 2090 | h->sps->scaling_list[i] = x264_cqm_flat16; |
2062 | 2091 | h->param.i_cqm_preset = h->sps->i_cqm_preset = X264_CQM_FLAT; |
2063 | 2092 | } |
2064 | 2093 | else if( i_cqm == 1 ) |
2065 | 2094 | { |
2066 | for( int i = 0; i < 6; i++ ) | |
2095 | for( int i = 0; i < 8; i++ ) | |
2067 | 2096 | h->sps->scaling_list[i] = x264_cqm_jvt[i]; |
2068 | 2097 | h->param.i_cqm_preset = h->sps->i_cqm_preset = X264_CQM_JVT; |
2069 | 2098 | } |
2099 | else if( i_cqm == 2 ) | |
2100 | { | |
2101 | for( int i = 0; i < 4; i++ ) | |
2102 | h->sps->scaling_list[i] = cqm_test4; | |
2103 | for( int i = 4; i < 8; i++ ) | |
2104 | h->sps->scaling_list[i] = x264_cqm_flat16; | |
2105 | h->param.i_cqm_preset = h->sps->i_cqm_preset = X264_CQM_CUSTOM; | |
2106 | } | |
2107 | else if( i_cqm == 3 ) | |
2108 | { | |
2109 | for( int i = 0; i < 4; i++ ) | |
2110 | h->sps->scaling_list[i] = x264_cqm_flat16; | |
2111 | for( int i = 4; i < 8; i++ ) | |
2112 | h->sps->scaling_list[i] = cqm_test8; | |
2113 | h->param.i_cqm_preset = h->sps->i_cqm_preset = X264_CQM_CUSTOM; | |
2114 | } | |
2070 | 2115 | else |
2071 | 2116 | { |
2072 | 2117 | int max_scale = BIT_DEPTH < 10 ? 255 : 228; |
2073 | if( i_cqm == 2 ) | |
2118 | if( i_cqm == 4 ) | |
2074 | 2119 | for( int i = 0; i < 64; i++ ) |
2075 | 2120 | cqm_buf[i] = 10 + rand() % (max_scale - 9); |
2076 | 2121 | else |
2077 | 2122 | for( int i = 0; i < 64; i++ ) |
2078 | 2123 | cqm_buf[i] = 1; |
2079 | for( int i = 0; i < 6; i++ ) | |
2124 | for( int i = 0; i < 8; i++ ) | |
2080 | 2125 | h->sps->scaling_list[i] = cqm_buf; |
2081 | 2126 | h->param.i_cqm_preset = h->sps->i_cqm_preset = X264_CQM_CUSTOM; |
2082 | 2127 | } |
2093 | 2138 | static const int scale1d[8] = {32,31,24,31,32,31,24,31}; \ |
2094 | 2139 | for( int i = 0; i < max; i++ ) \ |
2095 | 2140 | { \ |
2096 | unsigned int scale = (255*scale1d[(i>>3)&7]*scale1d[i&7])/16; \ | |
2097 | dct1[i] = dct2[i] = (j>>(i>>6))&1 ? (rand()%(2*scale+1))-scale : 0; \ | |
2141 | int scale = (PIXEL_MAX*scale1d[(i>>3)&7]*scale1d[i&7])/16; \ | |
2142 | dct1[i] = dct2[i] = (j>>(i>>6))&1 ? (rand30()%(2*scale+1))-scale : 0; \ | |
2098 | 2143 | } \ |
2099 | 2144 | } |
2100 | 2145 | |
2103 | 2148 | static const int scale1d[4] = {4,6,4,6}; \ |
2104 | 2149 | for( int i = 0; i < max; i++ ) \ |
2105 | 2150 | { \ |
2106 | unsigned int scale = 255*scale1d[(i>>2)&3]*scale1d[i&3]; \ | |
2107 | dct1[i] = dct2[i] = (j>>(i>>4))&1 ? (rand()%(2*scale+1))-scale : 0; \ | |
2151 | int scale = PIXEL_MAX*scale1d[(i>>2)&3]*scale1d[i&3]; \ | |
2152 | dct1[i] = dct2[i] = (j>>(i>>4))&1 ? (rand30()%(2*scale+1))-scale : 0; \ | |
2108 | 2153 | } \ |
2109 | 2154 | } |
2110 | 2155 | |
2382 | 2427 | { \ |
2383 | 2428 | int nnz = 0; \ |
2384 | 2429 | int max = rand() & (size-1); \ |
2385 | memset( dct1, 0, size*sizeof(dctcoef) ); \ | |
2430 | memset( dct1, 0, 64*sizeof(dctcoef) ); \ | |
2386 | 2431 | for( int idx = ac; idx < max; idx++ ) \ |
2387 | 2432 | nnz |= dct1[idx] = !(rand()&3) + (!(rand()&15))*rand(); \ |
2388 | 2433 | if( !nnz ) \ |
2416 | 2461 | x264_run_level_t runlevel_c, runlevel_a; \ |
2417 | 2462 | int nnz = 0; \ |
2418 | 2463 | int max = rand() & (size-1); \ |
2419 | memset( dct1, 0, size*sizeof(dctcoef) ); \ | |
2464 | memset( dct1, 0, 64*sizeof(dctcoef) ); \ | |
2420 | 2465 | memcpy( &runlevel_a, buf1+i, sizeof(x264_run_level_t) ); \ |
2421 | 2466 | memcpy( &runlevel_c, buf1+i, sizeof(x264_run_level_t) ); \ |
2422 | 2467 | for( int idx = ac; idx < max; idx++ ) \ |
2502 | 2547 | if( ip_c.name == (void *)ip_c.predict_8x8 )\ |
2503 | 2548 | {\ |
2504 | 2549 | for( int k = -1; k < 16; k++ )\ |
2505 | printf( "%2x ", edge[16+k] );\ | |
2506 | printf( "\n" );\ | |
2550 | fprintf( stderr, FMT_PIXEL" ", edge[16+k] );\ | |
2551 | fprintf( stderr, "\n" );\ | |
2507 | 2552 | }\ |
2508 | 2553 | for( int j = 0; j < h; j++ )\ |
2509 | 2554 | {\ |
2510 | 2555 | if( ip_c.name == (void *)ip_c.predict_8x8 )\ |
2511 | printf( "%2x ", edge[14-j] );\ | |
2556 | fprintf( stderr, FMT_PIXEL" ", edge[14-j] );\ | |
2512 | 2557 | for( int k = 0; k < w; k++ )\ |
2513 | printf( "%2x ", pbuf4[48+k+j*FDEC_STRIDE] );\ | |
2514 | printf( "\n" );\ | |
2558 | fprintf( stderr, FMT_PIXEL" ", pbuf4[48+k+j*FDEC_STRIDE] );\ | |
2559 | fprintf( stderr, "\n" );\ | |
2515 | 2560 | }\ |
2516 | printf( "\n" );\ | |
2561 | fprintf( stderr, "\n" );\ | |
2517 | 2562 | for( int j = 0; j < h; j++ )\ |
2518 | 2563 | {\ |
2519 | 2564 | if( ip_c.name == (void *)ip_c.predict_8x8 )\ |
2520 | printf( " " );\ | |
2565 | fprintf( stderr, " " );\ | |
2521 | 2566 | for( int k = 0; k < w; k++ )\ |
2522 | printf( "%2x ", pbuf3[48+k+j*FDEC_STRIDE] );\ | |
2523 | printf( "\n" );\ | |
2567 | fprintf( stderr, FMT_PIXEL" ", pbuf3[48+k+j*FDEC_STRIDE] );\ | |
2568 | fprintf( stderr, "\n" );\ | |
2524 | 2569 | }\ |
2525 | 2570 | break;\ |
2526 | 2571 | }\ |
2771 | 2816 | int test_size = i < 10 ? i+1 : rand() & 0x3fff; |
2772 | 2817 | /* Test 8 different probability distributions of zeros */ |
2773 | 2818 | for( int j = 0; j < test_size+32; j++ ) |
2774 | input[j] = (rand()&((1 << ((i&7)+1)) - 1)) * rand(); | |
2819 | input[j] = (uint8_t)((rand()&((1 << ((i&7)+1)) - 1)) * rand()); | |
2775 | 2820 | uint8_t *end_c = (uint8_t*)call_c1( bs_c.nal_escape, output1, input, input+test_size ); |
2776 | 2821 | uint8_t *end_a = (uint8_t*)call_a1( bs_a.nal_escape, output2, input, input+test_size ); |
2777 | 2822 | int size_c = end_c-output1; |
2784 | 2829 | } |
2785 | 2830 | } |
2786 | 2831 | for( int j = 0; j < size+32; j++ ) |
2787 | input[j] = rand(); | |
2832 | input[j] = (uint8_t)rand(); | |
2788 | 2833 | call_c2( bs_c.nal_escape, output1, input, input+size ); |
2789 | 2834 | call_a2( bs_a.nal_escape, output2, input, input+size ); |
2790 | 2835 | free(input); |
2957 | 3002 | argv++; |
2958 | 3003 | } |
2959 | 3004 | |
2960 | int seed = ( argc > 1 ) ? atoi(argv[1]) : x264_mdate(); | |
3005 | unsigned seed = ( argc > 1 ) ? strtoul(argv[1], NULL, 0) : (unsigned)x264_mdate(); | |
2961 | 3006 | fprintf( stderr, "x264: using random seed %u\n", seed ); |
2962 | 3007 | srand( seed ); |
2963 | 3008 |
138 | 138 | args = self.optparse.parse_args()[1] # arguments may require reparsing after pre_dispatch; see test_x264.py |
139 | 139 | |
140 | 140 | if len(args) == 0: |
141 | print >>sys.stderr, "error: no comamnd specified\n" | |
141 | print >>sys.stderr, "error: no command specified\n" | |
142 | 142 | self.optparse.print_help() |
143 | 143 | return |
144 | 144 |
0 | 0 | #!/bin/sh |
1 | 1 | # Script modified from upstream source for Debian packaging since packaging |
2 | 2 | # won't include .git repository. |
3 | echo '#define X264_VERSION " r3060 5db6aa6"' | |
4 | echo '#define X264_POINTVER "0.163.3060 5db6aa6"' | |
3 | echo '#define X264_VERSION " r3095 baee400"' | |
4 | echo '#define X264_POINTVER "0.164.3095 baee400"' |
0 | 0 | /***************************************************************************** |
1 | 1 | * x264: top-level x264cli functions |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Loren Merritt <lorenm@u.washington.edu> |
6 | 6 | * Laurent Aimar <fenrir@via.ecp.fr> |
139 | 139 | /* video filter operation struct */ |
140 | 140 | static cli_vid_filter_t filter; |
141 | 141 | |
142 | const char * const x264_avcintra_class_names[] = { "50", "100", "200", 0 }; | |
142 | const char * const x264_avcintra_class_names[] = { "50", "100", "200", "300", "480", 0 }; | |
143 | 143 | const char * const x264_cqm_names[] = { "flat", "jvt", 0 }; |
144 | 144 | const char * const x264_log_level_names[] = { "none", "error", "warning", "info", "debug", 0 }; |
145 | 145 | const char * const x264_partition_names[] = { "p8x8", "p4x4", "b8x8", "i8x8", "i4x4", "none", "all", 0 }; |
494 | 494 | " .mkv -> Matroska\n" |
495 | 495 | " .flv -> Flash Video\n" |
496 | 496 | " .mp4 -> MP4 if compiled with GPAC or L-SMASH support (%s)\n" |
497 | "Output bit depth: %s\n." | |
497 | "Output bit depth: %s\n" | |
498 | 498 | "\n" |
499 | 499 | "Options:\n" |
500 | 500 | "\n" |
1301 | 1301 | { |
1302 | 1302 | x264_register_vid_filters(); |
1303 | 1303 | |
1304 | /* intialize baseline filters */ | |
1304 | /* initialize baseline filters */ | |
1305 | 1305 | if( x264_init_vid_filter( "source", handle, &filter, info, param, NULL ) ) /* wrap demuxer into a filter */ |
1306 | 1306 | return -1; |
1307 | 1307 | if( x264_init_vid_filter( "resize", handle, &filter, info, param, "normcsp" ) ) /* normalize csps to be of a known/supported format */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * x264.h: x264 public header |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
44 | 44 | |
45 | 45 | #include "x264_config.h" |
46 | 46 | |
47 | #define X264_BUILD 163 | |
47 | #define X264_BUILD 164 | |
48 | 48 | |
49 | 49 | #ifdef _WIN32 |
50 | 50 | # define X264_DLL_IMPORT __declspec(dllimport) |
520 | 520 | int i_sps_id; /* SPS and PPS id number */ |
521 | 521 | int b_vfr_input; /* VFR input. If 1, use timebase and timestamps for ratecontrol purposes. |
522 | 522 | * If 0, use fps only. */ |
523 | int b_pulldown; /* use explicity set timebase for CFR */ | |
523 | int b_pulldown; /* use explicitly set timebase for CFR */ | |
524 | 524 | uint32_t i_fps_num; |
525 | 525 | uint32_t i_fps_den; |
526 | 526 | uint32_t i_timebase_num; /* Timebase numerator */ |
0 | 0 | /***************************************************************************** |
1 | 1 | * x264cli.h: x264cli common |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2003-2021 x264 project | |
3 | * Copyright (C) 2003-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
6 | 6 | * Loren Merritt <lorenm@u.washington.edu> |
0 | 0 | /***************************************************************************** |
1 | 1 | * x264dll: x264 DLLMain for win32 |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2009-2021 x264 project | |
3 | * Copyright (C) 2009-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Anton Mitrofanov <BugMaster@narod.ru> |
6 | 6 | * |
0 | 0 | /***************************************************************************** |
1 | 1 | * x264res.rc: windows resource file |
2 | 2 | ***************************************************************************** |
3 | * Copyright (C) 2012-2021 x264 project | |
3 | * Copyright (C) 2012-2022 x264 project | |
4 | 4 | * |
5 | 5 | * Authors: Henrik Gramner <henrik@gramner.com> |
6 | 6 | * |
67 | 67 | #endif |
68 | 68 | VALUE "FileVersion", X264_POINTVER |
69 | 69 | VALUE "InternalName", "x264" |
70 | VALUE "LegalCopyright", "Copyright (C) 2003-2021 x264 project" | |
70 | VALUE "LegalCopyright", "Copyright (C) 2003-2022 x264 project" | |
71 | 71 | #ifdef DLL |
72 | 72 | VALUE "OriginalFilename", "libx264-" xstr(X264_BUILD) ".dll" |
73 | 73 | #else |