Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rem for openSUSE:Factory checked in at 2021-05-15 01:24:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rem (Old) and /work/SRC/openSUSE:Factory/.rem.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rem" Sat May 15 01:24:18 2021 rev:2 rq:893081 version:1.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rem/rem.changes 2020-07-03 00:11:35.315902883 +0200 +++ /work/SRC/openSUSE:Factory/.rem.new.2988/rem.changes 2021-05-15 01:24:35.750938911 +0200 @@ -1,0 +2,14 @@ +Wed May 12 23:24:56 UTC 2021 - Ferdinand Thiessen <r...@fthiessen.de> + +- Switch baresip fork, required for baresip. +- Update to fork version 1.0.0: + * aac: add module for AAC header parsing + * flv: add MP3 and PCM_LE + * fix ALAW and ULAW encoding + * vid: add NV12/NV21 to vidframe_fill + * H264: added SPS decode + * aubuf: read also last frame if it has not the full size + * add aulevel module +- Add 0001-mk-add-abi-versioning.patch + +------------------------------------------------------------------- Old: ---- rem-0.6.0.tar.gz New: ---- 0001-mk-add-abi-versioning.patch rem-1.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rem.spec ++++++ --- /var/tmp/diff_new_pack.BVlyHF/_old 2021-05-15 01:24:36.202937323 +0200 +++ /var/tmp/diff_new_pack.BVlyHF/_new 2021-05-15 01:24:36.206937309 +0200 @@ -1,7 +1,7 @@ # # spec file for package rem # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,15 +18,16 @@ %global sover 0 %global libname lib%{name}%{sover} Name: rem -Version: 0.6.0 +Version: 1.0.0 Release: 0 Summary: Audio and Video processing media library License: BSD-3-Clause Group: Development/Libraries/C and C++ -URL: http://www.creytiv.com/rem.html -Source: http://www.creytiv.com/pub/rem-%{version}.tar.gz +URL: https://github.com/baresip/rem +Source: %{URL}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch: 0001-mk-add-abi-versioning.patch BuildRequires: pkgconfig -BuildRequires: re-devel +BuildRequires: pkgconfig(libre) >= 2.0 %description Librem is a generic library for real-time audio @@ -65,22 +66,17 @@ applications that want to make use of librem. %prep -%setup -q +%autosetup -p1 sed -e 's|@$(CC)|$(CC)|g' \ -e 's|@$(LD)|$(LD)|g' \ -e 's|@$(AR)|$(AR)|g' \ -e 's|@rm -rf|rm -rf|g' -i Makefile %build -%make_build \ - RELEASE=1 \ - EXTRA_CFLAGS="%optflags" \ - EXTRA_LFLAGS="-Wl,-soname,librem.so.0" \ - LIB_SUFFIX=".so.0" +CFLAGS="%optflags" %make_build RELEASE=1 %install -make DESTDIR=%{buildroot} LIBDIR=%{_libdir} LIB_SUFFIX=".so.0" install -ln -s %{_libdir}/librem.so.0 %{buildroot}%{_libdir}/librem.so +%make_install LIBDIR=%{_libdir} rm %{buildroot}/%{_libdir}/librem.a %post -n %{libname} -p /sbin/ldconfig ++++++ 0001-mk-add-abi-versioning.patch ++++++ >From eea93d400fbf0efa3e7930babd1e6662b2d6aca2 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers <ha...@studio-link.de> Date: Fri, 9 Apr 2021 14:38:04 +0200 Subject: [PATCH] mk: add abi versioning --- Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5fd7c9c..2d5a843 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,14 @@ VER_MAJOR := 1 VER_MINOR := 0 VER_PATCH := 0 +# Libtool similar ABI versioning +# https://github.com/baresip/re/wiki/ABI-Versioning +ABI_CUR := 0 +ABI_REV := 0 +ABI_AGE := 0 + +ABI_MAJOR := $(shell expr $(ABI_CUR) - $(ABI_AGE)) + PROJECT := rem VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) OPT_SPEED := 1 @@ -69,8 +77,13 @@ endif MODMKS := $(patsubst %,src/%/mod.mk,$(MODULES)) SHARED := librem$(LIB_SUFFIX) +SHARED_SONAME := $(SHARED).$(ABI_MAJOR) +SHARED_FILE := $(SHARED).$(ABI_MAJOR).$(ABI_AGE).$(ABI_REV) STATIC := librem.a +ifeq ($(OS),linux) +SH_LFLAGS += -Wl,-soname,$(SHARED_SONAME) +endif include $(MODMKS) @@ -136,7 +149,9 @@ install: $(SHARED) $(STATIC) librem.pc $(DESTDIR)$(INCDIR) $(INSTALL) -m 0644 $(shell find include -name "*.h") \ $(DESTDIR)$(INCDIR) - $(INSTALL) -m 0755 $(SHARED) $(DESTDIR)$(LIBDIR) + $(INSTALL) -m 0755 $(SHARED) $(DESTDIR)$(LIBDIR)/$(SHARED_FILE) + cd $(DESTDIR)$(LIBDIR) && ln -sf $(SHARED_FILE) $(SHARED) && \ + ln -sf $(SHARED_FILE) $(SHARED_SONAME) $(INSTALL) -m 0755 $(STATIC) $(DESTDIR)$(LIBDIR) $(INSTALL) -m 0644 librem.pc $(DESTDIR)$(LIBDIR)/pkgconfig -- 2.26.2 ++++++ rem-0.6.0.tar.gz -> rem-1.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/.github/workflows/build.yml new/rem-1.0.0/.github/workflows/build.yml --- old/rem-0.6.0/.github/workflows/build.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/.github/workflows/build.yml 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,41 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + compiler: [gcc, clang] + os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-latest] + exclude: + - os: macos-latest + compiler: gcc + env: + CC: ${{ matrix.compiler }} + + steps: + - uses: actions/checkout@v2 + + - uses: sreimers/pr-dependency-action@v0.3 + with: + name: re + repo: https://github.com/baresip/re + secret: ${{ secrets.GITHUB_TOKEN }} + working-directory: '../.' + + - uses: sreimers/pr-dependency-action@v0.3 + with: + name: retest + repo: https://github.com/baresip/retest.git + secret: ${{ secrets.GITHUB_TOKEN }} + working-directory: '../.' + + - name: retest + run: | + cd .. + make -C re libre.a + make -C rem EXTRA_CFLAGS=-Werror CCACHE= librem.a + cd retest && make STATIC=1 LIBRE_SO=../re && ./retest -r diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/.github/workflows/ccheck.yml new/rem-1.0.0/.github/workflows/ccheck.yml --- old/rem-0.6.0/.github/workflows/ccheck.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/.github/workflows/ccheck.yml 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,15 @@ +name: ccheck + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: ccheck + run: | + wget "https://raw.githubusercontent.com/baresip/baresip/master/test/ccheck.py" + python3 ccheck.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/.gitignore new/rem-1.0.0/.gitignore --- old/rem-0.6.0/.gitignore 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/.gitignore 2021-04-09 13:05:40.000000000 +0200 @@ -1,4 +1,4 @@ -build* +/build* test* librem.a librem.dylib diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/.travis.yml new/rem-1.0.0/.travis.yml --- old/rem-0.6.0/.travis.yml 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -language: c - -before_install: - - sudo apt-get -qq update - - sudo apt-get -y install libssl-dev - -install: - - git clone https://github.com/creytiv/re.git - - cd re && make && sudo make install && cd .. - - sudo ldconfig - - wget "https://github.com/alfredh/pytools/raw/master/ccheck.py" - -script: - - make EXTRA_CFLAGS=-Werror - - python2 ccheck.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/Makefile new/rem-1.0.0/Makefile --- old/rem-0.6.0/Makefile 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/Makefile 2021-04-09 13:05:40.000000000 +0200 @@ -4,15 +4,16 @@ # Copyright (C) 2010 Creytiv.com # -# Master version number -VER_MAJOR := 0 -VER_MINOR := 6 +# Main version number +VER_MAJOR := 1 +VER_MINOR := 0 VER_PATCH := 0 PROJECT := rem VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) OPT_SPEED := 1 +ifndef LIBRE_MK LIBRE_MK := $(shell [ -f ../re/mk/re.mk ] && \ echo "../re/mk/re.mk") ifeq ($(LIBRE_MK),) @@ -23,6 +24,7 @@ LIBRE_MK := $(shell [ -f /usr/local/share/re/re.mk ] && \ echo "/usr/local/share/re/re.mk") endif +endif include $(LIBRE_MK) @@ -30,14 +32,16 @@ MODULES += fir goertzel MODULES += g711 MODULES += aubuf aufile auresamp autone dtmf -MODULES += au auconv +MODULES += au auconv aulevel ifneq ($(HAVE_LIBPTHREAD),) MODULES += aumix vidmix endif MODULES += vid vidconv +MODULES += aac MODULES += avc +MODULES += h264 LIBS += -lm diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/README.md new/rem-1.0.0/README.md --- old/rem-0.6.0/README.md 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/README.md 2021-04-09 13:05:40.000000000 +0200 @@ -3,9 +3,11 @@ librem is a Audio and video processing media library -Copyright (C) 2010 - 2018 Creytiv.com -[](https://travis-ci.org/creytiv/rem) +- Copyright (C) 2010 - 2019 Creytiv.com +- Copyright (C) 2020 - 2021 Baresip Foundation (https://github.com/baresip) + +[](https://github.com/baresip/rem/actions/workflows/build.yml) ## Features @@ -25,7 +27,7 @@ ## Building -librem is using GNU makefiles, and [libre](https://github.com/creytiv/re) +librem is using GNU makefiles, and [libre](https://github.com/baresip/re) must be installed before building. @@ -37,13 +39,6 @@ $ sudo ldconfig ``` - -## Documentation - -The online documentation generated with doxygen is available in -the main [website](http://creytiv.com/doxygen/rem-dox/html/) - - ## License The librem project is using the BSD license. @@ -52,10 +47,7 @@ ## Contributing Patches can sent via Github -[Pull-Requests](https://github.com/creytiv/rem/pulls) or to the RE devel -[mailing-list](http://lists.creytiv.com/mailman/listinfo/re-devel). -Currently we only accept small patches. -Please send private feedback to libre [at] creytiv.com +[Pull-Requests](https://github.com/baresip/rem/pulls) ## Modules @@ -64,6 +56,7 @@ name: status: description: +* aac unstable Advanced Audio Coding (AAC) * au testing Base audio types * aubuf testing Audio buffer * auconv unstable Audio sample format conversion @@ -82,6 +75,7 @@ name: status: description: * avc unstable Advanced Video Coding (AVC) +* h264 unstable H.264 header parser * vid testing Base video types * vidconv testing Colorspace conversion and scaling * vidmix unstable Video mixer @@ -107,21 +101,17 @@ ## Supported platforms -Same as [libre](https://github.com/creytiv/re) +Same as [libre](https://github.com/baresip/re) ## Related projects -* [libre](https://github.com/creytiv/re) -* [retest](https://github.com/creytiv/retest) -* [baresip](https://github.com/alfredh/baresip) +* [libre](https://github.com/baresip/re) +* [retest](https://github.com/baresip/retest) +* [baresip](https://github.com/baresip/baresip) ## References -http://creytiv.com/rem.html - -https://github.com/creytiv/rem - -http://lists.creytiv.com/mailman/listinfo/re-devel +https://github.com/baresip diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/debian/changelog new/rem-1.0.0/debian/changelog --- old/rem-0.6.0/debian/changelog 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/debian/changelog 2021-04-09 13:05:40.000000000 +0200 @@ -1,3 +1,39 @@ +librem (1.0.0) unstable; urgency=medium + + * version 1.0.0 + + -- Sebastian Reimers <sebastian.reim...@gmail.com> Fri, 9 Apr 2021 14:00:00 +0200 + +librem (0.6.0-5) unstable; urgency=medium + + * version 0.6.0-5 + + -- Alfred E. Heggestad <alfred.hegges...@gmail.com> Tue, 14 Apr 2020 14:00:00 +0200 + +librem (0.6.0-4) unstable; urgency=medium + + * version 0.6.0-4 + + -- Richard Aas <richar...@gmail.com> Wed, 4 Mar 2020 14:00:00 +0100 + +librem (0.6.0-3) unstable; urgency=medium + + * version 0.6.0-3 + + -- Richard Aas <richar...@gmail.com> Fri, 11 Oct 2019 12:00:00 +0200 + +librem (0.6.0-2) unstable; urgency=medium + + * version 0.6.0-2 + + -- Richard Aas <richar...@gmail.com> Fri, 26 Apr 2019 12:00:00 +0200 + +librem (0.6.0-1) unstable; urgency=medium + + * version 0.6.0-1 + + -- Richard Aas <richar...@gmail.com> Mon, 11 Mar 2019 13:00:00 +0100 + librem (0.6.0) unstable; urgency=medium * version 0.6.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/debian/control new/rem-1.0.0/debian/control --- old/rem-0.6.0/debian/control 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/debian/control 2021-04-09 13:05:40.000000000 +0200 @@ -3,13 +3,13 @@ Priority: optional Maintainer: Alfred E. Heggestad <a...@db.org> Standards-Version: 3.9.5 -Build-Depends: debhelper (>= 9.20120311), libre-dev (>= 0.6.0) +Build-Depends: debhelper (>= 9.20120311), libre-dev (>= 1.1.0) Homepage: http://www.creytiv.com/ Package: librem Architecture: any Section: libs -Depends: libre (>= 0.6.0), ${shlibs:Depends}, ${misc:Depends} +Depends: libre (>= 1.1.0), ${shlibs:Depends}, ${misc:Depends} Description: Audio and video processing media library Audio mixer, resampler, tone generator, G.711 codec Video mixer, pixel converter @@ -17,6 +17,6 @@ Package: librem-dev Architecture: any Section: libdevel -Depends: librem (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Depends: librem (= ${binary:Version}), ${misc:Depends} Description: Audio and video processing media library (development files) Development package for librem diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/debian/rules new/rem-1.0.0/debian/rules --- old/rem-0.6.0/debian/rules 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/debian/rules 2021-04-09 13:05:40.000000000 +0200 @@ -83,7 +83,7 @@ dh_fixperms # dh_perl # dh_python -# dh_makeshlibs + dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/debian/source/format new/rem-1.0.0/debian/source/format --- old/rem-0.6.0/debian/source/format 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/debian/source/format 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1 @@ +1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/docs/COPYING new/rem-1.0.0/docs/COPYING --- old/rem-0.6.0/docs/COPYING 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/docs/COPYING 2021-04-09 13:05:40.000000000 +0200 @@ -1,6 +1,6 @@ -Copyright (c) 2010 - 2018, Alfred E. Heggestad -Copyright (c) 2010 - 2018, Richard Aas -Copyright (c) 2010 - 2018, Creytiv.com +Copyright (c) 2010 - 2019, Alfred E. Heggestad +Copyright (c) 2010 - 2019, Richard Aas +Copyright (c) 2010 - 2019, Creytiv.com All rights reserved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_aac.h new/rem-1.0.0/include/rem_aac.h --- old/rem-0.6.0/include/rem_aac.h 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/include/rem_aac.h 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,15 @@ +/** + * @file rem_aac.h Advanced Audio Coding + * + * Copyright (C) 2010 Creytiv.com + */ + + +/** Defines the AAC header */ +struct aac_header { + unsigned sample_rate; /**< Audio sample rate in [Hz] */ + unsigned channels; /**< Number of audio channels */ + unsigned frame_size; /**< Frame size, 960 or 1024 bits */ +}; + +int aac_header_decode(struct aac_header *hdr, const uint8_t *p, size_t len); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_audio.h new/rem-1.0.0/include/rem_audio.h --- old/rem-0.6.0/include/rem_audio.h 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/include/rem_audio.h 2021-04-09 13:05:40.000000000 +0200 @@ -9,6 +9,7 @@ #include "rem_aubuf.h" #include "rem_auconv.h" #include "rem_aufile.h" +#include "rem_aulevel.h" #include "rem_autone.h" #include "rem_aumix.h" #include "rem_dtmf.h" @@ -16,3 +17,4 @@ #include "rem_goertzel.h" #include "rem_auresamp.h" #include "rem_g711.h" +#include "rem_aac.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_aulevel.h new/rem-1.0.0/include/rem_aulevel.h --- old/rem-0.6.0/include/rem_aulevel.h 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/include/rem_aulevel.h 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,12 @@ + + +/* + * Audio-level + */ + + +#define AULEVEL_MIN (-96.0) +#define AULEVEL_MAX (0.0) + + +double aulevel_calc_dbov(int fmt, const void *sampv, size_t sampc); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_flv.h new/rem-1.0.0/include/rem_flv.h --- old/rem-0.6.0/include/rem_flv.h 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/include/rem_flv.h 2021-04-09 13:05:40.000000000 +0200 @@ -11,6 +11,8 @@ enum flv_aucodec { FLV_AUCODEC_PCM = 0, + FLV_AUCODEC_MP3 = 2, + FLV_AUCODEC_PCM_LE = 3, FLV_AUCODEC_ALAW = 7, FLV_AUCODEC_ULAW = 8, FLV_AUCODEC_AAC = 10, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_g711.h new/rem-1.0.0/include/rem_g711.h --- old/rem-0.6.0/include/rem_g711.h 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/include/rem_g711.h 2021-04-09 13:05:40.000000000 +0200 @@ -18,8 +18,9 @@ * * @return U-law byte */ -static inline uint8_t g711_pcm2ulaw(int16_t l) +static inline uint8_t g711_pcm2ulaw(int16_t lx) { + int32_t l = lx; const uint8_t mask = (l < 0) ? 0x7f : 0xff; if (l < 0) l = -l; @@ -43,7 +44,7 @@ { const uint8_t mask = (l < 0) ? 0x7f : 0xff; if (l < 0) - l = -l; + l = ~l; l >>= 4; return g711_l2A[l] & mask; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_h264.h new/rem-1.0.0/include/rem_h264.h --- old/rem-0.6.0/include/rem_h264.h 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/include/rem_h264.h 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,75 @@ +/** + * @file rem_h264.h Interface to H.264 header parser + * + * Copyright (C) 2010 Creytiv.com + */ + + +/** NAL unit types */ +enum h264_nalu { + H264_NALU_SLICE = 1, + H264_NALU_DPA = 2, + H264_NALU_DPB = 3, + H264_NALU_DPC = 4, + H264_NALU_IDR_SLICE = 5, + H264_NALU_SEI = 6, + H264_NALU_SPS = 7, + H264_NALU_PPS = 8, + H264_NALU_AUD = 9, + H264_NALU_END_SEQUENCE = 10, + H264_NALU_END_STREAM = 11, + H264_NALU_FILLER_DATA = 12, + H264_NALU_SPS_EXT = 13, + H264_NALU_AUX_SLICE = 19, + + H264_NALU_STAP_A = 24, + H264_NALU_STAP_B = 25, + H264_NALU_MTAP16 = 26, + H264_NALU_MTAP24 = 27, + H264_NALU_FU_A = 28, + H264_NALU_FU_B = 29, +}; + + +/** + * H.264 NAL Header + */ +struct h264_nal_header { + unsigned f:1; /**< Forbidden zero bit (must be 0) */ + unsigned nri:2; /**< nal_ref_idc */ + unsigned type:5; /**< NAL unit type */ +}; + + +int h264_nal_header_encode(struct mbuf *mb, const struct h264_nal_header *hdr); +int h264_nal_header_decode(struct h264_nal_header *hdr, struct mbuf *mb); +const char *h264_nal_unit_name(enum h264_nalu nal_type); + + +/** + * H.264 Sequence Parameter Set (SPS) + */ +struct h264_sps { + uint8_t profile_idc; + uint8_t level_idc; + uint8_t seq_parameter_set_id; /* 0-31 */ + uint8_t chroma_format_idc; /* 0-3 */ + + unsigned log2_max_frame_num; + unsigned pic_order_cnt_type; + + unsigned max_num_ref_frames; + unsigned pic_width_in_mbs; + unsigned pic_height_in_map_units; + + unsigned frame_crop_left_offset; /* pixels */ + unsigned frame_crop_right_offset; /* pixels */ + unsigned frame_crop_top_offset; /* pixels */ + unsigned frame_crop_bottom_offset; /* pixels */ +}; + +struct vidsz; + +int h264_sps_decode(struct h264_sps *sps, const uint8_t *p, size_t len); +void h264_sps_resolution(const struct h264_sps *sps, struct vidsz *sz); +const char *h264_sps_chroma_format_name(uint8_t chroma_format_idc); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/include/rem_video.h new/rem-1.0.0/include/rem_video.h --- old/rem-0.6.0/include/rem_video.h 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/include/rem_video.h 2021-04-09 13:05:40.000000000 +0200 @@ -9,3 +9,4 @@ #include "rem_vidmix.h" #include "rem_vidconv.h" #include "rem_avc.h" +#include "rem_h264.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/mk/win32/rem.vcxproj new/rem-1.0.0/mk/win32/rem.vcxproj --- old/rem-0.6.0/mk/win32/rem.vcxproj 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/mk/win32/rem.vcxproj 2021-04-09 13:05:40.000000000 +0200 @@ -50,17 +50,17 @@ <ProjectName>rem-win32</ProjectName> <ProjectGuid>{3E767371-A72B-4F5C-A695-8F844B0889C5}</ProjectGuid> <Keyword>Win32Proj</Keyword> - <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> + <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v141</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v141</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> @@ -90,7 +90,6 @@ <InlineFunctionExpansion>Default</InlineFunctionExpansion> <AdditionalIncludeDirectories>..\..\include;..\..\..\re\include;..\..\..\misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;_CONSOLE;HAVE_SELECT;HAVE_IO_H;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <PrecompiledHeader /> @@ -107,7 +106,7 @@ <ClCompile> <AdditionalIncludeDirectories>..\..\include;..\..\..\re\include;..\..\..\misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;_CONSOLE;HAVE_SELECT;HAVE_IO_H;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/rpm/rem.spec new/rem-1.0.0/rpm/rem.spec --- old/rem-0.6.0/rpm/rem.spec 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/rpm/rem.spec 2021-04-09 13:05:40.000000000 +0200 @@ -1,5 +1,5 @@ %define name rem -%define ver 0.6.0 +%define ver 1.0.0 %define rel 1 Summary: Audio and Video processing media library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/aac/aac.c new/rem-1.0.0/src/aac/aac.c --- old/rem-0.6.0/src/aac/aac.c 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/aac/aac.c 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,69 @@ +/** + * @file aac.c Advanced Audio Coding + * + * Copyright (C) 2018 Creytiv.com + */ + +#include <re_types.h> +#include <rem_aac.h> + + +/* + * Ref https://wiki.multimedia.cx/index.php/MPEG-4_Audio + */ + +enum { + OBJECT_TYPE_AAC_LC = 2 +}; + + +static const unsigned aac_sample_rates[13] = { + 96000, 88200, 64000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, 11025, 8000, 7350 +}; + + +static const unsigned aac_channels[8] = { + 0, 1, 2, 3, 4, 5, 6, 8 +}; + + +/** + * Decode an AAC header + * + * @param hdr Decoded AAC header + * @param p Packet to decode + * @param len Packet length + * + * @return 0 if success, otherwise errorcode + */ +int aac_header_decode(struct aac_header *hdr, const uint8_t *p, size_t len) +{ + uint8_t object_type; + uint8_t srate_index; + uint8_t channel_index; + + if (!hdr || !p || len<2) + return EINVAL; + + object_type = (p[0] >> 3) & 0x1f; + + if (object_type != OBJECT_TYPE_AAC_LC) + return EBADMSG; + + srate_index = (p[0] & 0x07) << 1; + srate_index |= (p[1] & 0x80) >> 7; + + channel_index = (p[1] >> 3) & 0xf; + + if (srate_index >= ARRAY_SIZE(aac_sample_rates)) + return ENOTSUP; + if (channel_index >= ARRAY_SIZE(aac_channels)) + return ENOTSUP; + + hdr->sample_rate = aac_sample_rates[srate_index]; + hdr->channels = aac_channels[channel_index]; + hdr->frame_size = ((p[1] >> 2) & 1) ? 960 : 1024; + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/aac/mod.mk new/rem-1.0.0/src/aac/mod.mk --- old/rem-0.6.0/src/aac/mod.mk 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/aac/mod.mk 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,7 @@ +# +# mod.mk +# +# Copyright (C) 2010 Creytiv.com +# + +SRCS += aac/aac.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/aubuf/aubuf.c new/rem-1.0.0/src/aubuf/aubuf.c --- old/rem-0.6.0/src/aubuf/aubuf.c 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/src/aubuf/aubuf.c 2021-04-09 13:05:40.000000000 +0200 @@ -177,6 +177,7 @@ void aubuf_read(struct aubuf *ab, uint8_t *p, size_t sz) { struct le *le; + bool filling; if (!ab || !p || !sz) return; @@ -191,12 +192,15 @@ ab, ab->cur_sz); } #endif + filling = ab->filling; ab->filling = true; memset(p, 0, sz); - goto out; + if (filling) + goto out; + } + else { + ab->filling = false; } - - ab->filling = false; le = ab->afl.head; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/aulevel/aulevel.c new/rem-1.0.0/src/aulevel/aulevel.c --- old/rem-0.6.0/src/aulevel/aulevel.c 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/aulevel/aulevel.c 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,117 @@ +/** + * @file src/aulevel.c Audio level + * + * Copyright (C) 2017 Creytiv.com + */ + +#include <math.h> +#include <re.h> +#include <rem.h> + + +/** + * Generic routine to calculate RMS (Root-Mean-Square) from + * a set of signed 16-bit values + * + * \verbatim + + .--------------- + | N-1 + | ----. + | \ + | \ 2 + | | s[n] + | / + | / + _ | ----' + \ | n=0 + \ | ------------ + \| N + + \endverbatim + * + * @param data Array of signed 16-bit values + * @param len Number of values + * + * @return RMS value from 0 to 32768 + */ +static double calc_rms(const int16_t *data, size_t len) +{ + double sum = 0; + size_t i; + + if (!data || !len) + return .0; + + for (i = 0; i < len; i++) { + const double sample = data[i]; + + sum += sample * sample; + } + + return sqrt(sum / (double)len); +} + + +static double calc_rms_float(const float *data, size_t len) +{ + double sum = 0; + size_t i; + + if (!data || !len) + return .0; + + for (i = 0; i < len; i++) { + const double sample = data[i]; + + sum += sample * sample; + } + + return sqrt(sum / (double)len); +} + + +/** + * Calculate the audio level in dBov from a set of audio samples. + * dBov is the level, in decibels, relative to the overload point + * of the system + * + * @param fmt Sample format (enum aufmt) + * @param sampv Audio samples + * @param sampc Number of audio samples + * + * @return Audio level expressed in dBov + */ +double aulevel_calc_dbov(int fmt, const void *sampv, size_t sampc) +{ + static const double peak = 32767.0; + double rms, dbov; + + if (!sampv || !sampc) + return AULEVEL_MIN; + + switch (fmt) { + + case AUFMT_S16LE: + rms = calc_rms(sampv, sampc) / peak; + break; + + case AUFMT_FLOAT: + rms = calc_rms_float(sampv, sampc) / 1.0; + break; + + default: + re_printf("aulevel: sample format not supported (%s)\n", + aufmt_name(fmt)); + return AULEVEL_MIN; + } + + dbov = 20 * log10(rms); + + if (dbov < AULEVEL_MIN) + dbov = AULEVEL_MIN; + else if (dbov > AULEVEL_MAX) + dbov = AULEVEL_MAX; + + return dbov; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/aulevel/mod.mk new/rem-1.0.0/src/aulevel/mod.mk --- old/rem-0.6.0/src/aulevel/mod.mk 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/aulevel/mod.mk 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,7 @@ +# +# mod.mk +# +# Copyright (C) 2010 Creytiv.com +# + +SRCS += aulevel/aulevel.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/h264/getbit.c new/rem-1.0.0/src/h264/getbit.c --- old/rem-0.6.0/src/h264/getbit.c 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/h264/getbit.c 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,92 @@ +/** + * @file h264/getbit.c Generic bit parser + * + * Copyright (C) 2010 Creytiv.com + */ + +#include <re_types.h> +#include <re_fmt.h> +#include "h264.h" + + +void getbit_init(struct getbit *gb, const uint8_t *buf, size_t size) +{ + if (!gb) + return; + + gb->buf = buf; + gb->pos = 0; + gb->end = size; +} + + +size_t getbit_get_left(const struct getbit *gb) +{ + if (!gb) + return 0; + + if (gb->end > gb->pos) + return gb->end - gb->pos; + else + return 0; +} + + +unsigned get_bit(struct getbit *gb) +{ + const uint8_t *p; + register unsigned tmp; + + if (!gb) + return 0; + + if (gb->pos >= gb->end) { + re_fprintf(stderr, "get_bit: read past end" + " (%zu >= %zu)\n", gb->pos, gb->end); + return 0; + } + + p = gb->buf; + tmp = ((*(p + (gb->pos >> 0x3))) >> (0x7 - (gb->pos & 0x7))) & 0x1; + + ++gb->pos; + + return tmp; +} + + +int get_ue_golomb(struct getbit *gb, unsigned *valp) +{ + unsigned zeros = 0; + unsigned info; + int i; + + if (!gb) + return EINVAL; + + while (1) { + + if (getbit_get_left(gb) < 1) + return EBADMSG; + + if (0 == get_bit(gb)) + ++zeros; + else + break; + } + + info = 1 << zeros; + + for (i = zeros - 1; i >= 0; i--) { + + if (getbit_get_left(gb) < 1) + return EBADMSG; + + info |= get_bit(gb) << i; + } + + if (valp) + *valp = info - 1; + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/h264/h264.h new/rem-1.0.0/src/h264/h264.h --- old/rem-0.6.0/src/h264/h264.h 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/h264/h264.h 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,18 @@ +/** + * @file h264/h264.h Internal interface + * + * Copyright (C) 2010 Creytiv.com + */ + + +struct getbit { + const uint8_t *buf; + size_t pos; + size_t end; +}; + + +void getbit_init(struct getbit *gb, const uint8_t *buf, size_t size); +size_t getbit_get_left(const struct getbit *gb); +unsigned get_bit(struct getbit *gb); +int get_ue_golomb(struct getbit *gb, unsigned *valp); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/h264/mod.mk new/rem-1.0.0/src/h264/mod.mk --- old/rem-0.6.0/src/h264/mod.mk 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/h264/mod.mk 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,9 @@ +# +# mod.mk +# +# Copyright (C) 2010 Creytiv.com +# + +SRCS += h264/getbit.c +SRCS += h264/nal.c +SRCS += h264/sps.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/h264/nal.c new/rem-1.0.0/src/h264/nal.c --- old/rem-0.6.0/src/h264/nal.c 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/h264/nal.c 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,94 @@ +/** + * @file h264/nal.c H.264 header parser + * + * Copyright (C) 2010 Creytiv.com + */ + +#include <re_types.h> +#include <re_mbuf.h> +#include <rem_h264.h> + + +/** + * Encode H.264 NAL header + * + * @param mb Buffer to encode into + * @param hdr H.264 NAL header to encode + * + * @return 0 if success, otherwise errorcode + */ +int h264_nal_header_encode(struct mbuf *mb, const struct h264_nal_header *hdr) +{ + uint8_t v; + + if (!mb || !hdr) + return EINVAL; + + v = hdr->f<<7 | hdr->nri<<5 | hdr->type; + + return mbuf_write_u8(mb, v); +} + + +/** + * Decode H.264 NAL header + * + * @param hdr H.264 NAL header to decode into + * @param mb Buffer to decode + * + * @return 0 if success, otherwise errorcode + */ +int h264_nal_header_decode(struct h264_nal_header *hdr, struct mbuf *mb) +{ + uint8_t v; + + if (!hdr || !mb) + return EINVAL; + if (mbuf_get_left(mb) < 1) + return EBADMSG; + + v = mbuf_read_u8(mb); + + hdr->f = v>>7 & 0x1; + hdr->nri = v>>5 & 0x3; + hdr->type = v & 0x1f; + + return 0; +} + + +/** + * Get the name of an H.264 NAL unit + * + * @param nal_type NAL unit type + * + * @return A string containing the NAL unit name + */ +const char *h264_nal_unit_name(enum h264_nalu nal_type) +{ + switch (nal_type) { + + case H264_NALU_SLICE: return "SLICE"; + case H264_NALU_DPA: return "DPA"; + case H264_NALU_DPB: return "DPB"; + case H264_NALU_DPC: return "DPC"; + case H264_NALU_IDR_SLICE: return "IDR_SLICE"; + case H264_NALU_SEI: return "SEI"; + case H264_NALU_SPS: return "SPS"; + case H264_NALU_PPS: return "PPS"; + case H264_NALU_AUD: return "AUD"; + case H264_NALU_END_SEQUENCE: return "END_SEQUENCE"; + case H264_NALU_END_STREAM: return "END_STREAM"; + case H264_NALU_FILLER_DATA: return "FILLER_DATA"; + case H264_NALU_SPS_EXT: return "SPS_EXT"; + case H264_NALU_AUX_SLICE: return "AUX_SLICE"; + case H264_NALU_STAP_A: return "STAP-A"; + case H264_NALU_STAP_B: return "STAP-B"; + case H264_NALU_MTAP16: return "MTAP16"; + case H264_NALU_MTAP24: return "MTAP24"; + case H264_NALU_FU_A: return "FU-A"; + case H264_NALU_FU_B: return "FU-B"; + } + + return "???"; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/h264/sps.c new/rem-1.0.0/src/h264/sps.c --- old/rem-0.6.0/src/h264/sps.c 1970-01-01 01:00:00.000000000 +0100 +++ new/rem-1.0.0/src/h264/sps.c 2021-04-09 13:05:40.000000000 +0200 @@ -0,0 +1,341 @@ +/** + * @file h264/sps.c H.264 SPS parser + * + * Copyright (C) 2010 Creytiv.com + */ + +#include <string.h> +#include <re_types.h> +#include <re_fmt.h> +#include <re_mbuf.h> +#include <rem_h264.h> +#include <rem_vid.h> +#include "h264.h" + + +enum { + MAX_SPS_COUNT = 32, + MAX_LOG2_MAX_FRAME_NUM = 16, + MACROBLOCK_SIZE = 16, +}; + +#define MAX_MACROBLOCKS 1048576u + + +static int scaling_list(struct getbit *gb, + unsigned *scaling_list, size_t sizeofscalinglist, + bool *usedefaultscalingmatrix) +{ + unsigned lastscale = 8; + unsigned nextscale = 8; + size_t j; + int err; + + for (j = 0; j < sizeofscalinglist; j++) { + + if (nextscale != 0) { + + unsigned delta_scale; + + err = get_ue_golomb(gb, &delta_scale); + if (err) + return err; + + nextscale = (lastscale + delta_scale + 256) % 256; + + *usedefaultscalingmatrix = (j==0 && nextscale==0); + } + + scaling_list[j] = (nextscale==0) ? lastscale : nextscale; + + lastscale = scaling_list[j]; + } + + return 0; +} + + +static int decode_scaling_matrix(struct getbit *gb, unsigned chroma_format_idc) +{ + unsigned scalinglist4x4[16]; + unsigned scalinglist8x8[64]; + bool usedefaultscalingmatrix[12]; + unsigned i; + int err; + + for (i = 0; i < ((chroma_format_idc != 3) ? 8 : 12); i++) { + + unsigned seq_scaling_list_present_flag; + + if (getbit_get_left(gb) < 1) + return EBADMSG; + + seq_scaling_list_present_flag = get_bit(gb); + + if (seq_scaling_list_present_flag) { + + if (i < 6) { + err = scaling_list(gb, scalinglist4x4, 16, + &usedefaultscalingmatrix[i]); + } + else { + err = scaling_list(gb, scalinglist8x8, 64, + &usedefaultscalingmatrix[i]); + } + + if (err) + return err; + } + } + + return 0; +} + + +/** + * Decode a Sequence Parameter Set (SPS) bitstream + * + * @param sps Decoded H.264 SPS + * @param p SPS bitstream to decode, excluding NAL header + * @param len Number of bytes + * + * @return 0 if success, otherwise errorcode + */ +int h264_sps_decode(struct h264_sps *sps, const uint8_t *p, size_t len) +{ + struct getbit gb; + uint8_t profile_idc; + unsigned seq_parameter_set_id; + unsigned frame_mbs_only_flag; + unsigned chroma_format_idc = 1; + bool frame_cropping_flag; + unsigned mb_w_m1; + unsigned mb_h_m1; + int err; + + if (!sps || !p || len < 3) + return EINVAL; + + memset(sps, 0, sizeof(*sps)); + + profile_idc = p[0]; + sps->level_idc = p[2]; + + getbit_init(&gb, p+3, (len-3)*8); + + err = get_ue_golomb(&gb, &seq_parameter_set_id); + if (err) + return err; + + if (seq_parameter_set_id >= MAX_SPS_COUNT) { + re_fprintf(stderr, "h264: sps: sps_id %u out of range\n", + seq_parameter_set_id); + return EBADMSG; + } + + if (profile_idc == 100 || + profile_idc == 110 || + profile_idc == 122 || + profile_idc == 244 || + profile_idc == 44 || + profile_idc == 83 || + profile_idc == 86 || + profile_idc == 118 || + profile_idc == 128 || + profile_idc == 138 || + profile_idc == 144) { + + unsigned seq_scaling_matrix_present_flag; + + err = get_ue_golomb(&gb, &chroma_format_idc); + if (err) + return err; + + if (chroma_format_idc > 3U) { + return EBADMSG; + } + else if (chroma_format_idc == 3) { + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + + /* separate_colour_plane_flag */ + (void)get_bit(&gb); + } + + /* bit_depth_luma/chroma */ + err = get_ue_golomb(&gb, NULL); + err |= get_ue_golomb(&gb, NULL); + if (err) + return err; + + if (getbit_get_left(&gb) < 2) + return EBADMSG; + + /* qpprime_y_zero_transform_bypass_flag */ + get_bit(&gb); + + seq_scaling_matrix_present_flag = get_bit(&gb); + if (seq_scaling_matrix_present_flag) { + + err = decode_scaling_matrix(&gb, chroma_format_idc); + if (err) + return err; + } + } + + err = get_ue_golomb(&gb, &sps->log2_max_frame_num); + if (err) + return err; + + sps->log2_max_frame_num += 4; + + if (sps->log2_max_frame_num > MAX_LOG2_MAX_FRAME_NUM) { + re_fprintf(stderr, "h264: sps: log2_max_frame_num" + " out of range: %u\n", sps->log2_max_frame_num); + return EBADMSG; + } + + err = get_ue_golomb(&gb, &sps->pic_order_cnt_type); + if (err) + return err; + + if (sps->pic_order_cnt_type == 0) { + + /* log2_max_pic_order_cnt_lsb */ + err = get_ue_golomb(&gb, NULL); + if (err) + return err; + } + else if (sps->pic_order_cnt_type == 2) { + } + else { + re_fprintf(stderr, "h264: sps: WARNING:" + " unknown pic_order_cnt_type (%u)\n", + sps->pic_order_cnt_type); + return ENOTSUP; + } + + err = get_ue_golomb(&gb, &sps->max_num_ref_frames); + if (err) + return err; + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + + /* gaps_in_frame_num_value_allowed_flag */ + (void)get_bit(&gb); + + err = get_ue_golomb(&gb, &mb_w_m1); + err |= get_ue_golomb(&gb, &mb_h_m1); + if (err) + return err; + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + frame_mbs_only_flag = get_bit(&gb); + + sps->pic_width_in_mbs = mb_w_m1 + 1; + sps->pic_height_in_map_units = mb_h_m1 + 1; + + sps->pic_height_in_map_units *= 2 - frame_mbs_only_flag; + + if (sps->pic_width_in_mbs >= MAX_MACROBLOCKS || + sps->pic_height_in_map_units >= MAX_MACROBLOCKS) { + re_fprintf(stderr, "h264: sps: width/height overflow\n"); + return EBADMSG; + } + + if (!frame_mbs_only_flag) { + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + + /* mb_adaptive_frame_field_flag */ + (void)get_bit(&gb); + } + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + + /* direct_8x8_inference_flag */ + (void)get_bit(&gb); + + if (getbit_get_left(&gb) < 1) + return EBADMSG; + + frame_cropping_flag = get_bit(&gb); + + if (frame_cropping_flag) { + + unsigned crop_left; + unsigned crop_right; + unsigned crop_top; + unsigned crop_bottom; + + unsigned vsub = (chroma_format_idc == 1) ? 1 : 0; + unsigned hsub = (chroma_format_idc == 1 || + chroma_format_idc == 2) ? 1 : 0; + unsigned sx = 1u << hsub; + unsigned sy = (2u - frame_mbs_only_flag) << vsub; + + unsigned w = MACROBLOCK_SIZE * sps->pic_width_in_mbs; + unsigned h = MACROBLOCK_SIZE * sps->pic_height_in_map_units; + + err = get_ue_golomb(&gb, &crop_left); + err |= get_ue_golomb(&gb, &crop_right); + err |= get_ue_golomb(&gb, &crop_top); + err |= get_ue_golomb(&gb, &crop_bottom); + if (err) + return err; + + if ((crop_left + crop_right ) * sx >= w || + (crop_top + crop_bottom) * sy >= h) { + re_fprintf(stderr, "h264: sps: crop values invalid" + " %u %u %u %u / %u %u\n", + crop_left, crop_right, crop_top, + crop_bottom, w, h); + return EBADMSG; + } + + sps->frame_crop_left_offset = sx * crop_left; + sps->frame_crop_right_offset = sx * crop_right; + sps->frame_crop_top_offset = sy * crop_top; + sps->frame_crop_bottom_offset = sy * crop_bottom; + } + + /* success */ + sps->profile_idc = profile_idc; + sps->seq_parameter_set_id = (uint8_t)seq_parameter_set_id; + sps->chroma_format_idc = chroma_format_idc; + + return 0; +} + + +void h264_sps_resolution(const struct h264_sps *sps, struct vidsz *sz) +{ + if (!sps || !sz) + return; + + sz->w = MACROBLOCK_SIZE * sps->pic_width_in_mbs + - sps->frame_crop_left_offset + - sps->frame_crop_right_offset; + + sz->h = MACROBLOCK_SIZE * sps->pic_height_in_map_units + - sps->frame_crop_top_offset + - sps->frame_crop_bottom_offset; +} + + +const char *h264_sps_chroma_format_name(uint8_t chroma_format_idc) +{ + switch (chroma_format_idc) { + + case 0: return "monochrome"; + case 1: return "YUV420"; + case 2: return "YUV422"; + case 3: return "YUV444"; + default: return "???"; + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rem-0.6.0/src/vid/frame.c new/rem-1.0.0/src/vid/frame.c --- old/rem-0.6.0/src/vid/frame.c 2018-11-23 13:59:48.000000000 +0100 +++ new/rem-1.0.0/src/vid/frame.c 2021-04-09 13:05:40.000000000 +0200 @@ -188,7 +188,8 @@ void vidframe_fill(struct vidframe *vf, uint32_t r, uint32_t g, uint32_t b) { uint8_t *p; - unsigned h, i; + unsigned h, i, x; + int u, v; if (!vf) return; @@ -221,6 +222,34 @@ } break; + case VID_FMT_NV12: + case VID_FMT_NV21: + h = vf->size.h; + + if (vf->fmt == VID_FMT_NV12) { + u = rgb2u(r, g, b); + v = rgb2v(r, g, b); + } + else { + v = rgb2u(r, g, b); + u = rgb2v(r, g, b); + } + + memset(vf->data[0], rgb2y(r, g, b), h * vf->linesize[0]); + + p = vf->data[1]; + + for (h=0; h<vf->size.h; h+=2) { + + for (x=0; x<vf->size.w; x+=2) { + p[x ] = u; + p[x+1] = v; + } + + p += vf->linesize[1]; + } + break; + default: (void)re_printf("vidfill: no fmt %s\n", vidfmt_name(vf->fmt)); break;