Commit 7c1aba4f authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (21 commits)
  fate: allow testing with libavfilter disabled
  x86: XOP/FMA4 CPU detection support
  ws_snd: misc cosmetic clean-ups
  ws_snd: remove the 2-bit ADPCM table and just subtract 2 instead.
  ws_snd: use memcpy() and memset() instead of loops
  ws_snd: use samples pointer for loop termination instead of a separate iterator variable.
  ws_snd: make sure number of channels is 1
  ws_snd: add some checks to prevent buffer overread or overwrite.
  ws_snd: decode to AV_SAMPLE_FMT_U8 instead of S16.
  flacdec: fix buffer size checking in get_metadata_size()
  rtp: Simplify ff_rtp_get_payload_type
  rtpenc: Add a payload type private option
  rtp: Correct ff_rtp_get_payload_type documentation
  avconv: replace all fprintf() by av_log().
  avconv: change av_log verbosity from ERROR to FATAL for fatal errors.
  cmdutils: replace fprintf() by av_log()
  avtools: parse loglevel before all the other options.
  oggdec: add support for Xiph's CELT codec
  sol: return error if av_get_packet() fails.
  cosmetics: reindent and pretty-print
  ...

Conflicts:
	avconv.c
	cmdutils.c
	libavcodec/avcodec.h
	libavcodec/version.h
	libavformat/oggparsecelt.c
	libavformat/utils.c
	libavutil/avutil.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents c2a016ad 908f12f3
......@@ -59,6 +59,7 @@ easier to use. The changes are:
- audio support to lavfi input device added
- libcdio-paranoia input device for audio CD grabbing
- Apple ProRes decoder
- CELT in Ogg demuxing
version 0.8:
......
This diff is collapsed.
......@@ -91,7 +91,7 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
error= "Expected int for %s but found %s\n";
else
return d;
fprintf(stderr, error, context, numstr, min, max);
av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
exit_program(1);
return 0;
}
......@@ -100,8 +100,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr, int is_durat
{
int64_t us;
if (av_parse_time(&us, timestr, is_duration) < 0) {
fprintf(stderr, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit_program(1);
}
return us;
......@@ -305,6 +305,41 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options
}
}
/*
* Return index of option opt in argv or 0 if not found.
*/
static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
{
const OptionDef *po;
int i;
for (i = 1; i < argc; i++) {
const char *cur_opt = argv[i];
if (*cur_opt++ != '-')
continue;
po = find_option(options, cur_opt);
if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')
po = find_option(options, cur_opt + 2);
if ((!po->name && !strcmp(cur_opt, optname)) ||
(po->name && !strcmp(optname, po->name)))
return i;
if (!po || po->flags & HAS_ARG)
i++;
}
return 0;
}
void parse_loglevel(int argc, char **argv, const OptionDef *options)
{
int idx = locate_option(argc, argv, options, "loglevel");
if (idx && argv[idx + 1])
opt_loglevel("loglevel", argv[idx + 1]);
}
#define FLAGS(o) ((o)->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
int opt_default(const char *opt, const char *arg)
{
......@@ -337,7 +372,7 @@ int opt_default(const char *opt, const char *arg)
if (oc || of || os)
return 0;
fprintf(stderr, "Unrecognized option '%s'\n", opt);
av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
return AVERROR_OPTION_NOT_FOUND;
}
......@@ -366,10 +401,10 @@ int opt_loglevel(const char *opt, const char *arg)
level = strtol(arg, &tail, 10);
if (*tail) {
fprintf(stderr, "Invalid loglevel \"%s\". "
"Possible levels are numbers or:\n", arg);
av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". "
"Possible levels are numbers or:\n", arg);
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
fprintf(stderr, "\"%s\"\n", log_levels[i].name);
av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
exit_program(1);
}
av_log_set_level(level);
......@@ -384,7 +419,7 @@ int opt_timelimit(const char *opt, const char *arg)
if (setrlimit(RLIMIT_CPU, &rl))
perror("setrlimit");
#else
fprintf(stderr, "Warning: -%s not implemented on this OS\n", opt);
av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
#endif
return 0;
}
......@@ -396,7 +431,7 @@ void print_error(const char *filename, int err)
if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
errbuf_ptr = strerror(AVUNERROR(err));
fprintf(stderr, "%s: %s\n", filename, errbuf_ptr);
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr);
}
static int warned_cfg = 0;
......@@ -405,58 +440,59 @@ static int warned_cfg = 0;
#define SHOW_VERSION 2
#define SHOW_CONFIG 4
#define PRINT_LIB_INFO(outstream,libname,LIBNAME,flags) \
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
if (CONFIG_##LIBNAME) { \
const char *indent = flags & INDENT? " " : ""; \
if (flags & SHOW_VERSION) { \
unsigned int version = libname##_version(); \
fprintf(outstream, "%slib%-9s %2d.%3d.%2d / %2d.%3d.%2d\n", \
indent, #libname, \
LIB##LIBNAME##_VERSION_MAJOR, \
LIB##LIBNAME##_VERSION_MINOR, \
LIB##LIBNAME##_VERSION_MICRO, \
version >> 16, version >> 8 & 0xff, version & 0xff); \
av_log(NULL, level, "%slib%-9s %2d.%3d.%2d / %2d.%3d.%2d\n",\
indent, #libname, \
LIB##LIBNAME##_VERSION_MAJOR, \
LIB##LIBNAME##_VERSION_MINOR, \
LIB##LIBNAME##_VERSION_MICRO, \
version >> 16, version >> 8 & 0xff, version & 0xff); \
} \
if (flags & SHOW_CONFIG) { \
const char *cfg = libname##_configuration(); \
if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \
if (!warned_cfg) { \
fprintf(outstream, \
av_log(NULL, level, \
"%sWARNING: library configuration mismatch\n", \
indent); \
warned_cfg = 1; \
} \
fprintf(stderr, "%s%-11s configuration: %s\n", \
av_log(NULL, level, "%s%-11s configuration: %s\n", \
indent, #libname, cfg); \
} \
} \
} \
static void print_all_libs_info(FILE* outstream, int flags)
static void print_all_libs_info(int flags, int level)
{
PRINT_LIB_INFO(outstream, avutil, AVUTIL, flags);
PRINT_LIB_INFO(outstream, avcodec, AVCODEC, flags);
PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags);
PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags);
PRINT_LIB_INFO(outstream, avfilter, AVFILTER, flags);
PRINT_LIB_INFO(outstream, swscale, SWSCALE, flags);
PRINT_LIB_INFO(outstream, postproc, POSTPROC, flags);
PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
}
void show_banner(void)
{
fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n",
program_name, program_birth_year, this_year);
fprintf(stderr, " built on %s %s with %s %s\n",
__DATE__, __TIME__, CC_TYPE, CC_VERSION);
fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n");
print_all_libs_info(stderr, INDENT|SHOW_CONFIG);
print_all_libs_info(stderr, INDENT|SHOW_VERSION);
av_log(NULL, AV_LOG_INFO, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n",
program_name, program_birth_year, this_year);
av_log(NULL, AV_LOG_INFO, " built on %s %s with %s %s\n",
__DATE__, __TIME__, CC_TYPE, CC_VERSION);
av_log(NULL, AV_LOG_VERBOSE, " configuration: " FFMPEG_CONFIGURATION "\n");
print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_VERBOSE);
print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_VERBOSE);
}
int opt_version(const char *opt, const char *arg) {
av_log_set_callback(log_callback_help);
printf("%s " FFMPEG_VERSION "\n", program_name);
print_all_libs_info(stdout, SHOW_VERSION);
print_all_libs_info(SHOW_VERSION, AV_LOG_INFO);
return 0;
}
......@@ -758,7 +794,7 @@ int read_file(const char *filename, char **bufptr, size_t *size)
FILE *f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "Cannot read file '%s': %s\n", filename, strerror(errno));
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno));
return AVERROR(errno);
}
fseek(f, 0, SEEK_END);
......@@ -766,7 +802,7 @@ int read_file(const char *filename, char **bufptr, size_t *size)
fseek(f, 0, SEEK_SET);
*bufptr = av_malloc(*size + 1);
if (!*bufptr) {
fprintf(stderr, "Could not allocate file buffer\n");
av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
fclose(f);
return AVERROR(ENOMEM);
}
......
......@@ -178,6 +178,11 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options
*/
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options);
/**
* Find the '-loglevel' option in the commandline args and apply it.
*/
void parse_loglevel(int argc, char **argv, const OptionDef *options);
/**
* Check if the given stream matches a stream specifier.
*
......
......@@ -1630,11 +1630,14 @@ test_deps(){
dep=${v%=*}
tests=${v#*=}
for name in ${tests}; do
eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'"
append ${name}_test_deps ${dep}$suf1 ${dep}$suf2
done
done
}
mxf_d10_test_deps="avfilter"
seek_lavf_mxf_d10_test_deps="mxf_d10_test"
test_deps _encoder _decoder \
adpcm_g726=g726 \
adpcm_ima_qt \
......
......@@ -154,7 +154,8 @@ avconv -i INPUT -metadata:s:1 language=eng OUTPUT
@end example
@item -v @var{number} (@emph{global})
Set the logging verbosity level.
This option is deprecated and has no effect, use -loglevel
to set verbosity level.
@item -target @var{type} (@emph{output})
Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd",
......
This diff is collapsed.
......@@ -3043,6 +3043,7 @@ int main(int argc, char **argv)
VideoState *is;
av_log_set_flags(AV_LOG_SKIP_REPEATED);
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
avcodec_register_all();
......
......@@ -669,6 +669,7 @@ int main(int argc, char **argv)
{
int ret;
parse_loglevel(argc, argv, options);
av_register_all();
init_opts();
#if CONFIG_AVDEVICE
......
......@@ -4669,6 +4669,7 @@ int main(int argc, char **argv)
{
struct sigaction sigact;
parse_loglevel(argc, argv, options);
av_register_all();
show_banner();
......
......@@ -226,9 +226,11 @@ static int get_metadata_size(const uint8_t *buf, int buf_size)
buf += 4;
do {
if (buf_end - buf < 4)
return 0;
ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
buf += 4;
if (buf + metadata_size > buf_end) {
if (buf_end - buf < metadata_size) {
/* need more data in order to read the complete header */
return 0;
}
......
......@@ -35,36 +35,26 @@
#define GSM_MS_BLOCK_SIZE 65
#define GSM_FRAME_SIZE 160
static av_cold int libgsm_init(AVCodecContext *avctx) {
static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
if (avctx->channels > 1) {
av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
avctx->channels);
return -1;
}
if(avctx->codec->decode){
if(!avctx->channels)
avctx->channels= 1;
if(!avctx->sample_rate)
avctx->sample_rate= 8000;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
}else{
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n",
avctx->sample_rate);
if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
return -1;
}
if (avctx->bit_rate != 13000 /* Official */ &&
avctx->bit_rate != 13200 /* Very common */ &&
avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) {
av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n",
avctx->bit_rate);
if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
return -1;
}
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n",
avctx->sample_rate);
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
return -1;
}
if (avctx->bit_rate != 13000 /* Official */ &&
avctx->bit_rate != 13200 /* Very common */ &&
avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) {
av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n",
avctx->bit_rate);
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
return -1;
}
avctx->priv_data = gsm_create();
......@@ -88,7 +78,7 @@ static av_cold int libgsm_init(AVCodecContext *avctx) {
return 0;
}
static av_cold int libgsm_close(AVCodecContext *avctx) {
static av_cold int libgsm_encode_close(AVCodecContext *avctx) {
av_freep(&avctx->coded_frame);
gsm_destroy(avctx->priv_data);
avctx->priv_data = NULL;
......@@ -116,9 +106,9 @@ AVCodec ff_libgsm_encoder = {
.name = "libgsm",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_GSM,
.init = libgsm_init,
.init = libgsm_encode_init,
.encode = libgsm_encode_frame,
.close = libgsm_close,
.close = libgsm_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
......@@ -127,13 +117,52 @@ AVCodec ff_libgsm_ms_encoder = {
.name = "libgsm_ms",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_GSM_MS,
.init = libgsm_init,
.init = libgsm_encode_init,
.encode = libgsm_encode_frame,
.close = libgsm_close,
.close = libgsm_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};
static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
if (avctx->channels > 1) {
av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
avctx->channels);
return -1;
}
if (!avctx->channels)
avctx->channels = 1;
if (!avctx->sample_rate)
avctx->sample_rate = 8000;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->priv_data = gsm_create();
switch(avctx->codec_id) {
case CODEC_ID_GSM:
avctx->frame_size = GSM_FRAME_SIZE;
avctx->block_align = GSM_BLOCK_SIZE;
break;
case CODEC_ID_GSM_MS: {
int one = 1;
gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one);
avctx->frame_size = 2 * GSM_FRAME_SIZE;
avctx->block_align = GSM_MS_BLOCK_SIZE;
}
}
return 0;
}
static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
gsm_destroy(avctx->priv_data);
avctx->priv_data = NULL;
return 0;
}
static int libgsm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt) {
......@@ -158,8 +187,8 @@ AVCodec ff_libgsm_decoder = {
.name = "libgsm",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_GSM,
.init = libgsm_init,
.close = libgsm_close,
.init = libgsm_decode_init,
.close = libgsm_decode_close,
.decode = libgsm_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
......@@ -168,8 +197,8 @@ AVCodec ff_libgsm_ms_decoder = {
.name = "libgsm_ms",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_GSM_MS,
.init = libgsm_init,
.close = libgsm_close,
.init = libgsm_decode_init,
.close = libgsm_decode_close,
.decode = libgsm_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 17
#define LIBAVCODEC_VERSION_MINOR 18
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -25,47 +25,50 @@
/**
* @file
* Westwood SNDx codecs.
* Westwood SNDx codecs
*
* Reference documents about VQA format and its audio codecs
* can be found here:
* http://www.multimedia.cx
*/
static const int8_t ws_adpcm_2bit[] = { -2, -1, 0, 1};
static const int8_t ws_adpcm_4bit[] = {
-9, -8, -6, -5, -4, -3, -2, -1,
0, 1, 2, 3, 4, 5, 6, 8 };
#define CLIP8(a) if(a>127)a=127;if(a<-128)a=-128;
0, 1, 2, 3, 4, 5, 6, 8
};
static av_cold int ws_snd_decode_init(AVCodecContext * avctx)
static av_cold int ws_snd_decode_init(AVCodecContext *avctx)
{
// WSSNDContext *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log_ask_for_sample(avctx, "unsupported number of channels\n");
return AVERROR(EINVAL);
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
return 0;
}
static int ws_snd_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
// WSSNDContext *c = avctx->priv_data;
int buf_size = avpkt->size;
int in_size, out_size;
int sample = 0;
int i;
short *samples = data;
int sample = 128;
uint8_t *samples = data;
uint8_t *samples_end;
if (!buf_size)
return 0;
if (buf_size < 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
out_size = AV_RL16(&buf[0]);
*data_size = out_size * 2;
in_size = AV_RL16(&buf[2]);
in_size = AV_RL16(&buf[2]);
buf += 4;
if (out_size > *data_size) {
......@@ -76,47 +79,63 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
return -1;
}
samples_end = samples + out_size;
if (in_size == out_size) {
for (i = 0; i < out_size; i++)
*samples++ = (*buf++ - 0x80) << 8;
memcpy(samples, buf, out_size);
*data_size = out_size;
return buf_size;
}
while (out_size > 0) {
int code;
while (samples < samples_end && buf - avpkt->data < buf_size) {
int code, smp, size;
uint8_t count;
code = (*buf) >> 6;
count = (*buf) & 0x3F;
code = *buf >> 6;
count = *buf & 0x3F;
buf++;
switch(code) {
/* make sure we don't write past the output buffer */
switch (code) {
case 0: smp = 4; break;
case 1: smp = 2; break;
case 2: smp = (count & 0x20) ? 1 : count + 1; break;
default: smp = count + 1; break;
}
if (samples_end - samples < smp)
break;
/* make sure we don't read past the input buffer */
size = ((code == 2 && (count & 0x20)) || code == 3) ? 0 : count + 1;
if ((buf - avpkt->data) + size > buf_size)
break;
switch (code) {
case 0: /* ADPCM 2-bit */
for (count++; count > 0; count--) {
code = *buf++;
sample += ws_adpcm_2bit[code & 0x3];
CLIP8(sample);
*samples++ = sample << 8;
sample += ws_adpcm_2bit[(code >> 2) & 0x3];
CLIP8(sample);
*samples++ = sample << 8;
sample += ws_adpcm_2bit[(code >> 4) & 0x3];
CLIP8(sample);
*samples++ = sample << 8;
sample += ws_adpcm_2bit[(code >> 6) & 0x3];
CLIP8(sample);
*samples++ = sample << 8;
out_size -= 4;
sample += ( code & 0x3) - 2;
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ((code >> 2) & 0x3) - 2;
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ((code >> 4) & 0x3) - 2;
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += (code >> 6) - 2;
sample = av_clip_uint8(sample);
*samples++ = sample;
}
break;
case 1: /* ADPCM 4-bit */
for (count++; count > 0; count--) {
code = *buf++;
sample += ws_adpcm_4bit[code & 0xF];
CLIP8(sample);
*samples++ = sample << 8;
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ws_adpcm_4bit[code >> 4];
CLIP8(sample);
*samples++ = sample << 8;
out_size -= 2;
sample = av_clip_uint8(sample);
*samples++ = sample;
}
break;
case 2: /* no compression */
......@@ -125,24 +144,23 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
t = count;
t <<= 3;
sample += t >> 3;
*samples++ = sample << 8;
out_size--;
sample = av_clip_uint8(sample);
*samples++ = sample;
} else { /* copy */
for (count++; count > 0; count--) {
*samples++ = (*buf++ - 0x80) << 8;
out_size--;
}
sample = buf[-1] - 0x80;
memcpy(samples, buf, smp);
samples += smp;
buf += smp;
sample = buf[-1];
}
break;
default: /* run */
for(count++; count > 0; count--) {
*samples++ = sample << 8;
out_size--;
}
memset(samples, sample, smp);
samples += smp;
}
}
*data_size = samples - (uint8_t *)data;
return buf_size;
}
......
......@@ -20,9 +20,10 @@
*/
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "oggdec.h"
#include "libavutil/intreadwrite.h"
struct oggcelt_private {
int extra_headers_left;
......@@ -38,11 +39,10 @@ static int celt_header(AVFormatContext *s, int idx)
if (os->psize == 60 &&
!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {
/* Main header */
uint32_t version, header_size av_unused, sample_rate, nb_channels, frame_size;
uint32_t overlap, bytes_per_packet av_unused, extra_headers;
uint32_t version, sample_rate, nb_channels, frame_size;
uint32_t overlap, extra_headers;
uint8_t *extradata;
extradata = av_malloc(2 * sizeof(uint32_t) +
......@@ -54,12 +54,12 @@ static int celt_header(AVFormatContext *s, int idx)
return AVERROR(ENOMEM);
}
version = AV_RL32(p + 28);
header_size = AV_RL32(p + 32); /* unused */
/* unused header size field skipped */
sample_rate = AV_RL32(p + 36);
nb_channels = AV_RL32(p + 40);
frame_size = AV_RL32(p + 44);
overlap = AV_RL32(p + 48);
bytes_per_packet = AV_RL32(p + 52); /* unused */
/* unused bytes per packet field skipped */
extra_headers = AV_RL32(p + 56);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_CELT;
......@@ -67,25 +67,23 @@ static int celt_header(AVFormatContext *s, int idx)
st->codec->channels = nb_channels;
st->codec->frame_size = frame_size;
st->codec->sample_fmt = AV_SAMPLE_FMT_S16;
av_set_pts_info(st, 64, 1, sample_rate);
av_free(st->codec->extradata);
st->codec->extradata = extradata;
st->codec->extradata_size = 2 * sizeof(uint32_t);
if (sample_rate)
av_set_pts_info(st, 64, 1, sample_rate);
priv->extra_headers_left = 1 + extra_headers;
av_free(os->private);
os->private = priv;
AV_WL32(extradata + 0, overlap);
AV_WL32(extradata + 4, version);
av_free(st->codec->extradata);
st->codec->extradata = extradata;
st->codec->extradata_size = 2 * sizeof(uint32_t);
return 1;
} else if(priv && priv->extra_headers_left) {
} else if (priv && priv->extra_headers_left) {
/* Extra headers (vorbiscomment) */
ff_vorbis_comment(s, &st->metadata, p, os->psize);
priv->extra_headers_left--;
return 1;
} else {
return 0;
}
......
......@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <libavutil/opt.h>
#include "avformat.h"
#include "rtp.h"
......@@ -89,26 +90,31 @@ int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type)
return -1;
}
int ff_rtp_get_payload_type(AVCodecContext *codec)
int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
{
int i, payload_type;
int i;
AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;
/* Was the payload type already specified for the RTP muxer? */
if (ofmt && ofmt->priv_class) {
int payload_type = av_get_int(fmt->priv_data, "payload_type", NULL);
if (payload_type >= 0)
return payload_type;
}
/* compute the payload type */
for (payload_type = -1, i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i)
/* static payload type */
for (i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i)
if (AVRtpPayloadTypes[i].codec_id == codec->codec_id) {
if (codec->codec_id == CODEC_ID_H263)
continue;
if (codec->codec_id == CODEC_ID_PCM_S16BE)
if (codec->channels != AVRtpPayloadTypes[i].audio_channels)
continue;
payload_type = AVRtpPayloadTypes[i].pt;
return AVRtpPayloadTypes[i].pt;
}
/* dynamic payload type */
if (payload_type < 0)
payload_type = RTP_PT_PRIVATE + (codec->codec_type == AVMEDIA_TYPE_AUDIO);
return payload_type;
return RTP_PT_PRIVATE + (codec->codec_type == AVMEDIA_TYPE_AUDIO);
}
const char *ff_rtp_enc_name(int payload_type)
......
......@@ -21,17 +21,17 @@
#ifndef AVFORMAT_RTP_H
#define AVFORMAT_RTP_H
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
/**
* Return the payload type for a given codec.
* Return the payload type for a given codec used in the given format context.
*
* @param fmt The context of the format
* @param codec The context of the codec
* @return In case of unknown payload type or dynamic payload type, a
* negative value is returned; otherwise, the payload type (the 'PT' field
* in the RTP header) is returned.
* @return The payload type (the 'PT' field in the RTP header).
*/
int ff_rtp_get_payload_type(AVCodecContext *codec);
int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec);
/**
* Initialize a codec context based on the payload type.
......
......@@ -32,6 +32,7 @@
static const AVOption options[] = {
FF_RTP_FLAG_OPTS(RTPMuxContext, flags),
{ "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};
......@@ -92,7 +93,8 @@ static int rtp_write_header(AVFormatContext *s1)
return -1;
}
s->payload_type = ff_rtp_get_payload_type(st->codec);
if (s->payload_type < 0)
s->payload_type = ff_rtp_get_payload_type(s1, st->codec);
s->base_timestamp = av_get_random_seed();
s->timestamp = s->base_timestamp;
s->cur_timestamp = 0;
......
......@@ -532,7 +532,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
const char *type;
int payload_type;
payload_type = ff_rtp_get_payload_type(c);
payload_type = ff_rtp_get_payload_type(fmt, c);
switch (c->codec_type) {
case AVMEDIA_TYPE_VIDEO : type = "video" ; break;
......
......@@ -132,6 +132,8 @@ static int sol_read_packet(AVFormatContext *s,
if (url_feof(s->pb))
return AVERROR(EIO);
ret= av_get_packet(s->pb, pkt, MAX_SIZE);
if (ret < 0)
return ret;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last
......
......@@ -2122,14 +2122,14 @@ static int has_codec_parameters(AVCodecContext *avctx)
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
val = avctx->sample_rate && avctx->channels && avctx->sample_fmt != AV_SAMPLE_FMT_NONE;
if(!avctx->frame_size &&
(avctx->codec_id == CODEC_ID_VORBIS ||
avctx->codec_id == CODEC_ID_AAC ||
avctx->codec_id == CODEC_ID_MP1 ||
avctx->codec_id == CODEC_ID_MP2 ||
avctx->codec_id == CODEC_ID_MP3 ||
avctx->codec_id == CODEC_ID_SPEEX ||
avctx->codec_id == CODEC_ID_CELT))
if (!avctx->frame_size &&
(avctx->codec_id == CODEC_ID_VORBIS ||
avctx->codec_id == CODEC_ID_AAC ||
avctx->codec_id == CODEC_ID_MP1 ||
avctx->codec_id == CODEC_ID_MP2 ||
avctx->codec_id == CODEC_ID_MP3 ||
avctx->codec_id == CODEC_ID_SPEEX ||
avctx->codec_id == CODEC_ID_CELT))
return 0;
break;
case AVMEDIA_TYPE_VIDEO:
......
......@@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 17
#define LIBAVUTIL_VERSION_MINOR 18
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
......@@ -65,6 +65,8 @@ static const struct {
{ AV_CPU_FLAG_SSE4, "sse4.1" },
{ AV_CPU_FLAG_SSE42, "sse4.2" },
{ AV_CPU_FLAG_AVX, "avx" },
{ AV_CPU_FLAG_XOP, "xop" },
{ AV_CPU_FLAG_FMA4, "fma4" },
{ AV_CPU_FLAG_3DNOW, "3dnow" },
{ AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
#endif
......
......@@ -38,6 +38,8 @@
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
#define AV_CPU_FLAG_IWMMXT 0x0100 ///< XScale IWMMXT
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
......
......@@ -133,6 +133,15 @@ int ff_get_cpu_flags_x86(void)
rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) {
rval |= AV_CPU_FLAG_SSE2SLOW;
}
/* XOP and FMA4 use the AVX instruction coding scheme, so they can't be
* used unless the OS has AVX support. */
if (rval & AV_CPU_FLAG_AVX) {
if (ecx & 0x00000800)
rval |= AV_CPU_FLAG_XOP;
if (ecx & 0x00010000)
rval |= AV_CPU_FLAG_FMA4;
}
}
if (!strncmp(vendor.c, "GenuineIntel", 12)) {
......
......@@ -54,9 +54,12 @@ FATE_SEEK = $(SEEK_TESTS:seek_%=fate-seek-%)
FATE = $(FATE_ACODEC) \
$(FATE_VCODEC) \
$(FATE_LAVF) \
$(FATE_LAVFI) \
$(FATE_SEEK) \
FATE-$(CONFIG_AVFILTER) += $(FATE_LAVFI)
FATE += $(FATE-yes)
$(filter-out %-aref,$(FATE_ACODEC)): $(AREF)
$(filter-out %-vref,$(FATE_VSYNTH1)): fate-vsynth1-vref
$(filter-out %-vref,$(FATE_VSYNTH2)): fate-vsynth2-vref
......@@ -79,7 +82,7 @@ fate-lavfi: $(FATE_LAVFI)
fate-seek: $(FATE_SEEK)
ifdef SAMPLES
FATE += $(FATE_TESTS)
FATE += $(FATE_TESTS) $(FATE_TESTS-yes)
fate-rsync:
rsync -vaLW rsync://fate.ffmpeg.org/fate-suite/ $(SAMPLES)
else
......
......@@ -128,7 +128,7 @@ FATE_TESTS += fate-id-cin-video
fate-id-cin-video: CMD = framecrc -i $(SAMPLES)/idcin/idlog-2MB.cin -pix_fmt rgb24
FATE_TESTS += fate-idroq-video-dpcm
fate-idroq-video-dpcm: CMD = framecrc -i $(SAMPLES)/idroq/idlogo.roq
FATE_TESTS += fate-idroq-video-encode
FATE_TESTS-$(CONFIG_AVFILTER) += fate-idroq-video-encode
fate-idroq-video-encode: CMD = md5 -f image2 -vcodec pgmyuv -i $(SAMPLES)/ffmpeg-synthetic/vsynth1/%02d.pgm -sws_flags +bitexact -vf pad=512:512:80:112 -f RoQ -t 0.2
FATE_TESTS += fate-iff-byterun1
fate-iff-byterun1: CMD = framecrc -i $(SAMPLES)/iff/ASH.LBM -pix_fmt rgb24
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment