From: Jaroslav Kysela Date: Thu, 4 Jan 2018 14:54:46 +0000 (+0100) Subject: transcoding: update ffmpeg to 2.4.1, add flac encoder and decoder, fixes #4828 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a79e82921a8a714f5febc7c119080fd31c1142cf;p=thirdparty%2Ftvheadend.git transcoding: update ffmpeg to 2.4.1, add flac encoder and decoder, fixes #4828 --- diff --git a/Makefile.ffmpeg b/Makefile.ffmpeg index e85bdde11..a9d5388a5 100644 --- a/Makefile.ffmpeg +++ b/Makefile.ffmpeg @@ -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 diff --git a/src/prop.c b/src/prop.c index 08ec07271..44e47ed93 100644 --- a/src/prop.c +++ b/src/prop.c @@ -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)); diff --git a/src/prop.h b/src/prop.h index 922d1c7b1..38a216af7 100644 --- a/src/prop.h +++ b/src/prop.h @@ -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 diff --git a/src/transcoding/codec/codec.c b/src/transcoding/codec/codec.c index 16434ce69..9ee1c61cd 100644 --- a/src/transcoding/codec/codec.c +++ b/src/transcoding/codec/codec.c @@ -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 index 000000000..de0ad78a6 --- /dev/null +++ b/src/transcoding/codec/codecs/flac.c @@ -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 . + */ + + +#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, +};