changeset 34652:4e7cc799cf54

lavcac3enc: make the filter buildable with shared FFmpeg Add some local definitions and a bitrate array to make FFmpeg private headers and symbols unneeded, allowing lavcac3enc to be built with shared FFmpeg. This also fixes the issue that the filter code expects the FFmpeg private definition AC3_MAX_CHANNELS to be the maximum number of "logical" channels to be encoded into AC-3, while it actually specifies the maximum channel count in the bitstream, which may include a coupling channel which is not an actual full audio channel. The issue is fixed by making the local AC3_MAX_CHANNELS have the value 6, which the FFmpeg private header also had before the addition of coupling support in 2011. patch by Anssi Hannula, anssi.hannula iki fi
author diego
date Sun, 19 Feb 2012 15:21:23 +0000
parents e4de3e6665ae
children 958431e2cde0
files Makefile libaf/af.c libaf/af_lavcac3enc.c
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Feb 19 14:58:53 2012 +0000
+++ b/Makefile	Sun Feb 19 15:21:23 2012 +0000
@@ -70,6 +70,7 @@
 SRCS_COMMON-$(FASTMEMCPY)            += libvo/aclib.c
 SRCS_COMMON-$(FFMPEG)                += av_helpers.c                \
                                         av_opts.c                   \
+                                        libaf/af_lavcac3enc.c       \
                                         libaf/af_lavcresample.c     \
                                         libmpcodecs/ad_ffmpeg.c     \
                                         libmpcodecs/ad_spdif.c      \
@@ -86,8 +87,7 @@
 SRCS_COMMON-$(CONFIG_VF_LAVFI)      +=  libmpcodecs/vf_lavfi.c
 
 # These filters use private headers and do not work with shared FFmpeg.
-SRCS_COMMON-$(FFMPEG_A)              += libaf/af_lavcac3enc.c    \
-                                        libmpcodecs/vf_fspp.c    \
+SRCS_COMMON-$(FFMPEG_A)              += libmpcodecs/vf_fspp.c    \
                                         libmpcodecs/vf_mcdeint.c \
                                         libmpcodecs/vf_qp.c      \
                                         libmpcodecs/vf_spp.c     \
--- a/libaf/af.c	Sun Feb 19 14:58:53 2012 +0000
+++ b/libaf/af.c	Sun Feb 19 15:21:23 2012 +0000
@@ -72,10 +72,8 @@
 #endif
    &af_info_volnorm,
    &af_info_extrastereo,
-#ifdef CONFIG_FFMPEG_A
+#ifdef CONFIG_FFMPEG
    &af_info_lavcac3enc,
-#endif
-#ifdef CONFIG_FFMPEG
    &af_info_lavcresample,
 #endif
    &af_info_sweep,
--- a/libaf/af_lavcac3enc.c	Sun Feb 19 14:58:53 2012 +0000
+++ b/libaf/af_lavcac3enc.c	Sun Feb 19 15:21:23 2012 +0000
@@ -33,9 +33,18 @@
 #include "av_helpers.h"
 
 #include "libavcodec/avcodec.h"
-#include "libavcodec/ac3.h"
 #include "libavutil/intreadwrite.h"
 
+#define AC3_MAX_CHANNELS            6
+#define AC3_FRAME_SIZE           1536
+#define AC3_MAX_CODED_FRAME_SIZE 3840
+//#define AC3_BIT_RATES_COUNT        19
+
+static const int ac3_bit_rates[] = {
+    32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000,
+    192000, 224000, 256000, 320000, 384000, 448000, 512000, 576000, 640000
+};
+
 // Data for specific instances of this filter
 typedef struct af_ac3enc_s {
     struct AVCodec        *lavc_acodec;
@@ -117,10 +126,10 @@
         if (s->bit_rate < 1000)
             s->bit_rate *= 1000;
         if (s->bit_rate) {
-            for (i = 0; i < 19; ++i)
-                if (ff_ac3_bitrate_tab[i] * 1000 == s->bit_rate)
+            for (i = 0; i < FF_ARRAY_ELEMS(ac3_bit_rates); ++i)
+                if (ac3_bit_rates[i] == s->bit_rate)
                     break;
-            if (i >= 19) {
+            if (i >= FF_ARRAY_ELEMS(ac3_bit_rates)) {
                 mp_msg(MSGT_AFILTER, MSGL_WARN, "af_lavcac3enc unable set unsupported "
                        "bitrate %d, use default bitrate (check manpage to see "
                        "supported bitrates).\n", s->bit_rate);