[FFmpeg-devel] [PATCH] doc/general_contents.texi: add uavs3d section

2020-10-06 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 doc/general_contents.texi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 598e0e74da..f441a75ee9 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -119,6 +119,14 @@ libdavs2 is under the GNU Public License Version 2 or later
 details), you must upgrade FFmpeg's license to GPL in order to use it.
 @end float
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @section Game Music Emu
 
 FFmpeg can make use of the Game Music Emu library to read audio from supported 
video game
@@ -816,6 +824,8 @@ following image formats are supported:
 @tab Video encoding used by the Creature Shock game.
 @item AVS2-P2/IEEE1857.4 @tab  E  @tab  E
 @tab Supported through external libraries libxavs2 and libdavs2
+@item AVS3-P2/IEEE1857.10@tab @tab  E
+@tab Supported through external library libuavs3d
 @item AYUV   @tab  X  @tab  X
 @tab Microsoft uncompressed packed 4:4:4:4
 @item Beam Software VB   @tab @tab  X
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v9 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-31 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 262 +
 libavcodec/version.h   |   4 +-
 8 files changed, 300 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index e68461e85c..40300d6756 100644
--- a/Changelog
+++ b/Changelog
@@ -16,6 +16,7 @@ version :
 - AV1 Low overhead bitstream format demuxer
 - RPZA video encoder
 - AVS3 bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 564072053b..c84c857d45 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index d618565347..d68b9c69b7 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5a2ddf8560..d391e1401f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1033,6 +1033,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c

[FFmpeg-devel] [PATCH v9 3/5] lavc/avs3_parser: add avs3 parser

2020-08-31 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 179 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 181 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ca2e8a2530..5a2ddf8560 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1060,6 +1060,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..bf97f75db6
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (AVS3_ISPIC(buf[cur])){
+cur++;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && AVS3_ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+avctx->framerate.den = avctx->time_base.num = 

[FFmpeg-devel] [PATCH v9 1/5] lavc: add AVS3 codec id and desc

2020-08-31 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v9 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-31 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 5 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/Changelog b/Changelog
index 7467e73306..e68461e85c 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
 - RPZA video encoder
+- AVS3 bitstream format demuxer
 
 
 version 4.3:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..a85f6f6c0b
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (AVS3_ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index 88876aec79..09444893eb 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH v9 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-31 Thread hwrenx
From: hwren 

*** Latest changes ***
Put AVS3 related definitions in sigle avs3.h file.


*** Historical  changes ***
=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

=== Version 6 ===
Fix incorrect code style problems.
Remove confused comments.
Add missing demuxer entry in Changelog.
Add value check in lavc/libuavs3d.c

=== Version 7 ===
Supplement information in dec_frame, including pkt_pos, pkt_size, 
coded_picture_number
and display_picture_number.

=== Version 8 ===
Pickup missing changes from previous version.

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definitions
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   2 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.h| 118 ++
 libavcodec/avs3_parser.c | 179 ++
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 262 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   4 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 ++
 libavformat/version.h|   2 +-
 17 files changed, 679 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v9 2/5] lavc/avs3: add AVS3 related definitions

2020-08-31 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/avs3.h | 118 ++
 1 file changed, 118 insertions(+)
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..4189d9b583
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,118 @@
+/*
+ *  AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AVS3_H
+#define AVCODEC_AVS3_H
+
+#define AVS3_NAL_START_CODE  0x01
+#define AVS3_SEQ_START_CODE  0xB0
+#define AVS3_SEQ_END_CODE0xB1
+#define AVS3_USER_DATA_START_CODE0xB2
+#define AVS3_INTRA_PIC_START_CODE0xB3
+#define AVS3_UNDEF_START_CODE0xB4
+#define AVS3_EXTENSION_START_CODE0xB5
+#define AVS3_INTER_PIC_START_CODE0xB6
+#define AVS3_VIDEO_EDIT_CODE 0xB7
+#define AVS3_FIRST_SLICE_START_CODE  0x00
+#define AVS3_PROFILE_BASELINE_MAIN   0x20
+#define AVS3_PROFILE_BASELINE_MAIN10 0x22
+
+#define AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == 
AVS3_INTER_PIC_START_CODE)
+#define AVS3_ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || AVS3_ISPIC(x))
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+
+static const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+static const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+static const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+static const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+static const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
+
+#endif /* AVCODEC_AVS3_H */
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v8 2/5] lavc/avs3: add AVS3 related definitions

2020-08-26 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +
 libavcodec/avs3.h   | 52 +
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  avs3.h\
   bsf.h \
   codec.h   \
   codec_desc.h  \
@@ -32,6 +33,7 @@ OBJS = ac3_parser.o   
  \
avdct.o  \
avpacket.o   \
avpicture.o  \
+   avs3.o   \
bitstream.o  \
bitstream_filter.o   \
bitstream_filters.o  \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 00..411a6c39a0
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@
+/*
+ * AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..8653e7c476
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@
+/*
+ *  AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 

[FFmpeg-devel] [PATCH v8 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-26 Thread hwrenx
From: hwren 

*** Latest changes ***

Pickup missing changes from previous version.


*** Historical  changes ***
=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

=== Version 6 ===
Fix incorrect code style problems.
Remove confused comments.
Add missing demuxer entry in Changelog.
Add value check in lavc/libuavs3d.c

=== Version 7 ===
Supplement information in dec_frame, including pkt_pos, pkt_size, 
coded_picture_number
and display_picture_number.

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definitions
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   2 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.c|  95 ++
 libavcodec/avs3.h|  52 
 libavcodec/avs3_parser.c | 179 ++
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 262 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 ++
 libavformat/version.h|   2 +-
 18 files changed, 709 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v8 3/5] lavc/avs3_parser: add avs3 parser

2020-08-26 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 179 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 181 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1e0c4629d..4c596515ee 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..bf97f75db6
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (AVS3_ISPIC(buf[cur])){
+cur++;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && AVS3_ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+avctx->framerate.den = avctx->time_base.num = 

[FFmpeg-devel] [PATCH v8 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-26 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 5 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/Changelog b/Changelog
index 1efc768387..f70ed4927a 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 bitstream format demuxer
 
 
 version 4.3:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..a85f6f6c0b
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (AVS3_ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index aa309ecc77..146db09d1b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH v8 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-26 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 262 +
 libavcodec/version.h   |   2 +-
 8 files changed, 299 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index f70ed4927a..a0e171d496 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
 - AVS3 bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c596515ee..5654b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1034,6 +1034,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c 

[FFmpeg-devel] [PATCH v8 1/5] lavc: add AVS3 codec id and desc

2020-08-26 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-23 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 248 +
 libavcodec/version.h   |   2 +-
 8 files changed, 285 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index 1efc768387..91794629e5 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c596515ee..5654b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1034,6 +1034,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c 

[FFmpeg-devel] [PATCH v7 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-23 Thread hwrenx
From: hwren 

*** Latest changes ***
Supplement information in dec_frame, including pkt_pos, pkt_size, 
coded_picture_number
and display_picture_number.

Will push if no more comments. Thanks.

*** Historical  changes ***
=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

=== Version 6 ===
Fix incorrect code style problems.
Remove confused comments.
Add missing demuxer entry in Changelog.
Add value check in lavc/libuavs3d.c

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definition
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.c|  95 +++
 libavcodec/avs3.h|  52 
 libavcodec/avs3_parser.c | 180 
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 248 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 +++
 libavformat/version.h|   2 +-
 18 files changed, 695 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 1/5] lavc: add AVS3 codec id and desc

2020-08-23 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 2/5] lavc/avs3: add AVS3 related definition

2020-08-23 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +
 libavcodec/avs3.h   | 52 +
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  avs3.h\
   bsf.h \
   codec.h   \
   codec_desc.h  \
@@ -32,6 +33,7 @@ OBJS = ac3_parser.o   
  \
avdct.o  \
avpacket.o   \
avpicture.o  \
+   avs3.o   \
bitstream.o  \
bitstream_filter.o   \
bitstream_filters.o  \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 00..8587e36def
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@
+/*
+ * AVS3 related definition
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
\ No newline at end of file
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..9f79adb7bf
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@
+/*
+ *  AVS3 related definition
+ *
+ * 

[FFmpeg-devel] [PATCH v7 3/5] lavc/avs3_parser: add avs3 parser

2020-08-23 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 180 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 182 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1e0c4629d..4c596515ee 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..36ca19797d
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,180 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+//low_delay
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+

[FFmpeg-devel] [PATCH v7 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-23 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 4 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..af14550b55
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index aa309ecc77..146db09d1b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/3] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavformat/Makefile   | 2 +-
 libavformat/{davs2.c => avs2dec.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename libavformat/{davs2.c => avs2dec.c} (100%)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8587197f66 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,7 +120,7 @@ OBJS-$(CONFIG_AVI_MUXER) += avienc.o 
mpegtsenc.o avlanguage.o ra
 OBJS-$(CONFIG_AVM2_MUXER)+= swfenc.o swf.o
 OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
-OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
+OBJS-$(CONFIG_AVS2_DEMUXER)  += avs2dec.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
similarity index 100%
rename from libavformat/davs2.c
rename to libavformat/avs2dec.c
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 1/3] lavc/avs2_parser.c, lavf/davs2.c: Add AVS2_* prefix

2020-08-20 Thread hwrenx
From: hwren 

Add AVS2_* prefix to macro definitions to avoid confusion

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 10 +-
 libavformat/davs2.c  | 20 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b3423ff..02af08f079 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -21,10 +21,10 @@
 
 #include "parser.h"
 
-#define SLICE_MAX_START_CODE0x01af
+#define AVS2_SLICE_MAX_START_CODE 0x01AF
 
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || 
AVS2_ISPIC(x))
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
@@ -35,7 +35,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
 state = (state<<8) | buf[cur];
-if (ISUNIT(buf[cur])){
+if (AVS2_ISUNIT(buf[cur])){
 ++cur;
 pic_found = 1;
 break;
@@ -48,7 +48,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 for (; cur < buf_size; ++cur) {
 state = (state << 8) | buf[cur];
-if ((state & 0xFF00) == 0x100 && state > SLICE_MAX_START_CODE) 
{
+if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
 pc->state = -1;
 return cur - 3;
diff --git a/libavformat/davs2.c b/libavformat/davs2.c
index 59f41fd499..f8337ea500 100644
--- a/libavformat/davs2.c
+++ b/libavformat/davs2.c
@@ -25,11 +25,11 @@
 #include "libavcodec/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define ISSQH(x)  ((x) == 0xB0 )
-#define ISEND(x)  ((x) == 0xB1 )
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
-#define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
+#define AVS2_ISSQH(x)  ((x) == 0xB0)
+#define AVS2_ISEND(x)  ((x) == 0xB1)
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) (AVS2_ISSQH(x) || AVS2_ISEND(x) || (x) == 0xB2 || 
AVS2_ISPIC(x) || (x) == 0xB5 || (x) == 0xB7)
+#define AVS2_ISPROFILE(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 
0x32)
 
 static int avs2_probe(const AVProbeData *p)
 {
@@ -44,18 +44,18 @@ static int avs2_probe(const AVProbeData *p)
 ptr = avpriv_find_start_code(ptr, end, );
 state = code & 0xFF;
 if ((code & 0xff00) == 0x100) {
-if (ISUNIT(state)) {
+if (AVS2_ISUNIT(state)) {
 if (sqb && !hds) {
 hds = ptr - sqb;
 }
-if (ISSQH(state)) {
-if (!ISAVS2(*ptr))
+if (AVS2_ISSQH(state)) {
+if (!AVS2_ISPROFILE(*ptr))
 return 0;
 sqb = ptr;
 seq++;
-} else if (ISPIC(state)) {
+} else if (AVS2_ISPIC(state)) {
 pic++;
-} else if (ISEND(state)) {
+} else if (AVS2_ISEND(state)) {
 break;
 }
 }
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 3/3] lavc/avs2_parser.c, lavf/avs2dec.c: fix code style

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 6 +++---
 libavformat/avs2dec.c| 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 02af08f079..54f687142f 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -34,9 +34,9 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
-state = (state<<8) | buf[cur];
+state = (state << 8) | buf[cur];
 if (AVS2_ISUNIT(buf[cur])){
-++cur;
+cur++;
 pic_found = 1;
 break;
 }
@@ -46,7 +46,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (pic_found) {
 if (!buf_size)
 return END_NOT_FOUND;
-for (; cur < buf_size; ++cur) {
+for (; cur < buf_size; cur++) {
 state = (state << 8) | buf[cur];
 if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
diff --git a/libavformat/avs2dec.c b/libavformat/avs2dec.c
index f8337ea500..51908d2b63 100644
--- a/libavformat/avs2dec.c
+++ b/libavformat/avs2dec.c
@@ -33,9 +33,9 @@
 
 static int avs2_probe(const AVProbeData *p)
 {
-uint32_t code= -1, hds=0, pic=0, seq=0;
-uint8_t state=0;
-const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
+uint32_t code = -1, hds = 0, pic = 0, seq = 0;
+uint8_t state = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb = 0;
 if (AV_RB32(p->buf) != 0x1B0){
 return 0;
 }
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] lavc/avs2_parser.c, lavf/davs2.c: Add AVS2_* prefix

2020-08-20 Thread hwrenx
From: hwren 

Add AVS2_* prefix to macro definitions to avoid confusion

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 10 +-
 libavformat/davs2.c  | 20 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b3423ff..02af08f079 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -21,10 +21,10 @@
 
 #include "parser.h"
 
-#define SLICE_MAX_START_CODE0x01af
+#define AVS2_SLICE_MAX_START_CODE 0x01AF
 
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || 
AVS2_ISPIC(x))
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
@@ -35,7 +35,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
 state = (state<<8) | buf[cur];
-if (ISUNIT(buf[cur])){
+if (AVS2_ISUNIT(buf[cur])){
 ++cur;
 pic_found = 1;
 break;
@@ -48,7 +48,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 for (; cur < buf_size; ++cur) {
 state = (state << 8) | buf[cur];
-if ((state & 0xFF00) == 0x100 && state > SLICE_MAX_START_CODE) 
{
+if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
 pc->state = -1;
 return cur - 3;
diff --git a/libavformat/davs2.c b/libavformat/davs2.c
index 59f41fd499..f8337ea500 100644
--- a/libavformat/davs2.c
+++ b/libavformat/davs2.c
@@ -25,11 +25,11 @@
 #include "libavcodec/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define ISSQH(x)  ((x) == 0xB0 )
-#define ISEND(x)  ((x) == 0xB1 )
-#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
-#define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
+#define AVS2_ISSQH(x)  ((x) == 0xB0)
+#define AVS2_ISEND(x)  ((x) == 0xB1)
+#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define AVS2_ISUNIT(x) (AVS2_ISSQH(x) || AVS2_ISEND(x) || (x) == 0xB2 || 
AVS2_ISPIC(x) || (x) == 0xB5 || (x) == 0xB7)
+#define AVS2_ISPROFILE(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 
0x32)
 
 static int avs2_probe(const AVProbeData *p)
 {
@@ -44,18 +44,18 @@ static int avs2_probe(const AVProbeData *p)
 ptr = avpriv_find_start_code(ptr, end, );
 state = code & 0xFF;
 if ((code & 0xff00) == 0x100) {
-if (ISUNIT(state)) {
+if (AVS2_ISUNIT(state)) {
 if (sqb && !hds) {
 hds = ptr - sqb;
 }
-if (ISSQH(state)) {
-if (!ISAVS2(*ptr))
+if (AVS2_ISSQH(state)) {
+if (!AVS2_ISPROFILE(*ptr))
 return 0;
 sqb = ptr;
 seq++;
-} else if (ISPIC(state)) {
+} else if (AVS2_ISPIC(state)) {
 pic++;
-} else if (ISEND(state)) {
+} else if (AVS2_ISEND(state)) {
 break;
 }
 }
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] lavf/davs2.c: Rename as avs2dec.c for better understanding

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavformat/{davs2.c => avs2dec.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename libavformat/{davs2.c => avs2dec.c} (100%)

diff --git a/libavformat/davs2.c b/libavformat/avs2dec.c
similarity index 100%
rename from libavformat/davs2.c
rename to libavformat/avs2dec.c
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] lavc/avs2_parser.c, lavf/avs2dec.c: fix code style

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/avs2_parser.c | 6 +++---
 libavformat/avs2dec.c| 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 02af08f079..54f687142f 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -34,9 +34,9 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
-state = (state<<8) | buf[cur];
+state = (state << 8) | buf[cur];
 if (AVS2_ISUNIT(buf[cur])){
-++cur;
+cur++;
 pic_found = 1;
 break;
 }
@@ -46,7 +46,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (pic_found) {
 if (!buf_size)
 return END_NOT_FOUND;
-for (; cur < buf_size; ++cur) {
+for (; cur < buf_size; cur++) {
 state = (state << 8) | buf[cur];
 if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
 pc->frame_start_found = 0;
diff --git a/libavformat/avs2dec.c b/libavformat/avs2dec.c
index f8337ea500..51908d2b63 100644
--- a/libavformat/avs2dec.c
+++ b/libavformat/avs2dec.c
@@ -33,9 +33,9 @@
 
 static int avs2_probe(const AVProbeData *p)
 {
-uint32_t code= -1, hds=0, pic=0, seq=0;
-uint8_t state=0;
-const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
+uint32_t code = -1, hds = 0, pic = 0, seq = 0;
+uint8_t state = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb = 0;
 if (AV_RB32(p->buf) != 0x1B0){
 return 0;
 }
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v6 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-20 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

=== Version 6 ===
Fix incorrect code style problems.
Remove confused comments.
Add missing demuxer entry in Changelog.
Add value check in lavc/libuavs3d.c

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definitions
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   2 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.c|  95 +++
 libavcodec/avs3.h|  52 +
 libavcodec/avs3_parser.c | 179 +
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 241 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 +++
 libavformat/version.h|   2 +-
 18 files changed, 688 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v6 1/5] lavc: add AVS3 codec id and desc

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v6 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 255 +
 libavcodec/version.h   |   2 +-
 8 files changed, 292 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index f70ed4927a..a0e171d496 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
 - AVS3 bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c596515ee..5654b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1034,6 +1034,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c 

[FFmpeg-devel] [PATCH v6 2/5] lavc/avs3: add AVS3 related definitions

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +
 libavcodec/avs3.h   | 52 +
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  avs3.h\
   bsf.h \
   codec.h   \
   codec_desc.h  \
@@ -32,6 +33,7 @@ OBJS = ac3_parser.o   
  \
avdct.o  \
avpacket.o   \
avpicture.o  \
+   avs3.o   \
bitstream.o  \
bitstream_filter.o   \
bitstream_filters.o  \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 00..411a6c39a0
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@
+/*
+ * AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..8653e7c476
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@
+/*
+ *  AVS3 related definitions
+ *
+ * Copyright (C) 2020 Huiwen Ren, 

[FFmpeg-devel] [PATCH v6 3/5] lavc/avs3_parser: add avs3 parser

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 179 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 181 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1e0c4629d..4c596515ee 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..bf97f75db6
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (AVS3_ISPIC(buf[cur])){
+cur++;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && AVS3_ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+avctx->framerate.den = avctx->time_base.num = 

[FFmpeg-devel] [PATCH v6 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-20 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 5 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/Changelog b/Changelog
index 1efc768387..f70ed4927a 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 bitstream format demuxer
 
 
 version 4.3:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..a85f6f6c0b
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (AVS3_ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index aa309ecc77..146db09d1b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH v5 5/5] lavc, doc: add libuavs3d video decoder wrapper

2020-08-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 241 +
 libavcodec/version.h   |   2 +-
 8 files changed, 278 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index 1efc768387..91794629e5 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c596515ee..5654b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1034,6 +1034,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c 

[FFmpeg-devel] [PATCH v5 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-19 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS.
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

=== Version 5 ===
Fix the wrong codec order in lavc/codec_desc.c
Use additional lavc/avs3.h and lavc/avs3.c for common definitions
Remove redundant description in the long name of libuavs3d.
Update iteration information in lavf/version.h and lavc/version.h.

Thanks.

hwren (5):
  lavc: add AVS3 codec id and desc
  lavc/avs3: add AVS3 related definitions
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3.c|  95 +++
 libavcodec/avs3.h|  52 +
 libavcodec/avs3_parser.c | 180 +
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 241 +++
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  68 +++
 libavformat/version.h|   2 +-
 18 files changed, 688 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 2/5] lavc/avs3: add AVS3 related definitions

2020-08-19 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/Makefile |  2 +
 libavcodec/avs3.c   | 95 +
 libavcodec/avs3.h   | 52 +
 3 files changed, 149 insertions(+)
 create mode 100644 libavcodec/avs3.c
 create mode 100644 libavcodec/avs3.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..e1e0c4629d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  avs3.h\
   bsf.h \
   codec.h   \
   codec_desc.h  \
@@ -32,6 +33,7 @@ OBJS = ac3_parser.o   
  \
avdct.o  \
avpacket.o   \
avpicture.o  \
+   avs3.o   \
bitstream.o  \
bitstream_filter.o   \
bitstream_filters.o  \
diff --git a/libavcodec/avs3.c b/libavcodec/avs3.c
new file mode 100644
index 00..8587e36def
--- /dev/null
+++ b/libavcodec/avs3.c
@@ -0,0 +1,95 @@
+/*
+ * AVS3 related definition
+ *
+ * Copyright (C) 2020 Huiwen Ren, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+
+const AVRational ff_avs3_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
+const int ff_avs3_color_primaries_tab[10] = {
+AVCOL_PRI_RESERVED0   ,// 0
+AVCOL_PRI_BT709   ,// 1
+AVCOL_PRI_UNSPECIFIED ,// 2
+AVCOL_PRI_RESERVED,// 3
+AVCOL_PRI_BT470M  ,// 4
+AVCOL_PRI_BT470BG ,// 5
+AVCOL_PRI_SMPTE170M   ,// 6
+AVCOL_PRI_SMPTE240M   ,// 7
+AVCOL_PRI_FILM,// 8
+AVCOL_PRI_BT2020   // 9
+};
+
+const int ff_avs3_color_transfer_tab[15] = {
+AVCOL_TRC_RESERVED0, // 0
+AVCOL_TRC_BT709, // 1
+AVCOL_TRC_UNSPECIFIED  , // 2
+AVCOL_TRC_RESERVED , // 3
+AVCOL_TRC_GAMMA22  , // 4
+AVCOL_TRC_GAMMA28  , // 5
+AVCOL_TRC_SMPTE170M, // 6
+AVCOL_TRC_SMPTE240M, // 7
+AVCOL_TRC_LINEAR   , // 8
+AVCOL_TRC_LOG  , // 9
+AVCOL_TRC_LOG_SQRT , // 10
+AVCOL_TRC_BT2020_12, // 11
+AVCOL_TRC_SMPTE2084, // 12
+AVCOL_TRC_UNSPECIFIED  , // 13
+AVCOL_TRC_ARIB_STD_B67   // 14
+};
+
+const int ff_avs3_color_matrix_tab[12] = {
+AVCOL_SPC_RESERVED , // 0
+AVCOL_SPC_BT709, // 1
+AVCOL_SPC_UNSPECIFIED  , // 2
+AVCOL_SPC_RESERVED , // 3
+AVCOL_SPC_FCC  , // 4
+AVCOL_SPC_BT470BG  , // 5
+AVCOL_SPC_SMPTE170M, // 6
+AVCOL_SPC_SMPTE240M, // 7
+AVCOL_SPC_BT2020_NCL   , // 8
+AVCOL_SPC_BT2020_CL, // 9
+AVCOL_SPC_UNSPECIFIED  , // 10
+AVCOL_SPC_UNSPECIFIED// 11
+};
+
+const enum AVPictureType ff_avs3_image_type[4] = {
+AV_PICTURE_TYPE_NONE,
+AV_PICTURE_TYPE_I,
+AV_PICTURE_TYPE_P,
+AV_PICTURE_TYPE_B
+};
\ No newline at end of file
diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h
new file mode 100644
index 00..9f79adb7bf
--- /dev/null
+++ b/libavcodec/avs3.h
@@ -0,0 +1,52 @@
+/*
+ *  AVS3 related definition
+ *
+ * 

[FFmpeg-devel] [PATCH v5 1/5] lavc: add AVS3 codec id and desc

2020-08-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..61473178fc 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 4/5] lavf/avs3dec: add raw avs3 demuxer

2020-08-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 libavformat/version.h|  2 +-
 4 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..af14550b55
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
diff --git a/libavformat/version.h b/libavformat/version.h
index aa309ecc77..146db09d1b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  51
+#define LIBAVFORMAT_VERSION_MINOR  52
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 3/5] lavc/avs3_parser: add avs3 parser

2020-08-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 180 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 182 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e1e0c4629d..4c596515ee 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..36ca19797d
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,180 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3.h"
+#include "get_bits.h"
+#include "parser.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+//low_delay
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = avctx->time_base.den = 
ff_avs3_frame_rate_tab[ratecode].num;
+

[FFmpeg-devel] [PATCH v4 2/4] lavc/avs3_parser: add avs3 parser

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 179 +++
 libavcodec/avs3_parser.h |  64 ++
 libavcodec/parsers.c |   1 +
 4 files changed, 245 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/avs3_parser.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3431ba2dca..5c031f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1059,6 +1059,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..f04f696a89
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,179 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avs3_parser.h"
+#include "get_bits.h"
+
+static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == AVS3_SEQ_START_CODE) {
+GetBitContext gb;
+int profile, ratecode;
+
+init_get_bits(, buf + 4, buf_size - 4);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+// Skip bits: level(8)
+//progressive(1)
+//field(1)
+//library(2)
+//resv(1)
+//width(14)
+//resv(1)
+//height(14)
+//chroma(2)
+//sampe_precision(3)
+skip_bits(, 47);
+
+if (profile == AVS3_PROFILE_BASELINE_MAIN10) {
+int sample_precision = get_bits(, 3);
+if (sample_precision == 1) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+} else if (sample_precision == 2) {
+avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}
+}
+
+// Skip bits: resv(1)
+//aspect(4)
+skip_bits(, 5);
+
+ratecode = get_bits(, 4);
+
+// Skip bits: resv(1)
+//bitrate_low(18)
+//resv(1)
+//bitrate_high(12)
+//low_delay
+skip_bits(, 32);
+
+avctx->has_b_frames = !get_bits(, 1);
+
+avctx->framerate.num = 

[FFmpeg-devel] [PATCH v4 0/4] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-18 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS,
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

=== Version 4 ===
Add avs3_parser.h for some reusable definitions in AVS3
Refine avs3_parser.c and libuavs3d.c
Fix some vague definitions and potential risks

Thanks.

hwren (4):
  lavc: add AVS3 codec id and desc
  lavc/avs3_parser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 +++
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3_parser.c | 179 
 libavcodec/avs3_parser.h |  64 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 294 +++
 libavcodec/parsers.c |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  69 +
 15 files changed, 654 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/avs3_parser.h
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 4/4] lavc, doc: add libuavs3d video decoder wrapper

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 +++
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 294 +
 7 files changed, 330 insertions(+)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index 1efc768387..91794629e5 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 6faff9bc7b..0fde821742 100755
--- a/configure
+++ b/configure
@@ -277,6 +277,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvmaf
 libvorbis
@@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue"
 libsvtav1_encoder_deps="libsvtav1"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" 
uavs3d.h uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.5.2" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..42b46fe153 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with 
davs2 library.
 
 @c man end VIDEO DECODERS
 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
+
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
 
diff --git a/doc/general.texi b/doc/general.texi
index fac5377504..233f69d349 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5c031f..31d5f39bcd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1032,6 +1032,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBSVTAV1_ENCODER)  += libsvtav1.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4bd830e5d0..04b990dd37 100644
--- 

[FFmpeg-devel] [PATCH v4 1/4] lavc: add AVS3 codec id and desc

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..c5259bf824 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1405,6 +1405,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_PGX,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..47aa0787b6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -242,6 +242,7 @@ enum AVCodecID {
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
 AV_CODEC_ID_PGX,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 3/4] lavf/avs3dec: add raw avs3 demuxer

2020-08-18 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 68 
 3 files changed, 70 insertions(+)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..8ddab3aee5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..7f41c12d7c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -84,6 +84,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..21c24893a9
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,68 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avs3_parser.h"
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+static int avs3video_probe(const AVProbeData *p)
+{
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+uint32_t code = -1;
+uint8_t state = 0;
+int pic = 0, seq = 0, slice_pos = 0;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+state = code & 0xFF;
+if ((code & 0xFF00) == 0x100) {
+if (state < AVS3_SEQ_START_CODE) {
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (state == AVS3_SEQ_START_CODE) {
+seq++;
+if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != 
AVS3_PROFILE_BASELINE_MAIN10)
+return 0;
+} else if (ISPIC(state)) {
+pic++;
+} else if ((state == AVS3_UNDEF_START_CODE) ||
+   (state > AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
\ No newline at end of file
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 2/4] lavc/avs3_paeser: add avs3 parser

2020-08-05 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 184 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 186 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5a6ea59715..f1512779be 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1053,6 +1053,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..7a7f826c59
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,184 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "parser.h"
+
+#define SLICE_MAX_START_CODE0x01af
+
+#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define ISUNIT(x) ((x) == 0xB0 || ISPIC(x))
+
+static av_cold int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, 
int buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state<<8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static unsigned int read_bits(const char** ppbuf, int *pidx, int bits) 
+{
+const char* p = *ppbuf;
+int idx = *pidx;
+unsigned int val = 0;
+
+while (bits) {
+bits--;
+val = (val << 1) | (((*p) >> idx) & 0x1);
+if (--idx < 0) {
+idx = 7;
+p++;
+}
+}
+
+*ppbuf = p;
+*pidx = idx;
+
+return val;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == 0xB0) {
+static const int avs3_fps_num[9] = {0, 24, 24, 25, 3, 30, 
50, 6, 60 };
+static const int avs3_fps_den[9] = {1,   1001,  1,  1,  1001,  1,  
1,  1001,  1 };
+int profile,ratecode;
+const char* p = buf + 4;
+int idx = 7;
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = read_bits(, , 8);
+// level(8) + progressive(1) + field(1) + library(2) + resv(1) + 
width(14) + resv(1) + height(14) + chroma(2) + sampe_precision(3)
+read_bits(, , 47); 
+
+if (profile == 0x22) {
+avctx->pix_fmt = read_bits(, , 3) == 1 ? 
AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV420P10LE;
+} 
+
+// resv(1) + aspect(4)
+read_bits(, , 5);
+
+ratecode = read_bits(, , 4);
+
+// resv(1) + bitrate_low(18) + resv(1) + bitrate_high(12)
+read_bits(, , 32);
+
+avctx->has_b_frames = !read_bits(, , 1);
+
+avctx->framerate.num = avctx->time_base.den = 
avs3_fps_num[ratecode];
+avctx->framerate.den = 

[FFmpeg-devel] [PATCH v3 4/4] lavc, doc: add libuavs3d video decoder wrapper

2020-08-05 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 +++
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 283 +
 7 files changed, 319 insertions(+)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index a60e7d2eb8..dfd56b3fc6 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - AudioToolbox output device
 - MacCaption demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 7495f35faa..7340bc4a35 100755
--- a/configure
+++ b/configure
@@ -274,6 +274,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1807,6 +1808,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvorbis
 libvpx
@@ -3242,6 +3244,7 @@ libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6379,6 +6382,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d uavs3d uavs3d.h 
uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.3.9" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..f1a0b3c36e 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -86,6 +86,27 @@ AVS2-P2/IEEE1857.4 video decoder wrapper.
 
 This decoder allows libavcodec to decode AVS2 streams with davs2 library.
 
+@c man end VIDEO DECODERS
+ 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
 @c man end VIDEO DECODERS
 
 @chapter Audio Decoders
diff --git a/doc/general.texi b/doc/general.texi
index 9b0ee96752..6d673b74e1 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1512779be..491485f3c0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 80f128cade..3d2d0af87a 100644
--- 

[FFmpeg-devel] [PATCH v3 0/4] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-08-05 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS,
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

=== Version 3 ===
Rename parameter names that may be confused with AVS2
Reorder header files.

Thanks.

hwren (4):
  lavc: add AVS3 codec id and desc
  lavc/avs3_paeser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 +++
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3_parser.c | 184 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 283 +++
 libavcodec/parsers.c |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  75 +++
 14 files changed, 590 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 1/4] lavc: add AVS3 codec id and desc

2020-08-05 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9f8847544f..ad55d992d3 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1405,6 +1405,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index d885962c9c..7f7dee51f1 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -241,6 +241,7 @@ enum AVCodecID {
 AV_CODEC_ID_SCREENPRESSO,
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 3/4] lavf/avs3dec: add raw avs3 demuxer

2020-08-05 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 75 
 3 files changed, 77 insertions(+)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 26af859a28..b433a6029c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,6 +120,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 97fd06debb..2d768b8c88 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -82,6 +82,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..955114dc42
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,75 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/internal.h"
+#include "avformat.h"
+#include "rawdec.h"
+
+#define AVS3_SEQ_START_CODE   0x01b0
+#define AVS3_PIC_I_START_CODE 0x01b3
+#define AVS3_UNDEF_START_CODE 0x01b4
+#define AVS3_PIC_PB_START_CODE0x01b6
+#define AVS3_VIDEO_EDIT_CODE  0x01b7
+#define AVS3_PROFILE_JIZHUN   0x20
+#define AVS3_PROFILE_JIZHUN10 0x22
+
+static int avs3video_probe(const AVProbeData *p)
+{
+uint32_t code= -1;
+int pic=0, seq=0, slice_pos = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+if ((code & 0xff00) == 0x100) {
+if (code < AVS3_SEQ_START_CODE) {
+/* slices have to be consecutive */
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (code == AVS3_SEQ_START_CODE) {
+seq++;
+/* check for the only currently supported profile */
+if (*ptr != AVS3_PROFILE_JIZHUN && *ptr != 
AVS3_PROFILE_JIZHUN10)
+return 0;
+} else if ((code == AVS3_PIC_I_START_CODE) ||
+   (code == AVS3_PIC_PB_START_CODE)) {
+pic++;
+} else if ((code == AVS3_UNDEF_START_CODE) ||
+   (code >  AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
+
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavc/libxavs2.c: mark key-frame packets

2020-07-27 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 76b57e731e..8519f6925a 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -223,6 +223,12 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 pkt->pts = cae->packet.pts;
 pkt->dts = cae->packet.dts;
 
+if (cae->packet.type == XAVS2_TYPE_IDR ||
+cae->packet.type == XAVS2_TYPE_I ||
+cae->packet.type == XAVS2_TYPE_KEYFRAME) {
+pkt->flags |= AV_PKT_FLAG_KEY;
+}
+
 memcpy(pkt->data, cae->packet.stream, cae->packet.len);
 pkt->size = cae->packet.len;
 
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 4/4] lavc, doc: add libuavs3d video decoder wrapper

2020-06-22 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 +++
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 283 +
 7 files changed, 319 insertions(+)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index a60e7d2eb8..dfd56b3fc6 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - AudioToolbox output device
 - MacCaption demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 7495f35faa..7340bc4a35 100755
--- a/configure
+++ b/configure
@@ -274,6 +274,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1807,6 +1808,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvorbis
 libvpx
@@ -3242,6 +3244,7 @@ libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6379,6 +6382,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d uavs3d uavs3d.h 
uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.3.9" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714e3c..f1a0b3c36e 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -86,6 +86,27 @@ AVS2-P2/IEEE1857.4 video decoder wrapper.
 
 This decoder allows libavcodec to decode AVS2 streams with davs2 library.
 
+@c man end VIDEO DECODERS
+ 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
 @c man end VIDEO DECODERS
 
 @chapter Audio Decoders
diff --git a/doc/general.texi b/doc/general.texi
index 9b0ee96752..6d673b74e1 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1512779be..491485f3c0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 80f128cade..3d2d0af87a 100644
--- 

[FFmpeg-devel] [PATCH v2 1/4] lavc: add AVS3 codec id and desc

2020-06-22 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9f8847544f..ad55d992d3 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1405,6 +1405,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index d885962c9c..7f7dee51f1 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -241,6 +241,7 @@ enum AVCodecID {
 AV_CODEC_ID_SCREENPRESSO,
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 3/4] lavf/avs3dec: add raw avs3 demuxer

2020-06-22 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 75 
 3 files changed, 77 insertions(+)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 26af859a28..b433a6029c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,6 +120,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 97fd06debb..2d768b8c88 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -82,6 +82,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 00..955114dc42
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,75 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+#include "libavcodec/internal.h"
+
+#define AVS3_SEQ_START_CODE   0x01b0
+#define AVS3_PIC_I_START_CODE 0x01b3
+#define AVS3_UNDEF_START_CODE 0x01b4
+#define AVS3_PIC_PB_START_CODE0x01b6
+#define AVS3_VIDEO_EDIT_CODE  0x01b7
+#define AVS3_PROFILE_JIZHUN   0x20
+#define AVS3_PROFILE_JIZHUN10 0x22
+
+static int avs3video_probe(const AVProbeData *p)
+{
+uint32_t code= -1;
+int pic=0, seq=0, slice_pos = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+if ((code & 0xff00) == 0x100) {
+if (code < AVS3_SEQ_START_CODE) {
+/* slices have to be consecutive */
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (code == AVS3_SEQ_START_CODE) {
+seq++;
+/* check for the only currently supported profile */
+if (*ptr != AVS3_PROFILE_JIZHUN && *ptr != 
AVS3_PROFILE_JIZHUN10)
+return 0;
+} else if ((code == AVS3_PIC_I_START_CODE) ||
+   (code == AVS3_PIC_PB_START_CODE)) {
+pic++;
+} else if ((code == AVS3_UNDEF_START_CODE) ||
+   (code >  AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+if (seq && pic && av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+}
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
+
-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/4] lavc/avs3_paeser: add avs3 parser

2020-06-22 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 184 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 186 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5a6ea59715..f1512779be 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1053,6 +1053,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 00..7a7f826c59
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,184 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "parser.h"
+
+#define SLICE_MAX_START_CODE0x01af
+
+#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define ISUNIT(x) ((x) == 0xB0 || ISPIC(x))
+
+static av_cold int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, 
int buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state<<8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static unsigned int read_bits(const char** ppbuf, int *pidx, int bits) 
+{
+const char* p = *ppbuf;
+int idx = *pidx;
+unsigned int val = 0;
+
+while (bits) {
+bits--;
+val = (val << 1) | (((*p) >> idx) & 0x1);
+if (--idx < 0) {
+idx = 7;
+p++;
+}
+}
+
+*ppbuf = p;
+*pidx = idx;
+
+return val;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == 0xB0) {
+static const int avs3_fps_num[9] = {0, 24, 24, 25, 3, 30, 
50, 6, 60 };
+static const int avs3_fps_den[9] = {1,   1001,  1,  1,  1001,  1,  
1,  1001,  1 };
+int profile,ratecode;
+const char* p = buf + 4;
+int idx = 7;
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = read_bits(, , 8);
+// level(8) + progressive(1) + field(1) + library(2) + resv(1) + 
width(14) + resv(1) + height(14) + chroma(2) + sampe_precision(3)
+read_bits(, , 47); 
+
+if (profile == 0x22) {
+avctx->pix_fmt = read_bits(, , 3) == 1 ? 
AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV420P10LE;
+} 
+
+// resv(1) + aspect(4)
+read_bits(, , 5);
+
+ratecode = read_bits(, , 4);
+
+// resv(1) + bitrate_low(18) + resv(1) + bitrate_high(12)
+read_bits(, , 32);
+
+avctx->has_b_frames = !read_bits(, , 1);
+
+avctx->framerate.num = avctx->time_base.den = 
avs3_fps_num[ratecode];
+avctx->framerate.den = 

[FFmpeg-devel] [PATCH v2 0/4] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-06-22 Thread hwrenx
From: hwren 

=== Version1 ===
These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

=== Version 2 ===
Fix conflict with CAVS streams. Considering that there is no direct version 
flag in AVS,
AVS3 demuxer only supports raw streams in format <*.avs3>.

Fix API function conflict.

Thanks.

hwren (4):
  lavc: add AVS3 codec id and desc
  lavc/avs3_paeser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 +++
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3_parser.c | 184 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 283 +++
 libavcodec/parsers.c |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  75 +++
 14 files changed, 590 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.23.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 1/4] lavc: add AVS3 codec id and desc

2020-06-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9f88475..ad55d99 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1406,6 +1406,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_LOSSY,
 },
 {
+.id= AV_CODEC_ID_AVS3,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "avs3",
+.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"),
+.props = AV_CODEC_PROP_LOSSY,
+},
+{
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "y41p",
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index d885962..7f7dee5 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -241,6 +241,7 @@ enum AVCodecID {
 AV_CODEC_ID_SCREENPRESSO,
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
+AV_CODEC_ID_AVS3,
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 3/4] lavf/avs3dec: add raw avs3 demuxer

2020-06-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/avs3dec.c| 79 
 3 files changed, 81 insertions(+)
 create mode 100644 libavformat/avs3dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 26af859..b433a60 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,6 +120,7 @@ OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
 OBJS-$(CONFIG_AVS_DEMUXER)   += avs.o voc_packet.o vocdec.o voc.o
 OBJS-$(CONFIG_AVS2_DEMUXER)  += davs2.o rawdec.o
 OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o
+OBJS-$(CONFIG_AVS3_DEMUXER)  += avs3dec.o rawdec.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)   += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)   += bfi.o
 OBJS-$(CONFIG_BINK_DEMUXER)  += bink.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 97fd06d..2d768b8 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -82,6 +82,7 @@ extern AVInputFormat  ff_avr_demuxer;
 extern AVInputFormat  ff_avs_demuxer;
 extern AVInputFormat  ff_avs2_demuxer;
 extern AVOutputFormat ff_avs2_muxer;
+extern AVInputFormat  ff_avs3_demuxer;
 extern AVInputFormat  ff_bethsoftvid_demuxer;
 extern AVInputFormat  ff_bfi_demuxer;
 extern AVInputFormat  ff_bintext_demuxer;
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
new file mode 100644
index 000..9758071
--- /dev/null
+++ b/libavformat/avs3dec.c
@@ -0,0 +1,79 @@
+/*
+ * RAW AVS3-P2/IEEE1857.10 video demuxer
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+#include "libavcodec/internal.h"
+
+#define AVS3_SEQ_START_CODE   0x01b0
+#define AVS3_PIC_I_START_CODE 0x01b3
+#define AVS3_UNDEF_START_CODE 0x01b4
+#define AVS3_PIC_PB_START_CODE0x01b6
+#define AVS3_VIDEO_EDIT_CODE  0x01b7
+#define AVS3_PROFILE_JIZHUN   0x20
+#define AVS3_PROFILE_JIZHUN10 0x22
+
+static int avs3video_probe(const AVProbeData *p)
+{
+uint32_t code= -1;
+int pic=0, seq=0, slice_pos = 0;
+const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
+int ret = 0;
+
+while (ptr < end) {
+ptr = avpriv_find_start_code(ptr, end, );
+if ((code & 0xff00) == 0x100) {
+if (code < AVS3_SEQ_START_CODE) {
+/* slices have to be consecutive */
+if (code < slice_pos)
+return 0;
+slice_pos = code;
+} else {
+slice_pos = 0;
+}
+if (code == AVS3_SEQ_START_CODE) {
+seq++;
+/* check for the only currently supported profile */
+if (*ptr != AVS3_PROFILE_JIZHUN && *ptr != 
AVS3_PROFILE_JIZHUN10)
+return 0;
+} else if ((code == AVS3_PIC_I_START_CODE) ||
+   (code == AVS3_PIC_PB_START_CODE)) {
+pic++;
+} else if ((code == AVS3_UNDEF_START_CODE) ||
+   (code >  AVS3_VIDEO_EDIT_CODE)) {
+return 0;
+}
+}
+}
+if (seq && pic) {
+if (av_match_ext(p->filename, "avs3")) {
+ret = AVPROBE_SCORE_MAX;
+} else {
+ret = AVPROBE_SCORE_EXTENSION + 1;
+}
+}
+return ret;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, 
"avs3", AV_CODEC_ID_AVS3)
+
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 0/4] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d

