summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-14 02:22:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-14 02:24:10 +0200
commit80e4fe4063001d0cf468d5f4c7c02ba5b04484b7 (patch)
treeab237b4967339905110c59f6a118bfda9a5a5433 /libavcodec
parent6b61920ab76dc6d85ef462909951923935dd643f (diff)
parentb5849f77095439e994b11c25e6063d443b36c228 (diff)
Merge commit 'b5849f77095439e994b11c25e6063d443b36c228'
* commit 'b5849f77095439e994b11c25e6063d443b36c228': (21 commits) ac3enc: merge AC3MDCTContext with AC3EncodeContext. ac3enc: prefer passing AC3EncodeContext rather than AVCodecContext ac3enc: fix memleak mpeg1video: add CODEC_CAP_SLICE_THREADS. lavf: fix segfault in av_open_input_stream() mpegtsenc: set Random Access indicator on keyframe start packets lavf: Cleanup try_decode_frame() logic. Replace some gotos that lead to single return statements by direct return. build: move tests/seek_test.c to libavformat and reuse generic build rules mxfenc: include needed header for ff_iso8601_to_unix_time() prototype Add a check for strptime(). lavf: factor out conversion of ISO8601 string to unix time wav: parse 'bext' metadata wav: keep parsing until EOF if the input is seekable and we know the size of the data tag wav: Refactor the tag checking into a switch statement wav: make sure neither data_size nor sample_count is negative. wav: refactor the 'fmt ' tag search and parsing. wav: add an option for writing BEXT chunk ffmpeg: get rid of a pointless limit on number of streams. ffmpeg: remove an unused define. ... Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3enc.c33
-rw-r--r--libavcodec/ac3enc.h23
-rw-r--r--libavcodec/ac3enc_fixed.c11
-rw-r--r--libavcodec/ac3enc_float.c17
-rw-r--r--libavcodec/ac3enc_template.c8
-rw-r--r--libavcodec/mpeg12.c2
6 files changed, 45 insertions, 49 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 9b0ee2d335..c90554e689 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1535,10 +1535,10 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
}
-static void dprint_options(AVCodecContext *avctx)
+static void dprint_options(AC3EncodeContext *s)
{
#ifdef DEBUG
- AC3EncodeContext *s = avctx->priv_data;
+ AVCodecContext *avctx = s->avctx;
AC3EncOptions *opt = &s->options;
char strbuf[32];
@@ -1689,9 +1689,9 @@ static void validate_mix_level(void *log_ctx, const char *opt_name,
* Validate metadata options as set by AVOption system.
* These values can optionally be changed per-frame.
*/
-int ff_ac3_validate_metadata(AVCodecContext *avctx)
+int ff_ac3_validate_metadata(AC3EncodeContext *s)
{
- AC3EncodeContext *s = avctx->priv_data;
+ AVCodecContext *avctx = s->avctx;
AC3EncOptions *opt = &s->options;
/* validate mixing levels */
@@ -1820,6 +1820,8 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
av_freep(&s->band_psd_buffer);
av_freep(&s->mask_buffer);
av_freep(&s->qmant_buffer);
+ av_freep(&s->cpl_coord_exp_buffer);
+ av_freep(&s->cpl_coord_mant_buffer);
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
AC3Block *block = &s->blocks[blk];
av_freep(&block->mdct_coef);
@@ -1830,10 +1832,11 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
av_freep(&block->band_psd);
av_freep(&block->mask);
av_freep(&block->qmant);
+ av_freep(&block->cpl_coord_exp);
+ av_freep(&block->cpl_coord_mant);
}
- s->mdct_end(s->mdct);
- av_freep(&s->mdct);
+ s->mdct_end(s);
av_freep(&avctx->coded_frame);
return 0;
@@ -1888,8 +1891,9 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
}
-static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
+static av_cold int validate_options(AC3EncodeContext *s)
{
+ AVCodecContext *avctx = s->avctx;
int i, ret, max_sr;
/* validate channel layout */
@@ -1994,7 +1998,7 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
}
if (!s->eac3) {
- ret = ff_ac3_validate_metadata(avctx);
+ ret = ff_ac3_validate_metadata(s);
if (ret)
return ret;
}
@@ -2081,10 +2085,10 @@ static av_cold void set_bandwidth(AC3EncodeContext *s)
}
-static av_cold int allocate_buffers(AVCodecContext *avctx)
+static av_cold int allocate_buffers(AC3EncodeContext *s)
{
+ AVCodecContext *avctx = s->avctx;
int blk, ch;
- AC3EncodeContext *s = avctx->priv_data;
int channels = s->channels + 1; /* includes coupling channel */
if (s->allocate_sample_buffers(s))
@@ -2197,7 +2201,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
ff_ac3_common_init();
- ret = validate_options(avctx, s);
+ ret = validate_options(s);
if (ret)
return ret;
@@ -2237,12 +2241,11 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
bit_alloc_init(s);
- FF_ALLOCZ_OR_GOTO(avctx, s->mdct, sizeof(AC3MDCTContext), init_fail);
- ret = s->mdct_init(avctx, s->mdct, 9);
+ ret = s->mdct_init(s);
if (ret)
goto init_fail;
- ret = allocate_buffers(avctx);
+ ret = allocate_buffers(s);
if (ret)
goto init_fail;
@@ -2251,7 +2254,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
dsputil_init(&s->dsp, avctx);
ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
- dprint_options(avctx);
+ dprint_options(s);
return 0;
init_fail:
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index be2767ad8c..e3b4ba3133 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -66,10 +66,6 @@ typedef int64_t CoefSumType;
#endif
-typedef struct AC3MDCTContext {
- const SampleType *window; ///< MDCT window function
- FFTContext fft; ///< FFT context for MDCT calculation
-} AC3MDCTContext;
#if 0
/**
* Encoding Options used by AVOption.
@@ -143,7 +139,8 @@ typedef struct AC3EncodeContext {
PutBitContext pb; ///< bitstream writer context
DSPContext dsp;
AC3DSPContext ac3dsp; ///< AC-3 optimized functions
- AC3MDCTContext *mdct; ///< MDCT context
+ FFTContext mdct; ///< FFT context for MDCT calculation
+ const SampleType *mdct_window; ///< MDCT window function array
AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info
@@ -226,8 +223,8 @@ typedef struct AC3EncodeContext {
int ref_bap_set; ///< indicates if ref_bap pointers have been set
/* fixed vs. float function pointers */
- void (*mdct_end)(AC3MDCTContext *mdct);
- int (*mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct, int nbits);
+ void (*mdct_end)(struct AC3EncodeContext *s);
+ int (*mdct_init)(struct AC3EncodeContext *s);
/* fixed vs. float templated function pointers */
int (*allocate_sample_buffers)(struct AC3EncodeContext *s);
@@ -241,7 +238,7 @@ int ff_ac3_encode_init(AVCodecContext *avctx);
int ff_ac3_encode_close(AVCodecContext *avctx);
-int ff_ac3_validate_metadata(AVCodecContext *avctx);
+int ff_ac3_validate_metadata(AC3EncodeContext *s);
void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
@@ -260,13 +257,11 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
-void ff_ac3_fixed_mdct_end(AC3MDCTContext *mdct);
-void ff_ac3_float_mdct_end(AC3MDCTContext *mdct);
+void ff_ac3_fixed_mdct_end(AC3EncodeContext *s);
+void ff_ac3_float_mdct_end(AC3EncodeContext *s);
-int ff_ac3_fixed_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
- int nbits);
-int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
- int nbits);
+int ff_ac3_fixed_mdct_init(AC3EncodeContext *s);
+int ff_ac3_float_mdct_init(AC3EncodeContext *s);
/* prototypes for functions in ac3enc_template.c */
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index cbe92e1d8d..e7dff757b8 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -41,9 +41,9 @@ static AVClass ac3enc_class = { "Fixed-Point AC-3 Encoder", av_default_item_name
/**
* Finalize MDCT and free allocated memory.
*/
-av_cold void AC3_NAME(mdct_end)(AC3MDCTContext *mdct)
+av_cold void AC3_NAME(mdct_end)(AC3EncodeContext *s)
{
- ff_mdct_end(&mdct->fft);
+ ff_mdct_end(&s->mdct);
}
@@ -51,11 +51,10 @@ av_cold void AC3_NAME(mdct_end)(AC3MDCTContext *mdct)
* Initialize MDCT tables.
* @param nbits log2(MDCT size)
*/
-av_cold int AC3_NAME(mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct,
- int nbits)
+av_cold int AC3_NAME(mdct_init)(AC3EncodeContext *s)
{
- int ret = ff_mdct_init(&mdct->fft, nbits, 0, -1.0);
- mdct->window = ff_ac3_window;
+ int ret = ff_mdct_init(&s->mdct, 9, 0, -1.0);
+ s->mdct_window = ff_ac3_window;
return ret;
}
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index e21b99d9e9..83337530f2 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -45,10 +45,10 @@ static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name,
/**
* Finalize MDCT and free allocated memory.
*/
-av_cold void ff_ac3_float_mdct_end(AC3MDCTContext *mdct)
+av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s)
{
- ff_mdct_end(&mdct->fft);
- av_freep(&mdct->window);
+ ff_mdct_end(&s->mdct);
+ av_freep(&s->mdct_window);
}
@@ -56,26 +56,25 @@ av_cold void ff_ac3_float_mdct_end(AC3MDCTContext *mdct)
* Initialize MDCT tables.
* @param nbits log2(MDCT size)
*/
-av_cold int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
- int nbits)
+av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s)
{
float *window;
int i, n, n2;
- n = 1 << nbits;
+ n = 1 << 9;
n2 = n >> 1;
window = av_malloc(n * sizeof(*window));
if (!window) {
- av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
+ av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
return AVERROR(ENOMEM);
}
ff_kbd_window_init(window, 5.0, n2);
for (i = 0; i < n2; i++)
window[n-1-i] = window[i];
- mdct->window = window;
+ s->mdct_window = window;
- return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
+ return ff_mdct_init(&s->mdct, 9, 0, -2.0 / n);
}
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index c7243c7644..9b9151b3e0 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -108,13 +108,13 @@ static void apply_mdct(AC3EncodeContext *s)
const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
apply_window(&s->dsp, s->windowed_samples, input_samples,
- s->mdct->window, AC3_WINDOW_SIZE);
+ s->mdct_window, AC3_WINDOW_SIZE);
if (s->fixed_point)
block->coeff_shift[ch+1] = normalize_samples(s);
- s->mdct->fft.mdct_calcw(&s->mdct->fft, block->mdct_coef[ch+1],
- s->windowed_samples);
+ s->mdct.mdct_calcw(&s->mdct, block->mdct_coef[ch+1],
+ s->windowed_samples);
}
}
}
@@ -424,7 +424,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame,
int ret;
if (!s->eac3 && s->options.allow_per_frame_metadata) {
- ret = ff_ac3_validate_metadata(avctx);
+ ret = ff_ac3_validate_metadata(s);
if (ret)
return ret;
}
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 87dc0fbbed..20155a0219 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -2577,7 +2577,7 @@ AVCodec ff_mpeg1video_decoder = {
NULL,
mpeg_decode_end,
mpeg_decode_frame,
- CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
.flush= flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),