aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-07 02:17:30 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-07 02:17:30 +0200
commit46a47077eee2d7755e17f6557903f383cdfe1b8b (patch)
tree2f42fe2b5bcd4f3e71a24bc9126ce73ecc665a74 /libavcodec
parenta6da14ec3cbe009b2f6fe3eaaa4865e8c8f5ef1a (diff)
parent5adc829eb0787682111ca063bfc2b31558999dff (diff)
downloadffmpeg-46a47077eee2d7755e17f6557903f383cdfe1b8b.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: configure: add functions for testing code fragments af_amix: avoid spurious EAGAIN. af_amix: return AVERROR(EAGAIN) when request_frame didn't produce output. af_amix: only consider negative return codes as errors. avconv: use only meaningful timestamps in start time check. avconv: fix the check for -ss as an output option. mss3: add forgotten 'static' qualifier for private table lavc: options: add planar names for request_sample_fmt flacdec: add planar output support flvdec: Treat all nellymoser versions as the same codec Conflicts: ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/flacdec.c34
-rw-r--r--libavcodec/flacdsp.c35
-rw-r--r--libavcodec/flacdsp.h2
-rw-r--r--libavcodec/flacdsp_template.c47
-rw-r--r--libavcodec/mss3.c2
-rw-r--r--libavcodec/options_table.h5
6 files changed, 97 insertions, 28 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 13ce95d86c..fc68f75e22 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -104,11 +104,22 @@ int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
static void flac_set_bps(FLACContext *s)
{
- if (s->bps > 16) {
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
+ enum AVSampleFormat req = s->avctx->request_sample_fmt;
+ int need32 = s->bps > 16;
+ int want32 = av_get_bytes_per_sample(req) > 2;
+ int planar = av_sample_fmt_is_planar(req);
+
+ if (need32 || want32) {
+ if (planar)
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
+ else
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
s->sample_shift = 32 - s->bps;
} else {
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ if (planar)
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
+ else
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
s->sample_shift = 16 - s->bps;
}
}
@@ -132,7 +143,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
allocate_buffers(s);
flac_set_bps(s);
- ff_flacdsp_init(&s->dsp, avctx->sample_fmt);
+ ff_flacdsp_init(&s->dsp, avctx->sample_fmt, s->bps);
s->got_streaminfo = 1;
avcodec_get_frame_defaults(&s->frame);
@@ -233,7 +244,7 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
allocate_buffers(s);
flac_set_bps(s);
- ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt);
+ ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
s->got_streaminfo = 1;
return 0;
@@ -492,9 +503,11 @@ static int decode_frame(FLACContext *s)
"supported\n");
return -1;
}
- s->bps = s->avctx->bits_per_raw_sample = fi.bps;
- flac_set_bps(s);
+ if (!s->bps) {
+ s->bps = s->avctx->bits_per_raw_sample = fi.bps;
+ flac_set_bps(s);
+ }
if (!s->max_blocksize)
s->max_blocksize = FLAC_MAX_BLOCKSIZE;
@@ -520,7 +533,7 @@ static int decode_frame(FLACContext *s)
if (!s->got_streaminfo) {
allocate_buffers(s);
- ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt);
+ ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
s->got_streaminfo = 1;
dump_headers(s->avctx, (FLACStreaminfo *)s);
}
@@ -628,4 +641,9 @@ AVCodec ff_flac_decoder = {
.decode = flac_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_S16P,
+ AV_SAMPLE_FMT_S32,
+ AV_SAMPLE_FMT_S32P,
+ -1 },
};
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index 6c90e89d9b..bb2a920a72 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -23,10 +23,21 @@
#include "flacdsp.h"
#define SAMPLE_SIZE 16
+#define PLANAR 0
+#include "flacdsp_template.c"
+
+#undef PLANAR
+#define PLANAR 1
#include "flacdsp_template.c"
#undef SAMPLE_SIZE
+#undef PLANAR
#define SAMPLE_SIZE 32
+#define PLANAR 0
+#include "flacdsp_template.c"
+
+#undef PLANAR
+#define PLANAR 1
#include "flacdsp_template.c"
static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
@@ -72,15 +83,27 @@ static void flac_lpc_32_c(int32_t *decoded, const int coeffs[32],
}
-av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt)
+av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt,
+ int bps)
{
+ if (bps > 16)
+ c->lpc = flac_lpc_32_c;
+ else
+ c->lpc = flac_lpc_16_c;
+
switch (fmt) {
case AV_SAMPLE_FMT_S32:
c->decorrelate[0] = flac_decorrelate_indep_c_32;
c->decorrelate[1] = flac_decorrelate_ls_c_32;
c->decorrelate[2] = flac_decorrelate_rs_c_32;
c->decorrelate[3] = flac_decorrelate_ms_c_32;
- c->lpc = flac_lpc_32_c;
+ break;
+
+ case AV_SAMPLE_FMT_S32P:
+ c->decorrelate[0] = flac_decorrelate_indep_c_32p;
+ c->decorrelate[1] = flac_decorrelate_ls_c_32p;
+ c->decorrelate[2] = flac_decorrelate_rs_c_32p;
+ c->decorrelate[3] = flac_decorrelate_ms_c_32p;
break;
case AV_SAMPLE_FMT_S16:
@@ -88,7 +111,13 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt)
c->decorrelate[1] = flac_decorrelate_ls_c_16;
c->decorrelate[2] = flac_decorrelate_rs_c_16;
c->decorrelate[3] = flac_decorrelate_ms_c_16;
- c->lpc = flac_lpc_16_c;
+ break;
+
+ case AV_SAMPLE_FMT_S16P:
+ c->decorrelate[0] = flac_decorrelate_indep_c_16p;
+ c->decorrelate[1] = flac_decorrelate_ls_c_16p;
+ c->decorrelate[2] = flac_decorrelate_rs_c_16p;
+ c->decorrelate[3] = flac_decorrelate_ms_c_16p;
break;
}
}
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index e2abefb7f5..efb5e02ef4 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -29,6 +29,6 @@ typedef struct FLACDSPContext {
int qlevel, int len);
} FLACDSPContext;
-void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt);
+void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
#endif /* AVCODEC_FLACDSP_H */
diff --git a/libavcodec/flacdsp_template.c b/libavcodec/flacdsp_template.c
index 808b20d41d..62c0a15ff6 100644
--- a/libavcodec/flacdsp_template.c
+++ b/libavcodec/flacdsp_template.c
@@ -19,68 +19,85 @@
*/
#include <stdint.h>
+#include "libavutil/avutil.h"
#undef FUNC
+#undef FSUF
#undef sample
+#undef sample_type
+#undef OUT
+#undef S
#if SAMPLE_SIZE == 32
-# define FUNC(n) n ## _32
-# define sample int32_t
+# define sample_type int32_t
#else
-# define FUNC(n) n ## _16
-# define sample int16_t
+# define sample_type int16_t
#endif
+#if PLANAR
+# define FSUF AV_JOIN(SAMPLE_SIZE, p)
+# define sample sample_type *
+# define OUT(n) n
+# define S(s, c, i) (s[c][i])
+#else
+# define FSUF SAMPLE_SIZE
+# define sample sample_type
+# define OUT(n) n[0]
+# define S(s, c, i) (*s++)
+#endif
+
+#define FUNC(n) AV_JOIN(n ## _, FSUF)
+
static void FUNC(flac_decorrelate_indep_c)(uint8_t **out, int32_t **in,
int channels, int len, int shift)
{
- sample *samples = (sample *) out[0];
+ sample *samples = (sample *) OUT(out);
int i, j;
for (j = 0; j < len; j++)
for (i = 0; i < channels; i++)
- *samples++ = in[i][j] << shift;
+ S(samples, i, j) = in[i][j] << shift;
}
static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in,
int channels, int len, int shift)
{
- sample *samples = (sample *) out[0];
+ sample *samples = (sample *) OUT(out);
int i;
for (i = 0; i < len; i++) {
int a = in[0][i];
int b = in[1][i];
- *samples++ = a << shift;
- *samples++ = (a - b) << shift;
+ S(samples, 0, i) = a << shift;
+ S(samples, 1, i) = (a - b) << shift;
}
}
static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in,
int channels, int len, int shift)
{
- sample *samples = (sample *) out[0];
+ sample *samples = (sample *) OUT(out);
int i;
for (i = 0; i < len; i++) {
int a = in[0][i];
int b = in[1][i];
- *samples++ = (a + b) << shift;
- *samples++ = b << shift;
+ S(samples, 0, i) = (a + b) << shift;
+ S(samples, 1, i) = b << shift;
}
}
static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in,
int channels, int len, int shift)
{
- sample *samples = (sample *) out[0];
+ sample *samples = (sample *) OUT(out);
int i;
for (i = 0; i < len; i++) {
int a = in[0][i];
int b = in[1][i];
a -= b >> 1;
- *samples++ = (a + b) << shift;
- *samples++ = a << shift;
+ S(samples, 0, i) = (a + b) << shift;
+ S(samples, 1, i) = a << shift;
}
}
diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index 4f33984e06..649b7ca918 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -141,7 +141,7 @@ static const uint8_t mss3_chroma_quant[64] = {
99, 99, 99, 99, 99, 99, 99, 99
};
-const uint8_t zigzag_scan[64] = {
+static const uint8_t zigzag_scan[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 44eaa773a6..a4742d0e55 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -400,6 +400,11 @@ static const AVOption options[]={
{"s32", "32-bit signed integer", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
{"flt", "32-bit float", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_FLT }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
{"dbl", "64-bit double", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_DBL }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+{"u8p" , "8-bit unsigned integer planar", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_U8P }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+{"s16p", "16-bit signed integer planar", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S16P }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+{"s32p", "32-bit signed integer planar", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32P }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+{"fltp", "32-bit float planar", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_FLTP }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
+{"dblp", "64-bit double planar", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_DBLP }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
{NULL},
};