2020-06-19 Thread hwrenx
From: hwren 

These patches are to supplement the third generation of Audio Video Coding 
Standard,
part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d 
wrapper.

The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d
AVS3 sample streams could be found in https://github.com/uavs3/avs3stream

hwren (4):
  lavc: add AVS3 codec id and desc
  lavc/avs3_paeser: add avs3 parser
  lavf/avs3dec: add raw avs3 demuxer
  lavc,doc: add libuavs3d video decoder wrapper

 Changelog|   1 +
 configure|   4 +
 doc/decoders.texi|  21 
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   2 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avs3_parser.c | 184 ++
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/codec_id.h|   1 +
 libavcodec/libuavs3d.c   | 283 +++
 libavcodec/parsers.c |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/avs3dec.c|  79 +
 14 files changed, 594 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c
 create mode 100644 libavcodec/libuavs3d.c
 create mode 100644 libavformat/avs3dec.c

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 2/4] lavc/avs3_paeser: add avs3 parser

2020-06-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 libavcodec/Makefile  |   1 +
 libavcodec/avs3_parser.c | 184 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 186 insertions(+)
 create mode 100644 libavcodec/avs3_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5a6ea59..f151277 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1053,6 +1053,7 @@ OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o 
aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_AV1_PARSER)  += av1_parser.o av1_parse.o
 OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o
+OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
 OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
new file mode 100644
index 000..7a7f826
--- /dev/null
+++ b/libavcodec/avs3_parser.c
@@ -0,0 +1,184 @@
+/*
+ * AVS3-P2/IEEE1857.10 video parser.
+ * Copyright (c) 2020 Zhenyu Wang 
+ *Bingjie Han 
+ *Huiwen Ren  
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "parser.h"
+
+#define SLICE_MAX_START_CODE0x01af
+
+#define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
+#define ISUNIT(x) ((x) == 0xB0 || ISPIC(x))
+
+static av_cold int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, 
int buf_size)
+{
+int pic_found  = pc->frame_start_found;
+uint32_t state = pc->state;
+int cur = 0;
+
+if (!pic_found) {
+for (; cur < buf_size; ++cur) {
+state = (state<<8) | buf[cur];
+if (ISPIC(buf[cur])){
+++cur;
+pic_found = 1;
+break;
+}
+}
+}
+
+if (pic_found) {
+if (!buf_size)
+return END_NOT_FOUND;
+for (; cur < buf_size; ++cur) {
+state = (state << 8) | buf[cur];
+if ((state & 0xFF00) == 0x100 && ISUNIT(state & 0xFF)) {
+pc->frame_start_found = 0;
+pc->state = -1;
+return cur - 3;
+}
+}
+}
+
+pc->frame_start_found = pic_found;
+pc->state = state;
+
+return END_NOT_FOUND;
+}
+
+static unsigned int read_bits(const char** ppbuf, int *pidx, int bits) 
+{
+const char* p = *ppbuf;
+int idx = *pidx;
+unsigned int val = 0;
+
+while (bits) {
+bits--;
+val = (val << 1) | (((*p) >> idx) & 0x1);
+if (--idx < 0) {
+idx = 7;
+p++;
+}
+}
+
+*ppbuf = p;
+*pidx = idx;
+
+return val;
+}
+
+static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5) {
+return;
+}
+
+if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
+if (buf[3] == 0xB0) {
+static const int avs3_fps_num[9] = {0, 24, 24, 25, 3, 30, 
50, 6, 60 };
+static const int avs3_fps_den[9] = {1,   1001,  1,  1,  1001,  1,  
1,  1001,  1 };
+int profile,ratecode;
+const char* p = buf + 4;
+int idx = 7;
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = read_bits(, , 8);
+// level(8) + progressive(1) + field(1) + library(2) + resv(1) + 
width(14) + resv(1) + height(14) + chroma(2) + sampe_precision(3)
+read_bits(, , 47); 
+
+if (profile == 0x22) {
+avctx->pix_fmt = read_bits(, , 3) == 1 ? 
AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV420P10LE;
+} 
+
+// resv(1) + aspect(4)
+read_bits(, , 5);
+
+ratecode = read_bits(, , 4);
+
+// resv(1) + bitrate_low(18) + resv(1) + bitrate_high(12)
+read_bits(, , 32);
+
+avctx->has_b_frames = !read_bits(, , 1);
+
+avctx->framerate.num = avctx->time_base.den = 
avs3_fps_num[ratecode];
+avctx->framerate.den = 

[FFmpeg-devel] [PATCH v1 4/4] lavc, doc: add libuavs3d video decoder wrapper

2020-06-19 Thread hwrenx
From: hwren 

Signed-off-by: hbj 
Signed-off-by: hwren 
---
 Changelog  |   1 +
 configure  |   4 +
 doc/decoders.texi  |  21 
 doc/general.texi   |   8 ++
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libuavs3d.c | 283 +
 7 files changed, 319 insertions(+)
 create mode 100644 libavcodec/libuavs3d.c

diff --git a/Changelog b/Changelog
index a60e7d2..dfd56b3 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - AudioToolbox output device
 - MacCaption demuxer
+- AVS3 video decoder via libuavs3d
 
 
 version 4.3:
diff --git a/configure b/configure
index 7495f35..459f3a6 100755
--- a/configure
+++ b/configure
@@ -274,6 +274,7 @@ External library support:
   --enable-libtls  enable LibreSSL (via libtls), needed for https 
support
if openssl, gnutls or mbedtls is not used [no]
   --enable-libtwolame  enable MP2 encoding via libtwolame [no]
+  --enable-libuavs3d   enable AVS3 decoding via libuavs3d [no]
   --enable-libv4l2 enable libv4l2/v4l-utils [no]
   --enable-libvidstab  enable video stabilization using vid.stab [no]
   --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -1807,6 +1808,7 @@ EXTERNAL_LIBRARY_LIST="
 libtesseract
 libtheora
 libtwolame
+libuavs3d
 libv4l2
 libvorbis
 libvpx
@@ -3242,6 +3244,7 @@ libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
+libuavs3d_decoder_deps="libuavs3d"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
 libvorbis_decoder_deps="libvorbis"
 libvorbis_encoder_deps="libvorbis libvorbisenc"
@@ -6379,6 +6382,7 @@ enabled libtls&& require_pkg_config libtls 
libtls tls.h tls_configur
 enabled libtwolame&& require libtwolame twolame.h twolame_init 
-ltwolame &&
  { check_lib libtwolame twolame.h 
twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
+enabled libuavs3d && require_pkg_config libuavs3d uavs3d "uavs3d > 
1.0.0" uavs3d_decode
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
 enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.3.9" 
libvmaf.h compute_vmaf
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 9005714..f1a0b3c 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -87,6 +87,27 @@ AVS2-P2/IEEE1857.4 video decoder wrapper.
 This decoder allows libavcodec to decode AVS2 streams with davs2 library.
 
 @c man end VIDEO DECODERS
+ 
+@section libuavs3d
+
+AVS3-P2/IEEE1857.10 video decoder.
+
+libuavs3d allows libavcodec to decode AVS3 streams.
+Requires the presence of the libuavs3d headers and library during 
configuration.
+You need to explicitly configure the build with @code{--enable-libuavs3d}.
+
+@subsection Options
+
+The following option is supported by the libuavs3d wrapper.
+
+@table @option
+
+@item frame_threads
+Set amount of frame threads to use during decoding. The default value is 0 
(autodetect).
+
+@end table
+
+@c man end VIDEO DECODERS
 
 @chapter Audio Decoders
 @c man begin AUDIO DECODERS
diff --git a/doc/general.texi b/doc/general.texi
index 9b0ee96..6d673b7 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section uavs3d
+
+FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video 
decoding.
+
+Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for
+installing the library. Then pass @code{--enable-libuavs3d} to configure to
+enable it.
+
 @float NOTE
 libdavs2 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f151277..491485f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
+OBJS-$(CONFIG_LIBUAVS3D_DECODER)  += libuavs3d.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
 OBJS-$(CONFIG_LIBVORBIS_DECODER)  += libvorbisdec.o
 OBJS-$(CONFIG_LIBVORBIS_ENCODER)  += libvorbisenc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 80f128c..3d2d0af 100644
--- 

[FFmpeg-devel] [PATCH v3 2/4] lavc/libxavs2: optimize data access

2019-10-14 Thread hwrenx
From: hwren 

Optimize data access from multiplication to iteration.

Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 45 +
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 0179a1e..b5c07ec 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -132,29 +132,42 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 
 static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame 
*frame, const int shift_in)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-int i_stride = pic->img.i_stride[k];
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-uint16_t *p_plane = (uint16_t *)>img.img_planes[k][j * 
i_stride];
-int i;
-uint8_t *p_buffer = frame->data[k] + frame->linesize[k] * j;
-memset(p_plane, 0, i_stride);
-for (i = 0; i < pic->img.i_width[k]; i++) {
-p_plane[i] = p_buffer[i] << shift_in;
+uint16_t *p_plane;
+uint8_t *p_buffer;
+int wIdx;
+int hIdx;
+int plane;
+
+for (plane = 0; plane < 3; ++plane) {
+p_plane  = (uint16_t *)pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) {
+memset(p_plane, 0, pic->img.i_stride[plane]);
+for (wIdx = 0; wIdx < pic->img.i_width[plane]; ++wIdx) {
+p_plane[wIdx] = p_buffer[wIdx] << shift_in;
 }
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
 
 static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-memcpy( pic->img.img_planes[k] + pic->img.i_stride[k] * j,
-frame->data[k]+frame->linesize[k] * j,
-pic->img.i_width[k] * pic->img.in_sample_size);
+uint8_t *p_plane;
+uint8_t *p_buffer;
+int hIdx;
+int plane;
+int stride;
+
+for (plane = 0; plane < 3; ++plane) {
+p_plane  = pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
+stride = pic->img.i_width[plane] * pic->img.in_sample_size;
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) {
+memcpy(p_plane, p_buffer, stride);
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 3/4] lavc/libxavs2: optimize using of spaces and indents

2019-10-14 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 51 +++
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index b5c07ec..8077607 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -26,15 +26,16 @@
 #include "mpeg12.h"
 #include "libavutil/avstring.h"
 
-#define xavs2_opt_set2(name, format, ...) do{ \
-char opt_str[16] = {0}; \
-int err; \
-av_strlcatf(opt_str, sizeof(opt_str), format, __VA_ARGS__); \
-err = cae->api->opt_set2(cae->param, name, opt_str); \
-if (err < 0) {\
-av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s\n", name, 
opt_str);\
-}\
-} while(0);
+#define xavs2_opt_set2(name, format, ...)  
 \
+do {   
 \
+char opt_str[16] = {0};
 \
+int  err;  
 \
+av_strlcatf(opt_str, sizeof(opt_str), format, __VA_ARGS__);
 \
+err = cae->api->opt_set2(cae->param, name, opt_str);   
 \
+if (err < 0) { 
 \
+av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s\n", name, 
opt_str); \
+}  
 \
+} while (0);
 
 typedef struct XAVS2EContext {
 AVClass *class;
@@ -59,12 +60,12 @@ typedef struct XAVS2EContext {
 
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
-XAVS2EContext *cae= avctx->priv_data;
+XAVS2EContext *cae = avctx->priv_data;
 int bit_depth, code;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
 
-/* get API handler */
+// get API handler
 cae->api = xavs2_api_get(bit_depth);
 if (!cae->api) {
 av_log(avctx, AV_LOG_ERROR, "api get failed\n");
@@ -83,17 +84,15 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("BitDepth",  "%d", bit_depth);
 xavs2_opt_set2("Log",   "%d", cae->log_level);
 xavs2_opt_set2("Preset","%d", cae->preset_level);
+xavs2_opt_set2("OpenGOP",   "%d", !(avctx->flags & 
AV_CODEC_FLAG_CLOSED_GOP));
 
 xavs2_opt_set2("IntraPeriodMax","%d", avctx->gop_size);
 xavs2_opt_set2("IntraPeriodMin","%d", avctx->gop_size);
-
 xavs2_opt_set2("ThreadFrames",  "%d", avctx->thread_count);
 xavs2_opt_set2("ThreadRows","%d", cae->lcu_row_threads);
 
-xavs2_opt_set2("OpenGOP",  "%d", !(avctx->flags & 
AV_CODEC_FLAG_CLOSED_GOP));
-
 if (cae->xavs2_opts) {
-AVDictionary *dict= NULL;
+AVDictionary *dict = NULL;
 AVDictionaryEntry *en = NULL;
 
 if (!av_dict_parse_string(, cae->xavs2_opts, "=", ":", 0)) {
@@ -104,7 +103,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 }
 }
 
-/* Rate control */
+// Rate control
 if (avctx->bit_rate > 0) {
 xavs2_opt_set2("RateControl",   "%d", 1);
 xavs2_opt_set2("TargetBitRate", "%"PRId64"", avctx->bit_rate);
@@ -115,15 +114,14 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-
 ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
 
-xavs2_opt_set2("FrameRate",   "%d", code);
+xavs2_opt_set2("FrameRate", "%d", code);
 
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-av_log(avctx,AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
+av_log(avctx, AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
 return AVERROR(EINVAL);
 }
 
@@ -179,10 +177,10 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 xavs2_picture_t pic;
 int ret;
 
-/* create the XAVS2 video encoder */
-/* read frame data and send to the XAVS2 video encoder */
+// create the XAVS2 video encoder
+// read frame data and send to the XAVS2 video encoder
 if (cae->api->encoder_get_buffer(cae->encoder, ) < 0) {
-av_log(avctx,AV_LOG_ERROR, "failed to get frame buffer\n");
+av_log(avctx, AV_LOG_ERROR, "failed to get frame buffer\n");
 return AVERROR_EXTERNAL;
 }
 if (frame) {
@@ -216,14 +214,12 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 av_log(avctx, AV_LOG_ERROR, "encode failed\n");
 return AVERROR_EXTERNAL;
 }
-
 } else {
 cae->api->encoder_encode(cae->encoder, NULL, >packet);
 }
 
-if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)){
-
-if (av_new_packet(pkt, cae->packet.len) < 0){
+if ((cae->packet.len) && (cae->packet.state != 

[FFmpeg-devel] [PATCH v3 1/4] lavc/libxavs2: fix parameter setting result determination

2019-10-14 Thread hwrenx
From: hwren 

Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index d5c4557..0179a1e 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -31,7 +31,7 @@
 int err; \
 av_strlcatf(opt_str, sizeof(opt_str), format, __VA_ARGS__); \
 err = cae->api->opt_set2(cae->param, name, opt_str); \
-if (err) {\
+if (err < 0) {\
 av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s\n", name, 
opt_str);\
 }\
 } while(0);
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 4/4] lavc/libxavs2: replace 'FrameRate' with 'fps'

2019-10-14 Thread hwrenx
From: hwren 

Remove deprecated parameter FrameRate (frame rate code) and use fps (frame 
rate) instead.
Avoid encoder warnings.

Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 8077607..382f745 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -61,7 +61,8 @@ typedef struct XAVS2EContext {
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
 XAVS2EContext *cae = avctx->priv_data;
-int bit_depth, code;
+int bit_depth;
+float framerate;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
 
@@ -78,6 +79,10 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 }
 
+if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
+framerate = (float)avctx->framerate.num / (float)avctx->framerate.den;
+}
+
 xavs2_opt_set2("Width", "%d", avctx->width);
 xavs2_opt_set2("Height","%d", avctx->height);
 xavs2_opt_set2("BFrames",   "%d", avctx->max_b_frames);
@@ -85,6 +90,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("Log",   "%d", cae->log_level);
 xavs2_opt_set2("Preset","%d", cae->preset_level);
 xavs2_opt_set2("OpenGOP",   "%d", !(avctx->flags & 
AV_CODEC_FLAG_CLOSED_GOP));
+xavs2_opt_set2("fps",   "%.3f", framerate);
 
 xavs2_opt_set2("IntraPeriodMax","%d", avctx->gop_size);
 xavs2_opt_set2("IntraPeriodMin","%d", avctx->gop_size);
@@ -114,10 +120,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
-
-xavs2_opt_set2("FrameRate", "%d", code);
-
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 3/3] lavc/libdavs2.c: reduce memcpy

2019-07-22 Thread hwrenx
Can effectivly improved decoding speed when memcpy becomes a limitation
for proccessing high resolution source.
Tested under i7-8700k with `ffmpeg -i 7680x4320.avs2 -vsync 0 -f null -`
got performance 23fps => 42fps

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 52 ---
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 6d66209..32c07fe 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -73,13 +73,22 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
+static void davs2_frame_unref(void *opaque, uint8_t *data) {
+DAVS2Context*cad = (DAVS2Context *)opaque;
+davs2_picture_t  pic;
+
+pic.magic = (davs2_picture_t *)data;
+
+if (cad->decoder) {
+davs2_decoder_frame_unref(cad->decoder, );
+}
+}
+
 static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int 
*got_frame,
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
-int bytes_per_sample = pic->bytes_per_sample;
-int plane = 0;
-int line  = 0;
+int plane;
 
 if (!headerset) {
 *got_frame = 0;
@@ -117,29 +126,28 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 return AVERROR_EXTERNAL;
 }
 
-for (plane = 0; plane < 3; ++plane) {
-int size_line = pic->widths[plane] * bytes_per_sample;
-frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
-
-if (!frame->buf[plane]){
-av_log(avctx, AV_LOG_ERROR, "Decoder error: allocation failure, 
can't dump frames.\n");
-return AVERROR(ENOMEM);
-}
-
-frame->data[plane] = frame->buf[plane]->data;
-frame->linesize[plane] = size_line;
-
-for (line = 0; line < pic->lines[plane]; ++line)
-memcpy(frame->data[plane] + line * size_line,
-   pic->planes[plane] + line * pic->strides[plane],
-   pic->widths[plane] * bytes_per_sample);
-}
-
 frame->width = cad->headerset.width;
 frame->height= cad->headerset.height;
 frame->pts   = cad->out_frame.pts;
 frame->format= avctx->pix_fmt;
 
+/* handle the actual picture in magic */
+frame->buf[0]= av_buffer_create((uint8_t *)pic->magic,
+sizeof(davs2_picture_t *),
+davs2_frame_unref,
+(void *)cad,
+AV_BUFFER_FLAG_READONLY);
+if (!frame->buf[0]) {
+av_log(avctx, AV_LOG_ERROR,
+"Decoder error: allocation failure, can't dump frames.\n");
+return AVERROR(ENOMEM);
+}
+
+for (plane = 0; plane < 3; ++plane) {
+frame->linesize[plane] = pic->strides[plane];
+frame->data[plane] = pic->planes[plane];
+}
+
 *got_frame = 1;
 return 0;
 }
