]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
transcoding: update ffmpeg to 2.4.1, add flac encoder and decoder, fixes #4828
authorJaroslav Kysela <perex@perex.cz>
Thu, 4 Jan 2018 14:54:46 +0000 (15:54 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 4 Jan 2018 14:55:49 +0000 (15:55 +0100)
Makefile.ffmpeg
src/prop.c
src/prop.h
src/transcoding/codec/codec.c
src/transcoding/codec/codecs/flac.c [new file with mode: 0644]

index e85bdde11f601ebc79afdef50e00f23c0ad28df8..a9d5388a517cd814a058679655308a446c1f7e8b 100644 (file)
@@ -36,8 +36,8 @@ EXTLIBS        =
 COMPONENTS     = avutil avcodec avformat swscale avresample swresample avfilter
 PROTOCOLS      = file http https hls mmsh mmst rtmp rtmpe rtmps rtmpt rtmpte rtmpts \
                  ffrtmpcrypt ffrtmphttp rtp srtp tcp udp udplite unix
-DECODERS       = mpeg2video mp2 aac vorbis ac3 eac3 aac_latm opus h264 hevc theora
-ENCODERS       = mpeg2video mp2 aac vorbis
+DECODERS       = mpeg2video mp2 aac vorbis ac3 eac3 aac_latm opus h264 hevc theora flac
+ENCODERS       = mpeg2video mp2 aac vorbis flac
 MUXERS         = mpegts matroska mp4
 DEMUXERS       = mpegts matroska hls flv live_flv
 BSFS           = h264_mp4toannexb hevc_mp4toannexb
@@ -94,10 +94,10 @@ LIBOPUS_TB     = $(LIBOPUS).tar.gz
 LIBOPUS_URL    = https://archive.mozilla.org/pub/opus/$(LIBOPUS_TB)
 LIBOPUS_SHA1   = 35d108ca9d6a8d05e52d06c5421a5f95b39fdac9
 
-FFMPEG         = ffmpeg-3.4
+FFMPEG         = ffmpeg-3.4.1
 FFMPEG_TB      = $(FFMPEG).tar.bz2
 FFMPEG_URL     = http://ffmpeg.org/releases/$(FFMPEG_TB)
-FFMPEG_SHA1    = 6cfb7f4549a5b2dce6a8442ce16c76739c09dd6d
+FFMPEG_SHA1    = 4347db0b5a5cfc3847395b29aefb51d09cfdd697
 
 # ##############################################################################
 # Library Config
index 08ec072714ac3715356f59b374b92b85c0b89ef3..44e47ed937feb566a4e22b85fbdca67825e7b535 100644 (file)
@@ -541,9 +541,9 @@ prop_serialize_value
 
   /* Split integer value */
   if (pl->intextra) {
-    if (INTEXTRA_IS_SPLIT(pl->intextra))
+    if (INTEXTRA_IS_SPLIT(pl->intextra)) {
       htsmsg_add_u32(m, "intsplit", pl->intextra);
-    else {
+    else {
       htsmsg_add_s32(m, "intmax", INTEXTRA_GET_MAX(pl->intextra));
       htsmsg_add_s32(m, "intmin", INTEXTRA_GET_MIN(pl->intextra));
       htsmsg_add_s32(m, "intstep", INTEXTRA_GET_STEP(pl->intextra));
index 922d1c7b15598f20e4dc3e89cc6c365ce7aca29e..38a216af7ce609a700f7d673d97f4b03b6664e30 100644 (file)
@@ -77,8 +77,8 @@ typedef enum {
 #define INTEXTRA_IS_RANGE(e) (((e) & (1<<31)) != 0)
 #define INTEXTRA_IS_SPLIT(e) !INTEXTRA_IS_RANGE(e)
 #define INTEXTRA_GET_STEP(e) (((e)>>24)&0x7f)
-#define INTEXTRA_GET_MAX(e)  ((e)&(1<<23)?-(((e)>>12)&0x7ff):(((e)>>12)&0x7ff))
-#define INTEXTRA_GET_MIN(e)  ((e)&(1<<11)?-((e)&0x7ff):((e)&0x7ff))
+#define INTEXTRA_GET_MAX(e)  ((e)&(1<<23)?-(0x800-(((e)>>12)&0x7ff)):(((e)>>12)&0x7ff))
+#define INTEXTRA_GET_MIN(e)  ((e)&(1<<11)?-(0x800-((e)&0x7ff)):((e)&0x7ff))
 
 /*
  * Property definition
index 16434ce69000c9ad2aa829ecadee32b4e41046cf..9ee1c61cd7d1c3709a0a3a97ee8816dca577bd20 100644 (file)
@@ -30,6 +30,7 @@ extern TVHCodec tvh_codec_mpeg2video;
 extern TVHCodec tvh_codec_mp2;
 extern TVHCodec tvh_codec_aac;
 extern TVHCodec tvh_codec_vorbis;
+extern TVHCodec tvh_codec_flac;
 
 #if ENABLE_LIBX264
 extern TVHCodec tvh_codec_libx264;
@@ -251,6 +252,7 @@ tvh_codecs_register()
     tvh_codec_register(&tvh_codec_mp2);
     tvh_codec_register(&tvh_codec_aac);
     tvh_codec_register(&tvh_codec_vorbis);
+    tvh_codec_register(&tvh_codec_flac);
 
 #if ENABLE_LIBX264
     tvh_codec_register(&tvh_codec_libx264);
diff --git a/src/transcoding/codec/codecs/flac.c b/src/transcoding/codec/codecs/flac.c
new file mode 100644 (file)
index 0000000..de0ad78
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *  tvheadend - Codec Profiles
+ *
+ *  Copyright (C) 2016 Tvheadend
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "transcoding/codec/internals.h"
+
+
+/* flac ====================================================================== */
+
+// see flac_channel_layouts ffmpeg-3.4/libavcodec/flac.c & flacenc.c
+static const uint64_t flac_channel_layouts[] = {
+    AV_CH_LAYOUT_MONO,
+    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_SURROUND,
+    AV_CH_LAYOUT_QUAD,
+    AV_CH_LAYOUT_5POINT0,
+    AV_CH_LAYOUT_5POINT0_BACK,
+    AV_CH_LAYOUT_5POINT1,
+    AV_CH_LAYOUT_5POINT1_BACK,
+    0
+};
+
+
+typedef struct {
+    TVHAudioCodecProfile;
+    int compression_level;
+} tvh_codec_profile_flac_t;
+
+
+static int
+tvh_codec_profile_flac_open(tvh_codec_profile_flac_t *self, AVDictionary **opts)
+{
+    AV_DICT_SET_INT(opts, "compression_level", self->compression_level, 0);
+    return 0;
+}
+
+static const codec_profile_class_t codec_profile_flac_class = {
+    {
+        .ic_super      = (idclass_t *)&codec_profile_audio_class,
+        .ic_class      = "codec_profile_flac",
+        .ic_caption    = N_("flac"),
+        .ic_properties = (const property_t[]){
+            {
+                .type     = PT_INT,
+                .id       = "complevel",
+                .name     = N_("Compression level"),
+                .desc     = N_("Compression level (0-12), -1 means ffmpeg default"),
+                .group    = 3,
+                .get_opts = codec_profile_class_get_opts,
+                .off      = offsetof(tvh_codec_profile_flac_t, compression_level),
+                .intextra = INTEXTRA_RANGE(-1, 12, 1),
+                .def.i    = -1,
+            },
+            {}
+        }
+    },
+    .open = (codec_profile_open_meth)tvh_codec_profile_flac_open,
+};
+
+
+static int
+tvh_codec_profile_flac_init(TVHCodecProfile *_self, htsmsg_t *conf)
+{
+    tvh_codec_profile_flac_t *self = (tvh_codec_profile_flac_t *)_self;
+
+    self->compression_level = -1;
+    return tvh_codec_profile_audio_init(_self, conf);
+}
+
+
+TVHAudioCodec tvh_codec_flac = {
+    .name            = "flac",
+    .size            = sizeof(tvh_codec_profile_flac_t),
+    .idclass         = &codec_profile_flac_class,
+    .profiles        = NULL,
+    .profile_init    = tvh_codec_profile_flac_init,
+    .profile_destroy = tvh_codec_profile_audio_destroy,
+    .channel_layouts = flac_channel_layouts,
+};