Revision 6fd96d1a

View differences:

Changelog
70 70
- Windows Televison (WTV) demuxer
71 71
- FFmpeg metadata format muxer and demuxer
72 72
- SubRip (srt) subtitle decoder
73
- floating-point AC-3 encoder added
73 74

  
74 75

  
75 76
version 0.6:
configure
1193 1193
aac_encoder_select="mdct"
1194 1194
aac_latm_decoder_select="aac_decoder aac_latm_parser"
1195 1195
ac3_decoder_select="mdct ac3_parser"
1196
ac3_encoder_select="mdct"
1196 1197
alac_encoder_select="lpc"
1197 1198
amrnb_decoder_select="lsp"
1198 1199
amrwb_decoder_select="lsp"
......
1453 1454
}
1454 1455

  
1455 1456
test_deps _encoder _decoder                                             \
1456
    ac3                                                                 \
1457 1457
    adpcm_g726=g726                                                     \
1458 1458
    adpcm_ima_qt                                                        \
1459 1459
    adpcm_ima_wav                                                       \
......
1525 1525
    wav                                                                 \
1526 1526
    yuv4mpegpipe=yuv4mpeg                                               \
1527 1527

  
1528
ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1528 1529
mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1529 1530

  
1530 1531
set_ne_test_deps pixdesc
libavcodec/Makefile
54 54
                                          mpeg4audio.o
55 55
OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
56 56
OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o
57
OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_fixed.o ac3tab.o ac3.o
57
OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o
58
OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
58 59
OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
59 60
OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o
60 61
OBJS-$(CONFIG_ALS_DECODER)             += alsdec.o bgmc.o mpeg4audio.o
libavcodec/ac3enc.c
37 37
#include "audioconvert.h"
38 38

  
39 39

  
40
#ifndef CONFIG_AC3ENC_FLOAT
41
#define CONFIG_AC3ENC_FLOAT 0
42
#endif
43

  
44

  
40 45
/** Maximum number of exponent groups. +1 for separate DC exponent. */
41 46
#define AC3_MAX_EXP_GROUPS 85
42 47

  
......
44 49
#define SCALE_FLOAT(a, bits) lrintf((a) * (float)(1 << (bits)))
45 50

  
46 51

  
52
#if CONFIG_AC3ENC_FLOAT
53
#include "ac3enc_float.h"
54
#else
47 55
#include "ac3enc_fixed.h"
56
#endif
48 57

  
49 58

  
50 59
/**
......
130 139
} AC3EncodeContext;
131 140

  
132 141

  
133
/* prototypes for functions in ac3enc_fixed.c */
142
/* prototypes for functions in ac3enc_fixed.c and ac3_float.c */
134 143

  
135 144
static av_cold void mdct_end(AC3MDCTContext *mdct);
136 145

  
libavcodec/ac3enc_fixed.c
26 26
 * fixed-point AC-3 encoder.
27 27
 */
28 28

  
29
#undef CONFIG_AC3ENC_FLOAT
29 30
#include "ac3enc.c"
30 31

  
31 32

  
......
413 414
#endif /* TEST */
414 415

  
415 416

  
416
AVCodec ac3_encoder = {
417
    "ac3",
417
AVCodec ac3_fixed_encoder = {
418
    "ac3_fixed",
418 419
    AVMEDIA_TYPE_AUDIO,
419 420
    CODEC_ID_AC3,
420 421
    sizeof(AC3EncodeContext),
libavcodec/ac3enc_float.c
1
/*
2
 * The simplest AC-3 encoder
3
 * Copyright (c) 2000 Fabrice Bellard
4
 * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
5
 * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
6
 *
7
 * This file is part of FFmpeg.
8
 *
9
 * FFmpeg is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * FFmpeg is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with FFmpeg; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
 */
23

  
24
/**
25
 * @file
26
 * floating-point AC-3 encoder.
27
 */
28

  
29
#define CONFIG_AC3ENC_FLOAT 1
30
#include "ac3enc.c"
31

  
32

  
33
/**
34
 * Finalize MDCT and free allocated memory.
35
 */
36
static av_cold void mdct_end(AC3MDCTContext *mdct)
37
{
38
    ff_mdct_end(&mdct->fft);
39
    av_freep(&mdct->window);
40
}
41

  
42

  
43
/**
44
 * Initialize MDCT tables.
45
 * @param nbits log2(MDCT size)
46
 */
47
static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
48
                             int nbits)
49
{
50
    float *window;
51
    int n, n2;
52

  
53
    n  = 1 << nbits;
54
    n2 = n >> 1;
55

  
56
    window = av_malloc(n2 * sizeof(*window));
57
    if (!window) {
58
        av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
59
        return AVERROR(ENOMEM);
60
    }
61
    ff_kbd_window_init(window, 5.0, n2);
62
    mdct->window = window;
63

  
64
    return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
65
}
66

  
67

  
68
/**
69
 * Calculate a 512-point MDCT
70
 * @param out 256 output frequency coefficients
71
 * @param in  512 windowed input audio samples
72
 */
73
static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
74
{
75
    ff_mdct_calc(&mdct->fft, out, in);
76
}
77

  
78

  
79
/**
80
 * Apply KBD window to input samples prior to MDCT.
81
 */
82
static void apply_window(float *output, const float *input,
83
                         const float *window, int n)
84
{
85
    int i;
86
    int n2 = n >> 1;
87

  
88
    for (i = 0; i < n2; i++) {
89
        output[i]     = input[i]     * window[i];
90
        output[n-i-1] = input[n-i-1] * window[i];
91
    }
92
}
93

  
94

  
95
/**
96
 * Normalize the input samples to use the maximum available precision.
97
 */
98
static int normalize_samples(AC3EncodeContext *s)
99
{
100
    /* Normalization is not needed for floating-point samples, so just return 0 */
101
    return 0;
102
}
103

  
104

  
105
AVCodec ac3_encoder = {
106
    "ac3",
107
    AVMEDIA_TYPE_AUDIO,
108
    CODEC_ID_AC3,
109
    sizeof(AC3EncodeContext),
110
    ac3_encode_init,
111
    ac3_encode_frame,
112
    ac3_encode_close,
113
    NULL,
114
    .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
115
    .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
116
    .channel_layouts = ac3_channel_layouts,
117
};
libavcodec/ac3enc_float.h
1
/*
2
 * The simplest AC-3 encoder
3
 * Copyright (c) 2000 Fabrice Bellard
4
 * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
5
 * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
6
 *
7
 * This file is part of FFmpeg.
8
 *
9
 * FFmpeg is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * FFmpeg is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with FFmpeg; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
 */
23

  
24
/**
25
 * @file
26
 * floating-point AC-3 encoder header.
27
 */
28

  
29
#ifndef AVCODEC_AC3ENC_FLOAT_H
30
#define AVCODEC_AC3ENC_FLOAT_H
31

  
32
#include "fft.h"
33

  
34

  
35
typedef float SampleType;
36
typedef float CoefType;
37

  
38
#define SCALE_COEF(a) SCALE_FLOAT((a), 24)
39

  
40

  
41
typedef struct AC3MDCTContext {
42
    const float *window;    ///< MDCT window function
43
    FFTContext fft;         ///< FFT context for MDCT calculation
44
} AC3MDCTContext;
45

  
46
#endif /* AVCODEC_AC3ENC_FLOAT_H */
libavcodec/allcodecs.c
222 222
    REGISTER_ENCDEC  (AAC, aac);
223 223
    REGISTER_DECODER (AAC_LATM, aac_latm);
224 224
    REGISTER_ENCDEC  (AC3, ac3);
225
    REGISTER_ENCODER (AC3_FIXED, ac3_fixed);
225 226
    REGISTER_ENCDEC  (ALAC, alac);
226 227
    REGISTER_DECODER (ALS, als);
227 228
    REGISTER_DECODER (AMRNB, amrnb);
libavcodec/avcodec.h
32 32
#include "libavutil/cpu.h"
33 33

  
34 34
#define LIBAVCODEC_VERSION_MAJOR 52
35
#define LIBAVCODEC_VERSION_MINOR 101
35
#define LIBAVCODEC_VERSION_MINOR 102
36 36
#define LIBAVCODEC_VERSION_MICRO  0
37 37

  
38 38
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
tests/codec-regression.sh
269 269
$tiny_psnr $pcm_dst $pcm_ref 2 1924 >> $logfile
270 270
fi
271 271

  
272
if [ -n "$do_ac3" ] ; then
273
do_audio_encoding ac3.rm "" -vn
272
if [ -n "$do_ac3_fixed" ] ; then
273
do_audio_encoding ac3.rm "" "-vn -acodec ac3_fixed"
274 274
# binaries configured with --disable-sse decode ac3 differently
275 275
#do_audio_decoding
276 276
#$tiny_psnr $pcm_dst $pcm_ref 2 1024 >> $logfile
tests/lavf-regression.sh
57 57

  
58 58
if [ -n "$do_rm" ] ; then
59 59
file=${outfile}lavf.rm
60
do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src
60
do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec ac3_fixed
61 61
# broken
62 62
#do_ffmpeg_crc $file -i $target_path/$file
63 63
fi
tests/ref/acodec/ac3
1
b315176b519a63a35cb91566e768f62b *./tests/data/acodec/ac3.rm
2
98751 ./tests/data/acodec/ac3.rm
tests/ref/acodec/ac3_fixed
1
b315176b519a63a35cb91566e768f62b *./tests/data/acodec/ac3.rm
2
98751 ./tests/data/acodec/ac3.rm

Also available in: Unified diff