@@ -171,7 +179,6 @@ static int send_delayed_frame(AVCodecContext *avctx, 
AVFrame *frame, int *got_fr
 }
 if (ret == DAVS2_GOT_FRAME) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 return ret;
 }
@@ -220,7 +227,6 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 
 if (ret != DAVS2_DEFAULT) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 
 return ret == 0 ? buf_size : ret;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 1/3] lavc/avs2_parser.c: fix missing start code

2019-07-22 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/avs2_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b342..dc2fa16 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -23,8 +23,10 @@
 
 #define SLICE_MAX_START_CODE0x01af
 
+#define ISSQH(x)  ((x) == 0xB0 )
+#define ISEND(x)  ((x) == 0xB1 )
 #define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 0/3] optimize frame dumping and fix missing start codes

2019-07-22 Thread hwrenx
Version 5:
1. Using ifs for log level instead of expressions.


Version 4:
1. Change info level setting.
2. Remove `Decoder not found` condition.


The previous version 2 patches were deprecated for using
pointer to itself can be unsafe when release frames.

This patch set is mainly about avoiding using memcpy when fetching
frame data, and fixed missing start codes which may cause error
packetization sometime. Default info level of libdavs2 was changed
because we found debug info is useless in most of the time.
hwrenx (3):
  lavc/avs2_parser.c: fix missing start code
  lavc/libdavs2.c: fix decoder info level setting
  lavc/libdavs2.c: reduce memcpy

 libavcodec/avs2_parser.c |  4 ++-
 libavcodec/libdavs2.c| 69 +++-
 2 files changed, 48 insertions(+), 25 deletions(-)

The performance comparison is like following:

[Platform]
  Intel® Core™ i7-8700k CPU @ 3.70GHz × 6 / 16GiB
[Command]
  ffmpeg -i test.avs2 -vsync 0 -f null -
[Stream]
  7680x4320 yuv420p Random Access
[Original version]
  frame= 2669 fps= 23 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.465x
[Optimized version]
  frame= 2669 fps= 42 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.836x

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 2/3] lavc/libdavs2.c: fix decoder info level setting

2019-07-22 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..6d66209 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -37,14 +37,29 @@ typedef struct DAVS2Context {
 
 }DAVS2Context;
 
+static int davs2_log_get_level(int log_level)
+{
+if (log_level <= AV_LOG_ERROR)
+return DAVS2_LOG_ERROR;
+
+if (log_level <= AV_LOG_WARNING)
+return DAVS2_LOG_WARNING;
+
+if (log_level <= AV_LOG_INFO)
+return DAVS2_LOG_INFO;
+
+return DAVS2_LOG_DEBUG;
+}
+
 static av_cold int davs2_init(AVCodecContext *avctx)
 {
 DAVS2Context *cad = avctx->priv_data;
 int cpu_flags = av_get_cpu_flags();
+int log_level = av_log_get_level();
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
-cad->param.info_level   = 0;
+cad->param.info_level   = davs2_log_get_level(log_level);
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
 cad->decoder= davs2_decoder_open(>param);
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 3/3] lavc/libdavs2.c: reduce memcpy

2019-07-21 Thread hwrenx
Can effectivly improved decoding speed when memcpy becomes a limitation
for proccessing high resolution source.
Tested under i7-8700k with `ffmpeg -i 7680x4320.avs2 -vsync 0 -f null -`
got performance 23fps => 42fps

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 52 ---
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 79b3e4f..ca5b307 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -65,13 +65,22 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
+static void davs2_frame_unref(void *opaque, uint8_t *data) {
+DAVS2Context*cad = (DAVS2Context *)opaque;
+davs2_picture_t  pic;
+
+pic.magic = (davs2_picture_t *)data;
+
+if (cad->decoder) {
+davs2_decoder_frame_unref(cad->decoder, );
+}
+}
+
 static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int 
*got_frame,
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
-int bytes_per_sample = pic->bytes_per_sample;
-int plane = 0;
-int line  = 0;
+int plane;
 
 if (!headerset) {
 *got_frame = 0;
@@ -109,29 +118,28 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 return AVERROR_EXTERNAL;
 }
 
-for (plane = 0; plane < 3; ++plane) {
-int size_line = pic->widths[plane] * bytes_per_sample;
-frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
-
-if (!frame->buf[plane]){
-av_log(avctx, AV_LOG_ERROR, "Decoder error: allocation failure, 
can't dump frames.\n");
-return AVERROR(ENOMEM);
-}
-
-frame->data[plane] = frame->buf[plane]->data;
-frame->linesize[plane] = size_line;
-
-for (line = 0; line < pic->lines[plane]; ++line)
-memcpy(frame->data[plane] + line * size_line,
-   pic->planes[plane] + line * pic->strides[plane],
-   pic->widths[plane] * bytes_per_sample);
-}
-
 frame->width = cad->headerset.width;
 frame->height= cad->headerset.height;
 frame->pts   = cad->out_frame.pts;
 frame->format= avctx->pix_fmt;
 
+/* handle the actual picture in magic */
+frame->buf[0]= av_buffer_create((uint8_t *)pic->magic,
+sizeof(davs2_picture_t *),
+davs2_frame_unref,
+(void *)cad,
+AV_BUFFER_FLAG_READONLY);
+if (!frame->buf[0]) {
+av_log(avctx, AV_LOG_ERROR,
+"Decoder error: allocation failure, can't dump frames.\n");
+return AVERROR(ENOMEM);
+}
+
+for (plane = 0; plane < 3; ++plane) {
+frame->linesize[plane] = pic->strides[plane];
+frame->data[plane] = pic->planes[plane];
+}
+
 *got_frame = 1;
 return 0;
 }
@@ -163,7 +171,6 @@ static int send_delayed_frame(AVCodecContext *avctx, 
AVFrame *frame, int *got_fr
 }
 if (ret == DAVS2_GOT_FRAME) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 return ret;
 }
@@ -212,7 +219,6 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 
 if (ret != DAVS2_DEFAULT) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 
 return ret == 0 ? buf_size : ret;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 0/3] optimize frame dumping and fix missing start codes

2019-07-21 Thread hwrenx
Version 4:
1. Change info level setting.
2. Remove `Decoder not found` condition.


The previous version 2 patches were deprecated for using
pointer to itself can be unsafe when release frames.

This patch set is mainly about avoiding using memcpy when fetching
frame data, and fixed missing start codes which may cause error
packetization sometime. Default info level of libdavs2 was changed
because we found debug info is useless in most of the time.

hwrenx (3):
  lavc/avs2_parser.c: fix missing start code
  lavc/libdavs2.c: fix decoder info level setting
  lavc/libdavs2.c: reduce memcpy

 libavcodec/avs2_parser.c |  4 +++-
 libavcodec/libdavs2.c| 61 +---
 2 files changed, 40 insertions(+), 25 deletions(-)

The performance comparison is like following:

[Platform]
  Intel® Core™ i7-8700k CPU @ 3.70GHz × 6 / 16GiB
[Command]
  ffmpeg -i test.avs2 -vsync 0 -f null -
[Stream]
  7680x4320 yuv420p Random Access
[Original version]
  frame= 2669 fps= 23 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.465x
[Optimized version]
  frame= 2669 fps= 42 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.836x

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 2/3] lavc/libdavs2.c: fix decoder info level setting

2019-07-21 Thread hwrenx
Mapping log level from av_log_level to davs3_log_level_e:

[AV_LOG_QUIET, AV_LOG_ERROR]   => DAVS2_LOG_ERROR
[AV_LOG_WARNING]   => DAVS2_LOG_WARNING
[AV_LOG_INFO]  => DAVS2_LOG_INFO
[AV_LOG_VERBOSE, AV_LOG_TRACE] => DAVS2_LOG_DEBUG

in values:

[-8, 16] => 3
[17, 24] => 2
[25, 32] => 1
[33, 56] => 0

After clip into [AV_LOG_FATAL + 1, AV_LOG_VERBOSE]([9, 40]), davs2 log
level can be expressed as (4-(((av_log_level)-1)>>3)).

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..79b3e4f 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -25,6 +25,9 @@
 #include "avcodec.h"
 #include "davs2.h"
 
