Commit 721be993 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  cosmetics: fix some then/than typos
  doxygen: Include libavcodec and libavformat examples into the documentation
  avutil: elaborate documentation for av_get_random_seed
  Add support for aac streams in mp4/mov without extradata.
  aes: whitespace cosmetics
  adler32: whitespace cosmetics
  swscale: fix another yuv range conversion overflow in 16bit scaling.
  Fix cpu flags test program
  opt-test: Add missing braces to silence compiler warnings.
  build: Eliminate obsolete test targets.
  udp: Fix a compilation warning
  swscale: Unbreak build with --enable-small
  base64: add fate test
  aes: improve test program and add fate test
  adler32: make test program more useful and add fate test
  swscale: fix yuv range correction when using 16-bit scaling.
  aacenc: Make chan_map const correct

Conflicts:
	Makefile
	doc/examples/muxing-example.c
	libavformat/udp.c
	libavutil/random_seed.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 9251942c be73d76b
......@@ -591,7 +591,7 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
EXAMPLE_PATH = libavcodec/api-example.c libavformat/output-example.c
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
......
......@@ -150,8 +150,6 @@ distclean::
config:
$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
check: test
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/tests/Makefile
......
......@@ -20,8 +20,9 @@
/**
* @file
* avcodec API use example.
* libavcodec API use example.
*
* @example libavcodec/api-example.c
* Note that this library only handles codecs (mpeg, mpeg4, etc...),
* not file formats (avi, vob, etc...). See library 'libavformat' for the
* format handling
......
......@@ -22,8 +22,11 @@
/**
* @file
* Libavformat API example: Output a media file in any supported
* libavformat format. The default codecs are used.
* libavformat API example.
*
* @example libavformat/output-example.c
* Output a media file in any supported libavformat format.
* The default codecs are used.
*/
#include <stdlib.h>
......
......@@ -532,6 +532,22 @@ static void reset_all_predictors(PredictorState *ps)
reset_predict_state(&ps[i]);
}
static int sample_rate_idx (int rate)
{
if (92017 <= rate) return 0;
else if (75132 <= rate) return 1;
else if (55426 <= rate) return 2;
else if (46009 <= rate) return 3;
else if (37566 <= rate) return 4;
else if (27713 <= rate) return 5;
else if (23004 <= rate) return 6;
else if (18783 <= rate) return 7;
else if (13856 <= rate) return 8;
else if (11502 <= rate) return 9;
else if (9391 <= rate) return 10;
else return 11;
}
static void reset_predictor_group(PredictorState *ps, int group_num)
{
int i;
......@@ -554,10 +570,33 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ac->m4ac.sample_rate = avctx->sample_rate;
if (avctx->extradata_size > 0) {
avctx->channels = 0;
avctx->frame_size = 0;
avctx->sample_rate = 0;
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
avctx->extradata,
avctx->extradata_size) < 0)
return -1;
} else {
int sr, i;
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
sr = sample_rate_idx(avctx->sample_rate);
ac->m4ac.sampling_index = sr;
ac->m4ac.channels = avctx->channels;
for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
if (ff_mpeg4audio_channels[i] == avctx->channels)
break;
if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
i = 0;
}
ac->m4ac.chan_config = i;
if (ac->m4ac.chan_config) {
set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config);
output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR);
}
}
if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
......@@ -2049,6 +2088,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
return -7;
} else if (ac->output_configured != OC_LOCKED) {
ac->m4ac.chan_config = 0;
ac->output_configured = OC_NONE;
}
if (ac->output_configured != OC_LOCKED) {
......@@ -2516,6 +2556,7 @@ AVCodec ff_aac_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
.capabilities = CODEC_CAP_CHANNEL_CONF,
.channel_layouts = aac_channel_layout,
};
......@@ -2536,5 +2577,6 @@ AVCodec ff_aac_latm_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
.capabilities = CODEC_CAP_CHANNEL_CONF,
.channel_layouts = aac_channel_layout,
};
......@@ -61,7 +61,7 @@ typedef struct AACEncContext {
int16_t *samples; ///< saved preprocessed input
int samplerate_index; ///< MPEG-4 samplerate index
uint8_t *chan_map; ///< channel configuration map
const uint8_t *chan_map; ///< channel configuration map
ChannelElement *cpe; ///< channel elements
FFPsyContext psy;
......
......@@ -1410,7 +1410,7 @@ typedef struct AVCodecContext {
* A demuxer should set this to what is stored in the field used to identify the codec.
* If there are multiple such fields in a container then the demuxer should choose the one
* which maximizes the information about the used codec.
* If the codec tag field in a container is larger then 32 bits then the demuxer should
* If the codec tag field in a container is larger than 32 bits then the demuxer should
* remap the longer ID to 32 bits with a table or other structure. Alternatively a new
* extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
* first.
......
......@@ -1316,7 +1316,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds
PutBitContext pb;
if ((unsigned)src_size > (unsigned)max_size) {
// av_log(NULL, AV_LOG_ERROR, "Input frame size larger then DCA_MAX_FRAME_SIZE!\n");
// av_log(NULL, AV_LOG_ERROR, "Input frame size larger than DCA_MAX_FRAME_SIZE!\n");
// return -1;
src_size = max_size;
}
......
......@@ -150,7 +150,7 @@ void clear_blocks_c(DCTELEM *blocks);
/* add and put pixel (decoding) */
// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4
//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4
typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
......@@ -183,7 +183,7 @@ static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
}
/* motion estimation */
// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2
// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2
// although currently h<4 is not used as functions with width <8 are neither used nor implemented
typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
......
......@@ -381,7 +381,7 @@ static inline int check_marker(GetBitContext *s, const char *msg)
/**
* init GetBitContext.
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits
* because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
* @param bit_size the size of the buffer in bits
*
......@@ -504,7 +504,7 @@ void free_vlc(VLC *vlc);
/**
* parses a vlc code, faster then get_vlc()
* parses a vlc code, faster than get_vlc()
* @param bits is the number of bits which will be read at once, must be
* identical to nb_bits in init_vlc()
* @param max_depth is the number of times bits bits must be read to completely
......
......@@ -1787,7 +1787,7 @@ static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int moti
static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
int i;
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop?
/* mpeg1 */
d->mb_skip_run= s->mb_skip_run;
......@@ -1816,7 +1816,7 @@ static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *
int i;
memcpy(d->mv, s->mv, 2*4*2*sizeof(int));
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster than a loop?
/* mpeg1 */
d->mb_skip_run= s->mb_skip_run;
......
......@@ -198,7 +198,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
/* Make sure the bitmap is not too large */
if (avctx->width < width || avctx->height < height) {
av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger then video.\n");
av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n");
return -1;
}
......
......@@ -404,7 +404,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr=NULL;
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
......
......@@ -2246,11 +2246,7 @@ int av_find_stream_info(AVFormatContext *ic)
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
st = ic->streams[i];
if (st->codec->codec_id == CODEC_ID_AAC) {
st->codec->sample_rate = 0;
st->codec->frame_size = 0;
st->codec->channels = 0;
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
/* if(!st->time_base.num)
......@@ -2268,13 +2264,6 @@ int av_find_stream_info(AVFormatContext *ic)
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
/* Force decoding of at least one frame of codec data
* this makes sure the codec initializes the channel configuration
* and does not trust the values from the container.
*/
if (codec && codec->capabilities & CODEC_CAP_CHANNEL_CONF)
st->codec->channels = 0;
/* Ensure that subtitle_header is properly set. */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
......@@ -2417,8 +2406,16 @@ int av_find_stream_info(AVFormatContext *ic)
/* if still no information, we try to open the codec and to
decompress the frame. We try to avoid that in most cases as
it takes longer and uses more memory. For MPEG-4, we need to
decompress for QuickTime. */
if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st))
decompress for QuickTime.
If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at
least one frame of codec data, this makes sure the codec initializes
the channel configuration and does not only trust the values from the container.
*/
if (!has_codec_parameters(st->codec) ||
!has_decode_delay_been_guessed(st) ||
(st->codec->codec &&
st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))
try_decode_frame(st, pkt);
st->codec_info_nb_frames++;
......
......@@ -26,24 +26,28 @@
#define BASE 65521L /* largest prime smaller than 65536 */
#define DO1(buf) {s1 += *buf++; s2 += s1;}
#define DO1(buf) { s1 += *buf++; s2 += s1; }
#define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf);
#define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf);
unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigned int len)
unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf,
unsigned int len)
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = adler >> 16;
while (len>0) {
while (len > 0) {
#if CONFIG_SMALL
while(len>4 && s2 < (1U<<31)){
DO4(buf); len-=4;
while (len > 4 && s2 < (1U << 31)) {
DO4(buf);
len -= 4;
}
#else
while(len>16 && s2 < (1U<<31)){
DO16(buf); len-=16;
#endif
while (len > 16 && s2 < (1U << 31)) {
DO16(buf);
len -= 16;
}
#endif
DO1(buf); len--;
s1 %= BASE;
s2 %= BASE;
......@@ -52,22 +56,32 @@ unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigne
}
#ifdef TEST
#include <string.h>
#include "log.h"
#include "timer.h"
#define LEN 7001
volatile int checksum;
int main(void){
int main(int argc, char **argv)
{
int i;
char data[LEN];
av_log_set_level(AV_LOG_DEBUG);
for(i=0; i<LEN; i++)
data[i]= ((i*i)>>3) + 123*i;
for(i=0; i<1000; i++){
START_TIMER
checksum= av_adler32_update(1, data, LEN);
STOP_TIMER("adler")
for (i = 0; i < LEN; i++)
data[i] = ((i * i) >> 3) + 123 * i;
if (argc > 1 && !strcmp(argv[1], "-t")) {
for (i = 0; i < 1000; i++) {
START_TIMER;
checksum = av_adler32_update(1, data, LEN);
STOP_TIMER("adler");
}
} else {
checksum = av_adler32_update(1, data, LEN);
}
av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum);
return 0;
av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum);
return checksum == 0x50e6e508 ? 0 : 1;
}
#endif
This diff is collapsed.
......@@ -44,32 +44,45 @@ int av_get_cpu_flags(void)
#undef printf
#include <stdio.h>
static const struct {
int flag;
const char *name;
} cpu_flag_tab[] = {
#if ARCH_ARM
{ AV_CPU_FLAG_IWMMXT, "iwmmxt" },
#elif ARCH_PPC
{ AV_CPU_FLAG_ALTIVEC, "altivec" },
#elif ARCH_X86
{ AV_CPU_FLAG_MMX, "mmx" },
{ AV_CPU_FLAG_MMX2, "mmx2" },
{ AV_CPU_FLAG_SSE, "sse" },
{ AV_CPU_FLAG_SSE2, "sse2" },
{ AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" },
{ AV_CPU_FLAG_SSE3, "sse3" },
{ AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" },
{ AV_CPU_FLAG_SSSE3, "ssse3" },
{ AV_CPU_FLAG_ATOM, "atom" },
{ AV_CPU_FLAG_SSE4, "sse4.1" },
{ AV_CPU_FLAG_SSE42, "sse4.2" },
{ AV_CPU_FLAG_AVX, "avx" },
{ AV_CPU_FLAG_3DNOW, "3dnow" },
{ AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
#endif
{ 0 }
};
int main(void)
{
int cpu_flags = av_get_cpu_flags();
int i;
printf("cpu_flags = 0x%08X\n", cpu_flags);
printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
#if ARCH_ARM
cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "",
#elif ARCH_PPC
cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "",
#elif ARCH_X86
cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "",
cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "",
cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "",
cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "",
cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "",
cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "",
cpu_flags & AV_CPU_FLAG_ATOM ? "Atom " : "",
cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "",
cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "",
cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "",
cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "",
cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : "");
#endif
printf("cpu_flags =");
for (i = 0; cpu_flag_tab[i].flag; i++)
if (cpu_flags & cpu_flag_tab[i].flag)
printf(" %s", cpu_flag_tab[i].name);
printf("\n");
return 0;
}
......
......@@ -603,14 +603,14 @@ typedef struct TestContext
#define TEST_FLAG_MU 04
static const AVOption test_options[]= {
{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, 0, 0, 100 },
{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, 0, 0, 1 },
{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, 0, 0, 10 },
{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, 0, 0, INT_MAX, 0, "flags" },
{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_COOL, INT_MIN, INT_MAX, 0, "flags" },
{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_LAME, INT_MIN, INT_MAX, 0, "flags" },
{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_MU, INT_MIN, INT_MAX, 0, "flags" },
{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, {0}, 0, 100 },
{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, {0}, 0, 1 },
{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, {0}, 0, 10 },
{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX },
{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" },
{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" },
{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" },
{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" },
{NULL},
};
......
......@@ -988,7 +988,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
const uint32_t *b = (const uint32_t *) _b;
#if CONFIG_SMALL
int sh = hasAlpha ? ((fmt == PIX_FMT_RGB32_1 || fmt == PIX_FMT_BGR32_1) ? 0 : 24) : 0;
int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
......
fulltest test: codectest lavftest lavfitest seektest
FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
codectest: fate-codec
lavftest: fate-lavf
lavfitest: fate-lavfi
seektest: fate-seek
AREF = fate-acodec-aref
VREF = fate-vsynth1-vref fate-vsynth2-vref
REFS = $(AREF) $(VREF)
......@@ -120,4 +113,4 @@ testclean:
-include $(wildcard tests/*.d)
.PHONY: fate* *test
.PHONY: fate*
......@@ -217,6 +217,20 @@ FATE_TESTS += fate-sha
fate-sha: libavutil/sha-test$(EXESUF)
fate-sha: CMD = run libavutil/sha-test
FATE_TESTS += fate-adler32
fate-adler32: libavutil/adler32-test$(EXESUF)
fate-adler32: CMD = run libavutil/adler32-test
fate-adler32: REF = /dev/null
FATE_TESTS += fate-aes
fate-aes: libavutil/aes-test$(EXESUF)
fate-aes: CMD = run libavutil/aes-test
fate-aes: REF = /dev/null
FATE_TESTS += fate-base64
fate-base64: libavutil/base64-test$(EXESUF)
fate-base64: CMD = run libavutil/base64-test
FATE_TESTS += fate-musepack7
fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc
fate-musepack7: CMP = oneoff
......
Encoding/decoding tests
Passed!
Passed!
Passed!
Passed!
Passed!
Passed!
Passed!
Passed!
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