[MPlayer-cvslog] r34740 - in trunk: Makefile libaf/af.c libaf/af_lavcac3enc.c

diego subversion at mplayerhq.hu
Sun Feb 19 16:21:23 CET 2012


Author: diego
Date: Sun Feb 19 16:21:23 2012
New Revision: 34740

Log:
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

Modified:
   trunk/Makefile
   trunk/libaf/af.c
   trunk/libaf/af_lavcac3enc.c

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Sun Feb 19 15:58:53 2012	(r34739)
+++ trunk/Makefile	Sun Feb 19 16:21:23 2012	(r34740)
@@ -70,6 +70,7 @@ SRCS_COMMON-$(FAAD)                  += 
 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-$(FFMPEG)                += 
 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     \

Modified: trunk/libaf/af.c
==============================================================================
--- trunk/libaf/af.c	Sun Feb 19 15:58:53 2012	(r34739)
+++ trunk/libaf/af.c	Sun Feb 19 16:21:23 2012	(r34740)
@@ -72,10 +72,8 @@ static const af_info_t * const filter_li
 #endif
    &af_info_volnorm,
    &af_info_extrastereo,
-#ifdef CONFIG_FFMPEG_A
-   &af_info_lavcac3enc,
-#endif
 #ifdef CONFIG_FFMPEG
+   &af_info_lavcac3enc,
    &af_info_lavcresample,
 #endif
    &af_info_sweep,

Modified: trunk/libaf/af_lavcac3enc.c
==============================================================================
--- trunk/libaf/af_lavcac3enc.c	Sun Feb 19 15:58:53 2012	(r34739)
+++ trunk/libaf/af_lavcac3enc.c	Sun Feb 19 16:21:23 2012	(r34740)
@@ -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 @@ static int control(struct af_instance_s 
         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);


More information about the MPlayer-cvslog mailing list