+/* map log_level from 16/24/32/40 to 3/2/1/0 */
+#define DAVS2_GET_LEVEL(x) (4-(((x)-1)>>3))
+
 typedef struct DAVS2Context {
 void *decoder;
 
@@ -41,10 +44,14 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 {
 DAVS2Context *cad = avctx->priv_data;
 int cpu_flags = av_get_cpu_flags();
+int log_level = av_log_get_level();
+
+/* fix for davs2 level range */
+log_level = av_clip(log_level, AV_LOG_FATAL + 1, AV_LOG_VERBOSE);
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
-cad->param.info_level   = 0;
+cad->param.info_level   = DAVS2_GET_LEVEL(log_level);
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
 cad->decoder= davs2_decoder_open(>param);
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 1/3] lavc/avs2_parser.c: fix missing start code

2019-07-21 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/avs2_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b342..dc2fa16 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -23,8 +23,10 @@
 
 #define SLICE_MAX_START_CODE0x01af
 
+#define ISSQH(x)  ((x) == 0xB0 )
+#define ISEND(x)  ((x) == 0xB1 )
 #define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 3/3] lavc/libdavs2.c: use decoder data directly instead of memcpy

2019-07-12 Thread hwrenx
Can effectivly improved decoding speed when memcpy becomes a limitation
for proccessing high resolution source.
Tested under i7-8700k with `ffmpeg -i 7680x4320.avs2 -vsync 0 -f null -`
got performance 23fps => 42fps

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 54 +--
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 1b274a3..af0778f 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -60,13 +60,24 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
+static void davs2_frame_unref(void *opaque, uint8_t *data) {
+DAVS2Context*cad = (DAVS2Context *)opaque;
+davs2_picture_t  pic;
+
+pic.magic = (davs2_picture_t *)data;
+
+if (cad->decoder) {
+davs2_decoder_frame_unref(cad->decoder, );
+} else {
+av_log(NULL, AV_LOG_WARNING, "Decoder not found, frame unreference 
failed.\n");
+}
+}
+
 static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int 
*got_frame,
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
-int bytes_per_sample = pic->bytes_per_sample;
-int plane = 0;
-int line  = 0;
+int plane;
 
 if (!headerset) {
 *got_frame = 0;
@@ -104,29 +115,28 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 return AVERROR_EXTERNAL;
 }
 
-for (plane = 0; plane < 3; ++plane) {
-int size_line = pic->widths[plane] * bytes_per_sample;
-frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
-
-if (!frame->buf[plane]){
-av_log(avctx, AV_LOG_ERROR, "Decoder error: allocation failure, 
can't dump frames.\n");
-return AVERROR(ENOMEM);
-}
-
-frame->data[plane] = frame->buf[plane]->data;
-frame->linesize[plane] = size_line;
-
-for (line = 0; line < pic->lines[plane]; ++line)
-memcpy(frame->data[plane] + line * size_line,
-   pic->planes[plane] + line * pic->strides[plane],
-   pic->widths[plane] * bytes_per_sample);
-}
-
 frame->width = cad->headerset.width;
 frame->height= cad->headerset.height;
 frame->pts   = cad->out_frame.pts;
 frame->format= avctx->pix_fmt;
 
+/* handle the actual picture in magic */
+frame->buf[0]= av_buffer_create((uint8_t *)pic->magic,
+sizeof(davs2_picture_t *),
+davs2_frame_unref,
+(void *)cad,
+AV_BUFFER_FLAG_READONLY);
+if (!frame->buf[0]) {
+av_log(avctx, AV_LOG_ERROR,
+"Decoder error: allocation failure, can't dump frames.\n");
+return AVERROR(ENOMEM);
+}
+
+for (plane = 0; plane < 3; ++plane) {
+frame->linesize[plane] = pic->strides[plane];
+frame->data[plane] = pic->planes[plane];
+}
+
 *got_frame = 1;
 return 0;
 }
@@ -158,7 +168,6 @@ static int send_delayed_frame(AVCodecContext *avctx, 
AVFrame *frame, int *got_fr
 }
 if (ret == DAVS2_GOT_FRAME) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 return ret;
 }
@@ -207,7 +216,6 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 
 if (ret != DAVS2_DEFAULT) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 
 return ret == 0 ? buf_size : ret;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 1/3] lavc/avs2_parser.c: fix for missing start code

2019-07-12 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/avs2_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b342..dc2fa16 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -23,8 +23,10 @@
 
 #define SLICE_MAX_START_CODE0x01af
 
+#define ISSQH(x)  ((x) == 0xB0 )
+#define ISEND(x)  ((x) == 0xB1 )
 #define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 2/3] lavc/libdavs2.c: change decoder info level

2019-07-12 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..1b274a3 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -44,7 +44,9 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
-cad->param.info_level   = 0;
+cad->param.info_level   = av_log_get_level() > AV_LOG_INFO
+ ? DAVS2_LOG_DEBUG
+ : DAVS2_LOG_WARNING;
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
 cad->decoder= davs2_decoder_open(>param);
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 0/3] optimize frame dumping and fix missing start codes

2019-07-12 Thread hwrenx
The previous version 2 patches were deprecated for using
pointer to itself can be unsafe when release frames.

This patch set is mainly about avoiding using memcpy when fetching
frame data, and fixed missing start codes which may cause error
packetization sometime. Default info level of libdavs2 was changed
because we found debug info is useless in most of the time.

hwrenx (3):
  lavc/avs2_parser.c: fix for missing start code
  lavc/libdavs2.c: change decoder info level
  lavc/libdavs2.c: use decoder data directly instead of memcpy

 libavcodec/avs2_parser.c |  4 +++-
 libavcodec/libdavs2.c| 58 
 2 files changed, 37 insertions(+), 25 deletions(-)

The performance comparison is like following:

[Platform]
  Intel® Core™ i7-8700k CPU @ 3.70GHz × 6 / 16GiB
[Command]
  ffmpeg -i test.avs2 -vsync 0 -f null -
[Stream]
  7680x4320 yuv420p Random Access
[Original version]
  frame= 2669 fps= 23 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.465x
[Optimized version]
  frame= 2669 fps= 42 q=-0.0 Lsize=N/A time=00:00:53.44 bitrate=N/A speed=0.836x


-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 3/3] lavc/libdavs2.c: use decoder data directly instead of memcpy

2019-07-12 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 55 ++-
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index df538af..f88dfa0 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -58,13 +58,25 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
+static void davs2_frame_unref(void *opaque, uint8_t *data) {
+DAVS2Context*cad = (DAVS2Context *)opaque;
+davs2_picture_t *pic = (davs2_picture_t *)data;
+
+/* set release pointer to itself */
+pic->magic = pic;
+
+if (cad->decoder) {
+davs2_decoder_frame_unref(cad->decoder, pic);
+} else {
+av_log(NULL, AV_LOG_WARNING, "Decoder not found, frame unreference 
failed.\n");
+}
+}
+
 static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int 
*got_frame,
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
-int bytes_per_sample = pic->bytes_per_sample;
-int plane = 0;
-int line  = 0;
+int plane;
 
 if (!headerset) {
 *got_frame = 0;
@@ -102,29 +114,28 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 return AVERROR_EXTERNAL;
 }
 
-for (plane = 0; plane < 3; ++plane) {
-int size_line = pic->widths[plane] * bytes_per_sample;
-frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
-
-if (!frame->buf[plane]){
-av_log(avctx, AV_LOG_ERROR, "Decoder error: allocation failure, 
can't dump frames.\n");
-return AVERROR(ENOMEM);
-}
-
-frame->data[plane] = frame->buf[plane]->data;
-frame->linesize[plane] = size_line;
-
-for (line = 0; line < pic->lines[plane]; ++line)
-memcpy(frame->data[plane] + line * size_line,
-   pic->planes[plane] + line * pic->strides[plane],
-   pic->widths[plane] * bytes_per_sample);
-}
-
 frame->width = cad->headerset.width;
 frame->height= cad->headerset.height;
 frame->pts   = cad->out_frame.pts;
 frame->format= avctx->pix_fmt;
 
+/* handle the actual picture in magic */
+frame->buf[0]= av_buffer_create((uint8_t *)pic->magic,
+sizeof(davs2_picture_t *),
+davs2_frame_unref,
+(void *)cad,
+AV_BUFFER_FLAG_READONLY);
+if (!frame->buf[0]) {
+av_log(avctx, AV_LOG_ERROR,
+"Decoder error: allocation failure, can't dump frames.\n");
+return AVERROR(ENOMEM);
+}
+
+for (plane = 0; plane < 3; ++plane) {
+frame->linesize[plane] = pic->strides[plane];
+frame->data[plane] = pic->planes[plane];
+}
+
 *got_frame = 1;
 return 0;
 }
@@ -156,7 +167,6 @@ static int send_delayed_frame(AVCodecContext *avctx, 
AVFrame *frame, int *got_fr
 }
 if (ret == DAVS2_GOT_FRAME) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 return ret;
 }
@@ -205,7 +215,6 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 
 if (ret != DAVS2_DEFAULT) {
 ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
-davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 
 return ret == 0 ? buf_size : ret;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/3] lavc/libdavs2.c: change info level, only print errors

2019-07-12 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..df538af 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -44,7 +44,7 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
-cad->param.info_level   = 0;
+cad->param.info_level   = DAVS2_LOG_ERROR;
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
 cad->decoder= davs2_decoder_open(>param);
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 1/3] lavc/avs2_parser.c: fix for missing start code

2019-07-12 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/avs2_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 1c9b342..dc2fa16 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -23,8 +23,10 @@
 
 #define SLICE_MAX_START_CODE0x01af
 
+#define ISSQH(x)  ((x) == 0xB0 )
+#define ISEND(x)  ((x) == 0xB1 )
 #define ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || ISPIC(x))
+#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 
0xB5 || (x) == 0xB7 )
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1] lavc/libdavs2.c: optimize frame copy

2019-07-02 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..15ed3a1 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -62,7 +62,7 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
-int bytes_per_sample = pic->bytes_per_sample;
+int bytes_per_sample = pic->bytes_per_sample == 8 ? 1 : 2;
 int plane = 0;
 int line  = 0;
 
@@ -104,6 +104,7 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 
 for (plane = 0; plane < 3; ++plane) {
 int size_line = pic->widths[plane] * bytes_per_sample;
+void *dst, *src;
 frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
 
 if (!frame->buf[plane]){
@@ -114,10 +115,14 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 frame->data[plane] = frame->buf[plane]->data;
 frame->linesize[plane] = size_line;
 
-for (line = 0; line < pic->lines[plane]; ++line)
-memcpy(frame->data[plane] + line * size_line,
-   pic->planes[plane] + line * pic->strides[plane],
-   pic->widths[plane] * bytes_per_sample);
+dst = frame->data[plane];
+src = pic->planes[plane];
+
+for (line = 0; line < pic->lines[plane]; ++line) {
+memcpy(dst, src, size_line);
+dst += size_line;
+src += pic->strides[plane];
+}
 }
 
 frame->width = cad->headerset.width;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1 2/2] lavc/libdavs2: fix frame dumping error description

2019-03-20 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index b0eb4fd..218f3ec 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -107,7 +107,7 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 frame->buf[plane]  = av_buffer_alloc(size_line * pic->lines[plane]);
 
 if (!frame->buf[plane]){
-av_log(avctx, AV_LOG_ERROR, "dump error: alloc failed.\n");
+av_log(avctx, AV_LOG_ERROR, "Decoder error: allocation failure, 
can't dump frames.\n");
 return AVERROR(ENOMEM);
 }
 
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v1 1/2] lavc/libdavs2: add davs2_flush

2019-03-20 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 0808721..b0eb4fd 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -129,6 +129,21 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic, int *g
 return 0;
 }
 
+static void davs2_flush(AVCodecContext *avctx)
+{
+DAVS2Context *cad  = avctx->priv_data;
+int   ret  = DAVS2_GOT_FRAME;
+
+while (ret == DAVS2_GOT_FRAME) {
+ret = davs2_decoder_flush(cad->decoder, >headerset, 
>out_frame);
+davs2_decoder_frame_unref(cad->decoder, >out_frame);
+}
+
+if (ret == DAVS2_ERROR) {
+av_log(avctx, AV_LOG_WARNING, "Decoder flushing failed.\n");
+}
+}
+
 static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int 
*got_frame)
 {
 DAVS2Context *cad  = avctx->priv_data;
@@ -205,6 +220,7 @@ AVCodec ff_libdavs2_decoder = {
 .init   = davs2_init,
 .close  = davs2_end,
 .decode = davs2_decode_frame,
+.flush  = davs2_flush,
 .capabilities   =  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE },
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 3/3] lavc/libdavs2: fix parameter setting error

2019-01-24 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index cf75656..0808721 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -45,9 +45,9 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
 cad->param.info_level   = 0;
-cad->decoder= davs2_decoder_open(>param);
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
+cad->decoder= davs2_decoder_open(>param);
 
 if (!cad->decoder) {
 av_log(avctx, AV_LOG_ERROR, "decoder created error.");
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/3] lavc/libxavs2: use upper layer qp parameters first

2019-01-24 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 2d29427..d5c4557 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -109,8 +109,8 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("RateControl",   "%d", 1);
 xavs2_opt_set2("TargetBitRate", "%"PRId64"", avctx->bit_rate);
 xavs2_opt_set2("InitialQP", "%d", cae->initial_qp);
-xavs2_opt_set2("MaxQP", "%d", cae->max_qp);
-xavs2_opt_set2("MinQP", "%d", cae->min_qp);
+xavs2_opt_set2("MaxQP", "%d", avctx->qmax >= 0 ? avctx->qmax : 
cae->max_qp);
+xavs2_opt_set2("MinQP", "%d", avctx->qmin >= 0 ? avctx->qmin : 
cae->min_qp);
 } else {
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/3] lavc/libxavs2: remove unused context parameter

2019-01-24 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 52c50a1..2d29427 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -46,7 +46,6 @@ typedef struct XAVS2EContext {
 int min_qp;
 int preset_level;
 int log_level;
-int hierarchical_reference;
 
 void *encoder;
 char *xavs2_opts;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/3] lavc/libxavs2: use upper layer qp parameters first

2019-01-21 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 2d29427..0ad9ca9 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -109,8 +109,9 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("RateControl",   "%d", 1);
 xavs2_opt_set2("TargetBitRate", "%"PRId64"", avctx->bit_rate);
 xavs2_opt_set2("InitialQP", "%d", cae->initial_qp);
-xavs2_opt_set2("MaxQP", "%d", cae->max_qp);
-xavs2_opt_set2("MinQP", "%d", cae->min_qp);
+xavs2_opt_set2("MaxQP", "%d", avctx->qmax >= 0 ? avctx->qmax : 
cae->max_qp);
+xavs2_opt_set2("MinQP", "%d", avctx->qmin >= 0 ? avctx->qmin : 
cae->min_qp);
+
 } else {
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/3] lavc/libxavs2: remove unused context parameter

2019-01-21 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 52c50a1..2d29427 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -46,7 +46,6 @@ typedef struct XAVS2EContext {
 int min_qp;
 int preset_level;
 int log_level;
-int hierarchical_reference;
 
 void *encoder;
 char *xavs2_opts;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] lavc/libdavs2: fix parameter setting error

2019-01-21 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index cf75656..f8f1b05 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -45,10 +45,11 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
 cad->param.info_level   = 0;
-cad->decoder= davs2_decoder_open(>param);
 cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
 cpu_flags & AV_CPU_FLAG_AVX2);
 
+cad->decoder= davs2_decoder_open(>param);
+
 if (!cad->decoder) {
 av_log(avctx, AV_LOG_ERROR, "decoder created error.");
 return AVERROR_EXTERNAL;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v1 2/2] lavc/libxavs2: use upper layer qp parameters first

2019-01-11 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 2d29427..0ad9ca9 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -109,8 +109,9 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("RateControl",   "%d", 1);
 xavs2_opt_set2("TargetBitRate", "%"PRId64"", avctx->bit_rate);
 xavs2_opt_set2("InitialQP", "%d", cae->initial_qp);
-xavs2_opt_set2("MaxQP", "%d", cae->max_qp);
-xavs2_opt_set2("MinQP", "%d", cae->min_qp);
+xavs2_opt_set2("MaxQP", "%d", avctx->qmax >= 0 ? avctx->qmax : 
cae->max_qp);
+xavs2_opt_set2("MinQP", "%d", avctx->qmin >= 0 ? avctx->qmin : 
cae->min_qp);
+
 } else {
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v1 1/2] lavc/libxavs2: remove unused context parameter

2019-01-11 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libxavs2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 52c50a1..2d29427 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -46,7 +46,6 @@ typedef struct XAVS2EContext {
 int min_qp;
 int preset_level;
 int log_level;
-int hierarchical_reference;
 
 void *encoder;
 char *xavs2_opts;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] lavc/libdavs2: enable multithread

2018-12-14 Thread hwrenx
From: hwrenx 

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 37635bb..2846ecf 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -205,7 +205,7 @@ AVCodec ff_libdavs2_decoder = {
 .init   = davs2_init,
 .close  = davs2_end,
 .decode = davs2_decode_frame,
-.capabilities   =  AV_CODEC_CAP_DELAY,//AV_CODEC_CAP_DR1 |
+.capabilities   =  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE },
 .wrapper_name   = "libdavs2",
-- 
2.7.4



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/libdavs2: enable multithread

2018-12-13 Thread hwrenx
From: hwrenx 

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 37635bb..a714213 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -205,7 +205,7 @@ AVCodec ff_libdavs2_decoder = {
 .init   = davs2_init,
 .close  = davs2_end,
 .decode = davs2_decode_frame,
-.capabilities   =  AV_CODEC_CAP_DELAY,//AV_CODEC_CAP_DR1 |
+.capabilities   =  AV_CODEC_CAP_DELAY | 
AV_CODEC_CAP_AUTO_THREADS,//AV_CODEC_CAP_DR1 |
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE },
 .wrapper_name   = "libdavs2",
-- 
2.7.4



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] lavc/libdavs2: fix function return value error

2018-11-19 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 3b8666f..b7f7d65 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -58,7 +58,7 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 return 0;
 }
 
-static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic,
+static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic, int 
*got_frame,
  davs2_seq_info_t *headerset, int ret_type, 
AVFrame *frame)
 {
 DAVS2Context *cad= avctx->priv_data;
@@ -66,8 +66,10 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic,
 int plane = 0;
 int line  = 0;
 
-if (!headerset)
+if (!headerset) {
+*got_frame = 0;
 return 0;
+}
 
 if (!pic || ret_type == DAVS2_GOT_HEADER) {
 avctx->width = headerset->width;
@@ -76,6 +78,7 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic,
AV_PIX_FMT_YUV420P10 : AV_PIX_FMT_YUV420P;
 
 avctx->framerate = av_d2q(headerset->frame_rate,4096);
+*got_frame = 0;
 return 0;
 }
 
@@ -122,7 +125,8 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic,
 frame->pts   = cad->out_frame.pts;
 frame->format= avctx->pix_fmt;
 
-return 1;
+*got_frame = 1;
+return 0;
 }
 
 static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int 
*got_frame)
@@ -136,7 +140,7 @@ static int send_delayed_frame(AVCodecContext *avctx, 
AVFrame *frame, int *got_fr
 return AVERROR_EXTERNAL;
 }
 if (ret == DAVS2_GOT_FRAME) {
-*got_frame = davs2_dump_frames(avctx, >out_frame, 
>headerset, ret, frame);
+ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
 davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 return ret;
@@ -185,11 +189,11 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 ret = davs2_decoder_recv_frame(cad->decoder, >headerset, 
>out_frame);
 
 if (ret != DAVS2_DEFAULT) {
-*got_frame = davs2_dump_frames(avctx, >out_frame, 
>headerset, ret, frame);
+ret = davs2_dump_frames(avctx, >out_frame, got_frame, 
>headerset, ret, frame);
 davs2_decoder_frame_unref(cad->decoder, >out_frame);
 }
 
-return buf_size;
+return ret == 0 ? buf_size : ret;
 }
 
 AVCodec ff_libdavs2_decoder = {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/3] libdavs2: update api version and enable avx option

2018-11-19 Thread hwrenx
Signed-off-by: hwrenx 
---
 configure | 2 +-
 libavcodec/libdavs2.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index b4f944c..1a9f874 100755
--- a/configure
+++ b/configure
@@ -6076,7 +6076,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
 enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.0.1" 
"dav1d/dav1d.h" dav1d_version
-enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.5.115" 
davs2.h davs2_decoder_open
+enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 874f2f0..9a905b8 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -40,11 +40,14 @@ typedef struct DAVS2Context {
 static av_cold int davs2_init(AVCodecContext *avctx)
 {
 DAVS2Context *cad = avctx->priv_data;
+int cpu_flags = av_get_cpu_flags();
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
 cad->param.info_level   = 0;
 cad->decoder= davs2_decoder_open(>param);
+cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
+cpu_flags & AV_CPU_FLAG_AVX2);
 
 if (!cad->decoder) {
 av_log(avctx, AV_LOG_ERROR, "decoder created error.");
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/3] lavc/libdavs2: output delayed frames

2018-11-19 Thread hwrenx
Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 9a905b8..3b8666f 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -125,6 +125,23 @@ static int davs2_dump_frames(AVCodecContext *avctx, 
davs2_picture_t *pic,
 return 1;
 }
 
+static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int 
*got_frame)
+{
+DAVS2Context *cad  = avctx->priv_data;
+int   ret  = DAVS2_DEFAULT;
+
+ret = davs2_decoder_flush(cad->decoder, >headerset, >out_frame);
+if (ret == DAVS2_ERROR) {
+av_log(avctx, AV_LOG_ERROR, "Decoder error: can't flush delayed 
frame\n");
+return AVERROR_EXTERNAL;
+}
+if (ret == DAVS2_GOT_FRAME) {
+*got_frame = davs2_dump_frames(avctx, >out_frame, 
>headerset, ret, frame);
+davs2_decoder_frame_unref(cad->decoder, >out_frame);
+}
+return ret;
+}
+
 static av_cold int davs2_end(AVCodecContext *avctx)
 {
 DAVS2Context *cad = avctx->priv_data;
@@ -147,8 +164,9 @@ static int davs2_decode_frame(AVCodecContext *avctx, void 
*data,
 AVFrame  *frame= data;
 int   ret  = DAVS2_DEFAULT;
 
+/* end of stream, output what is still in the buffers */
 if (!buf_size) {
-return 0;
+return send_delayed_frame(avctx, frame, got_frame);
 }
 
 cad->packet.data = buf_ptr;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 3/3] lavc/libdavs2: add disable_avx into decoder parameter

2018-11-17 Thread hwrenx
From: hwrenx 

Signed-off-by: hwrenx 
---
 libavcodec/libdavs2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index cadf995..8cef49d 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -42,11 +42,14 @@ typedef struct DAVS2Context {
 static av_cold int davs2_init(AVCodecContext *avctx)
 {
 DAVS2Context *cad = avctx->priv_data;
+int cpu_flags = av_get_cpu_flags();
 
 /* init the decoder */
 cad->param.threads  = avctx->thread_count;
 cad->param.info_level   = 0;
 cad->decoder= davs2_decoder_open(>param);
+cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
+cpu_flags & AV_CPU_FLAG_AVX2);
 
 if (!cad->decoder) {
 av_log(avctx, AV_LOG_ERROR, "decoder created error.");
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/3] configure: update api version of libxavs2

2018-11-17 Thread hwrenx
From: hwrenx 

abolish parameter IntraPeriod &&
replaced by IntraPeriodMax/Min
...

more detials could be found in xavs2-git
https://github.com/pkuvcl/xavs2

Signed-off-by: hwrenx 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 9bc4cf3..dee901d 100755
--- a/configure
+++ b/configure
@@ -6191,7 +6191,7 @@ enabled libx264   && { check_pkg_config libx264 
x264 "stdint.h x264.h" x
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 68"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
-enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.2.77" 
"stdint.h xavs2.h" xavs2_api_get
+enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h 
zimg_get_api_version
 enabled libzmq&& require_pkg_config libzmq libzmq zmq.h zmq_ctx_new
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/3] configure: update api version of libdavs2

2018-11-17 Thread hwrenx
From: hwrenx 

add parameter disable_avx
...

more detials could be found in davs2-git
https://github.com/pkuvcl/davs2

Signed-off-by: hwrenx 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index dee901d..fb70181 100755
--- a/configure
+++ b/configure
@@ -6075,7 +6075,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
 enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.0.1" 
"dav1d/dav1d.h" dav1d_version
-enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.5.115" 
davs2.h davs2_decoder_open
+enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel