mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 12:09:55 +00:00
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>
This commit is contained in:
commit
46a47077ee
39
configure
vendored
39
configure
vendored
@ -716,6 +716,20 @@ check_ld(){
|
||||
check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
|
||||
}
|
||||
|
||||
check_code(){
|
||||
log check_code "$@"
|
||||
check=$1
|
||||
headers=$2
|
||||
code=$3
|
||||
shift 3
|
||||
{
|
||||
for hdr in $headers; do
|
||||
echo "#include <$hdr>"
|
||||
done
|
||||
echo "int main(void) { $code; return 0; }"
|
||||
} | check_$check "$@"
|
||||
}
|
||||
|
||||
check_cppflags(){
|
||||
log check_cppflags "$@"
|
||||
set -- $($filter_cppflags "$@")
|
||||
@ -912,15 +926,7 @@ check_type(){
|
||||
type=$2
|
||||
shift 2
|
||||
disable_safe "$type"
|
||||
incs=""
|
||||
for hdr in $headers; do
|
||||
incs="$incs
|
||||
#include <$hdr>"
|
||||
done
|
||||
check_cc "$@" <<EOF && enable_safe "$type"
|
||||
$incs
|
||||
$type v;
|
||||
EOF
|
||||
check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
|
||||
}
|
||||
|
||||
check_struct(){
|
||||
@ -930,15 +936,8 @@ check_struct(){
|
||||
member=$3
|
||||
shift 3
|
||||
disable_safe "${struct}_${member}"
|
||||
incs=""
|
||||
for hdr in $headers; do
|
||||
incs="$incs
|
||||
#include <$hdr>"
|
||||
done
|
||||
check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
|
||||
$incs
|
||||
const void *p = &(($struct *)0)->$member;
|
||||
EOF
|
||||
check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
|
||||
enable_safe "${struct}_${member}"
|
||||
}
|
||||
|
||||
require(){
|
||||
@ -2689,9 +2688,7 @@ case "$arch" in
|
||||
;;
|
||||
x86)
|
||||
subarch="x86_32"
|
||||
check_cc <<EOF && subarch="x86_64"
|
||||
int test[(int)sizeof(char*) - 7];
|
||||
EOF
|
||||
check_code cc "" "int test[(int)sizeof(char*) - 7]" && subarch="x86_64"
|
||||
if test "$subarch" = "x86_64"; then
|
||||
spic=$shared
|
||||
fi
|
||||
|
@ -104,10 +104,21 @@ int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
|
||||
|
||||
static void flac_set_bps(FLACContext *s)
|
||||
{
|
||||
if (s->bps > 16) {
|
||||
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 {
|
||||
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;
|
||||
|
||||
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 },
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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},
|
||||
};
|
||||
|
||||
|
@ -354,7 +354,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples)
|
||||
s->input_state[i] = INPUT_OFF;
|
||||
continue;
|
||||
}
|
||||
} else if (ret)
|
||||
} else if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
@ -403,7 +403,7 @@ static int request_frame(AVFilterLink *outlink)
|
||||
|
||||
available_samples = get_available_samples(s);
|
||||
if (!available_samples)
|
||||
return 0;
|
||||
return AVERROR(EAGAIN);
|
||||
|
||||
return output_frame(outlink, available_samples);
|
||||
}
|
||||
@ -416,7 +416,7 @@ static int request_frame(AVFilterLink *outlink)
|
||||
return AVERROR_EOF;
|
||||
else
|
||||
return AVERROR(EAGAIN);
|
||||
} else if (ret)
|
||||
} else if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
av_assert0(s->frame_list->nb_frames > 0);
|
||||
@ -431,10 +431,12 @@ static int request_frame(AVFilterLink *outlink)
|
||||
ret = calc_active_inputs(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (s->active_inputs > 1) {
|
||||
available_samples = get_available_samples(s);
|
||||
if (!available_samples)
|
||||
return 0;
|
||||
return AVERROR(EAGAIN);
|
||||
available_samples = FFMIN(available_samples, wanted_samples);
|
||||
} else {
|
||||
available_samples = wanted_samples;
|
||||
|
@ -113,11 +113,7 @@ static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
|
||||
case FLV_CODECID_MP3:
|
||||
return acodec->codec_id == CODEC_ID_MP3;
|
||||
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
|
||||
return acodec->sample_rate == 8000 &&
|
||||
acodec->codec_id == CODEC_ID_NELLYMOSER;
|
||||
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
|
||||
return acodec->sample_rate == 16000 &&
|
||||
acodec->codec_id == CODEC_ID_NELLYMOSER;
|
||||
case FLV_CODECID_NELLYMOSER:
|
||||
return acodec->codec_id == CODEC_ID_NELLYMOSER;
|
||||
case FLV_CODECID_PCM_MULAW:
|
||||
|
Loading…
Reference in New Issue
Block a user