[vlc-commits] [Git][videolan/vlc][master] 4 commits: fourcc: add mappings for AVS2 and AVS3
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue Jan 11 19:44:15 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
d591b868 by Rémi Denis-Courmont at 2022-01-11T19:10:51+00:00
fourcc: add mappings for AVS2 and AVS3
This keeps the C prefix for Chinese for consistency with the existing
AVS mapping. Another option would be to drop the C, and rename the rare
legacy video game coding also called AVS.
The AVI mapping is taken from libavformat's RIFF parser.
- - - - -
7b01dd3b by Rémi Denis-Courmont at 2022-01-11T19:10:51+00:00
avcodec: add mappings for AVS2 and AVS3
- - - - -
708a7d13 by Rémi Denis-Courmont at 2022-01-11T19:10:51+00:00
mkv: add mappings for AVS 1, 2 & 3 video codecs
- - - - -
170f0352 by Rémi Denis-Courmont at 2022-01-11T19:10:51+00:00
davs2: AVS2 decoder with libdavs2
This adds an initial AVS2-P2 video decoder using libdavs2.
- - - - -
8 changed files:
- configure.ac
- include/vlc_fourcc.h
- modules/codec/Makefile.am
- modules/codec/avcodec/fourcc.c
- + modules/codec/davs2.c
- modules/demux/mkv/matroska_segment_parse.cpp
- po/POTFILES.in
- src/misc/fourcc_list.h
Changes:
=====================================
configure.ac
=====================================
@@ -3036,6 +3036,13 @@ dnl Intel QuickSync (aka MediaSDK) H264/H262 encoder
dnl
PKG_ENABLE_MODULES_VLC([MFX], [qsv], [libmfx], [Intel QuickSync MPEG4-Part10/MPEG2 (aka H.264/H.262) encoder], [auto])
+
+dnl
+dnl AVS2 decoder module (davs2)
+dnl
+PKG_ENABLE_MODULES_VLC([DAVS2], [davs2], [davs2], [AVS2 video decoder with libdavs2], [auto])
+
+
dnl
dnl libfluidsynth (MIDI synthetizer) plugin
dnl
=====================================
include/vlc_fourcc.h
=====================================
@@ -55,6 +55,8 @@
#define VLC_CODEC_DIRAC VLC_FOURCC('d','r','a','c')
#define VLC_CODEC_OGGSPOTS VLC_FOURCC('S','P','O','T')
#define VLC_CODEC_CAVS VLC_FOURCC('C','A','V','S')
+#define VLC_CODEC_CAVS2 VLC_FOURCC('A','V','S','2')
+#define VLC_CODEC_CAVS3 VLC_FOURCC('A','V','S','3')
#define VLC_CODEC_NUV VLC_FOURCC('N','J','P','G')
#define VLC_CODEC_RV10 VLC_FOURCC('R','V','1','0')
#define VLC_CODEC_RV13 VLC_FOURCC('R','V','1','3')
=====================================
modules/codec/Makefile.am
=====================================
@@ -91,6 +91,13 @@ codec_LTLIBRARIES += libuleaddvaudio_plugin.la
libcdg_plugin_la_SOURCES = codec/cdg.c
codec_LTLIBRARIES += libcdg_plugin.la
+libdavs2_plugin_la_SOURCES = codec/davs2.c
+libdavs2_plugin_la_CFLAGS = $(AM_CFLAGS) $(DAVS2_CFLAGS)
+libdavs2_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
+libdavs2_plugin_la_LIBADD = $(DAVS2_LIBS) $(LIBM)
+EXTRA_LTLIBRARIES += libdavs2_plugin.la
+codec_LTLIBRARIES += $(LTLIBdavs2)
+
liblibmpeg2_plugin_la_SOURCES = codec/libmpeg2.c \
codec/synchro.c codec/synchro.h
liblibmpeg2_plugin_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_libmpeg2)
@@ -571,7 +578,6 @@ libqsv_plugin_la_LIBADD = $(MFX_LIBS)
EXTRA_LTLIBRARIES += libqsv_plugin.la
codec_LTLIBRARIES += $(LTLIBqsv)
-
### External frameworks ###
libdmo_plugin_la_SOURCES = codec/dmo/dmo.c codec/dmo/dmo.h codec/dmo/buffer.c
=====================================
modules/codec/avcodec/fourcc.c
=====================================
@@ -146,6 +146,12 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
{ VLC_CODEC_KMVC, AV_CODEC_ID_KMVC },
{ VLC_CODEC_FLASHSV, AV_CODEC_ID_FLASHSV },
{ VLC_CODEC_CAVS, AV_CODEC_ID_CAVS },
+#if LIBAVCODEC_VERSION_CHECK(58, 22, 100)
+ { VLC_CODEC_CAVS2, AV_CODEC_ID_AVS2 },
+#endif
+#if LIBAVCODEC_VERSION_CHECK(58, 109, 100)
+ { VLC_CODEC_CAVS3, AV_CODEC_ID_AVS3 },
+#endif
{ VLC_CODEC_JPEG2000, AV_CODEC_ID_JPEG2000 },
{ VLC_CODEC_VMNC, AV_CODEC_ID_VMNC },
{ VLC_CODEC_VP5, AV_CODEC_ID_VP5 },
=====================================
modules/codec/davs2.c
=====================================
@@ -0,0 +1,264 @@
+/*****************************************************************************
+ * davs2.c: AVS2-P2 video decoder using libdavs2
+ *****************************************************************************
+ * Copyright © 2021 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * NOTA BENE: this module requires the linking against a library which is
+ * known to require licensing under the GNU General Public License version 2
+ * (or later). Therefore, the result of compiling this module will normally
+ * be subject to the terms of that later license.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include <davs2.h>
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_frame.h>
+#include <vlc_codec.h>
+#include <vlc_cpu.h>
+
+static void UpdateFormat(decoder_t *dec, const davs2_seq_info_t *info)
+{
+ vlc_fourcc_t chroma = 0;
+ video_format_t *fmt = &dec->fmt_out.video;
+
+ switch (info->output_bit_depth) {
+ case 8:
+ switch (info->chroma_format) {
+ case 1:
+ chroma = VLC_CODEC_I420;
+ break;
+ case 2:
+ chroma = VLC_CODEC_I422;
+ break;
+ default:
+ msg_Err(dec, "unsupported chromatic sampling: %"PRIu32,
+ info->chroma_format);
+ }
+ break;
+ case 10:
+ switch (info->chroma_format) {
+#ifdef WORDS_BIGENDIAN
+ case 1:
+ chroma = VLC_CODEC_I420_10B;
+ break;
+ case 2:
+ chroma = VLC_CODEC_I422_10B;
+ break;
+#else
+ case 1:
+ chroma = VLC_CODEC_I420_10L;
+ break;
+ case 2:
+ chroma = VLC_CODEC_I422_10L;
+ break;
+#endif
+ default:
+ msg_Err(dec, "unsupported chromatic sampling: %"PRIu32,
+ info->chroma_format);
+ }
+ break;
+ default:
+ msg_Err(dec, "unsupported bit depth: %"PRIu32,
+ info->output_bit_depth);
+ }
+
+ dec->fmt_out.i_codec = chroma;
+ video_format_Init(fmt, chroma);
+ fmt->i_width = info->width;
+ fmt->i_height = info->height;
+ fmt->i_visible_width = info->width;
+ fmt->i_visible_height = info->height;
+ fmt->i_sar_num = 1;
+ fmt->i_sar_den = 1;
+ assert(info->frame_rate_id != 0);
+
+ static const struct {
+ uint16_t num;
+ uint16_t den;
+ } frame_rates[] = {
+ { 24000, 1001 }, { 24, 1 }, { 25, 1 }, { 30000, 1001 }, { 30, 1 },
+ { 50, 1 }, { 60000, 1001 }, { 60, 1 }
+ };
+
+ if (info->frame_rate_id <= ARRAY_SIZE(frame_rates)) {
+ fmt->i_frame_rate = frame_rates[info->frame_rate_id - 1].num;
+ fmt->i_frame_rate_base = frame_rates[info->frame_rate_id - 1].den;
+ } else {
+ msg_Warn(dec, "unknown frame rate %f (ID: %"PRIu32")",
+ info->frame_rate, info->frame_rate_id);
+ fmt->i_frame_rate = lroundf(ldexpf(info->frame_rate, 16));
+ fmt->i_frame_rate_base = 1 << 16;
+ }
+}
+
+static void SendPicture(decoder_t *dec, davs2_picture_t *frame)
+{
+ picture_t *pic = decoder_NewPicture(dec);
+
+ if (likely(pic != NULL)) {
+ for (int i = 0; i < pic->i_planes; i++) {
+ /*
+ * As of davs2 1.6.0, passing custom output picture buffers is not
+ * supported, so we have to copy here.
+ */
+ plane_t plane = {
+ .p_pixels = frame->planes[i],
+ .i_lines = frame->lines[i],
+ .i_pitch = frame->strides[i],
+ .i_pixel_pitch = (frame->bit_depth + 7) / 8,
+ .i_visible_lines = frame->lines[i],
+ .i_visible_pitch = frame->strides[i],
+ };
+
+ plane_CopyPixels(pic->p + i, &plane);
+ }
+
+ pic->date = frame->pts;
+ decoder_QueueVideo(dec, pic);
+ }
+}
+
+static void Flush(decoder_t *dec)
+{
+ void *hd = dec->p_sys;
+ int ret;
+
+ do {
+ davs2_seq_info_t info;
+ davs2_picture_t frame;
+
+ ret = davs2_decoder_flush(hd, &info, &frame);
+ davs2_decoder_frame_unref(hd, &frame);
+ } while (ret != DAVS2_ERROR && ret != DAVS2_END);
+}
+
+static int Dequeue(decoder_t *dec,
+ int (*func)(void *, davs2_seq_info_t *, davs2_picture_t *))
+{
+ davs2_seq_info_t info;
+ davs2_picture_t frame;
+ int ret = func(dec->p_sys, &info, &frame);
+
+ switch (ret) {
+ case DAVS2_ERROR:
+ msg_Err(dec, "decoding error");
+ break;
+
+ case DAVS2_DEFAULT:
+ case DAVS2_END:
+ break;
+
+ case DAVS2_GOT_HEADER:
+ UpdateFormat(dec, &info);
+ break;
+
+ case DAVS2_GOT_FRAME:
+ if (decoder_UpdateVideoFormat(dec) == 0)
+ SendPicture(dec, &frame);
+ break;
+
+ default:
+ vlc_assert_unreachable();
+ }
+
+ davs2_decoder_frame_unref(dec->p_sys, &frame);
+ return ret;
+}
+
+static int Decode(decoder_t *dec, vlc_frame_t *block)
+{
+ if (block == NULL) {
+ /* Drain */
+ int ret;
+
+ do
+ ret = Dequeue(dec, davs2_decoder_flush);
+ while (ret != DAVS2_ERROR && ret != DAVS2_END);
+
+ return VLCDEC_SUCCESS;
+ }
+
+ if (!(block->i_flags & BLOCK_FLAG_CORRUPTED)) {
+ assert(block->i_buffer <= INT_MAX);
+
+ davs2_packet_t packet = {
+ .data = block->p_buffer,
+ .len = block->i_buffer,
+ .pts = block->i_pts,
+ .dts = block->i_dts,
+ };
+
+ if (davs2_decoder_send_packet(dec->p_sys, &packet) == DAVS2_ERROR)
+ msg_Err(dec, "decoding error");
+ }
+
+ block_Release(block);
+
+ Dequeue(dec, davs2_decoder_recv_frame);
+ return VLCDEC_SUCCESS;
+}
+
+static void Close(vlc_object_t *obj)
+{
+ decoder_t *dec = (decoder_t *)obj;
+
+ davs2_decoder_close(dec->p_sys);
+}
+
+static int Open(vlc_object_t *obj)
+{
+ decoder_t *dec = (decoder_t *)obj;
+
+ if (dec->fmt_in.i_codec != VLC_CODEC_CAVS2)
+ return VLC_EGENERIC;
+
+ davs2_param_t params = {
+ .threads = vlc_GetCPUCount(),
+ };
+
+ if (params.threads > 8)
+ params.threads = 8;
+
+ dec->p_sys = davs2_decoder_open(¶ms);
+ if (dec->p_sys == NULL) {
+ msg_Err(obj, "decoder opening error");
+ return VLC_EGENERIC;
+ }
+
+ dec->pf_decode = Decode;
+ dec->pf_flush = Flush;
+ return VLC_SUCCESS;
+}
+
+vlc_module_begin()
+ set_shortname("davs2")
+ set_description(N_("AVS2 decoder (using davs2)"))
+ set_capability("video decoder", 200)
+ set_callbacks(Open, Close)
+ set_subcategory(SUBCAT_INPUT_VCODEC)
+vlc_module_end()
=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -1744,6 +1744,15 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
fill_extra_data( vars.p_tk, 0 );
}
+ S_CASE("V_CAVS") {
+ vars.p_fmt->i_codec = VLC_CODEC_CAVS;
+ }
+ S_CASE("V_AVS2") {
+ vars.p_fmt->i_codec = VLC_CODEC_CAVS2;
+ }
+ S_CASE("V_AVS3") {
+ vars.p_fmt->i_codec = VLC_CODEC_CAVS3;
+ }
S_CASE("V_MPEG4/MS/V3") {
vars.p_fmt->i_codec = VLC_CODEC_DIV3;
}
=====================================
po/POTFILES.in
=====================================
@@ -297,6 +297,7 @@ modules/codec/cea708.h
modules/codec/cvdsub.c
modules/codec/daala.c
modules/codec/dav1d.c
+modules/codec/davs2.c
modules/codec/dca.c
modules/codec/ddummy.c
modules/codec/dmo/dmo.c
=====================================
src/misc/fourcc_list.h
=====================================
@@ -673,6 +673,11 @@ static const staticentry_t p_list_video[] = {
A("AVs2"),
A("avs2"),
+ B(VLC_CODEC_CAVS2, "AVS2-P2 video (IEEE 1857.4)"),
+ A("AVS2"),
+
+ B(VLC_CODEC_CAVS3, "AVS3-P2 video (IEEE 1857.10)"),
+
B(VLC_CODEC_AMV, "AMV"),
B(VLC_CODEC_BINKVIDEO, "Bink Video"),
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b0fdb5243363a71e2f943ad752bdfd688234ebac...170f0352f9c8c35f995f3f1db49e09c584b39691
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b0fdb5243363a71e2f943ad752bdfd688234ebac...170f0352f9c8c35f995f3f1db49e09c584b39691
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list