diff --git a/Makefile b/Makefile index dd3a1f6f33..1d4e49459c 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,6 @@ PROGS-$(CONFIG_FFSERVER) += ffserver PROGS := $(PROGS-yes:%=%$(EXESUF)) PROGS_G = $(PROGS-yes:%=%_g$(EXESUF)) OBJS = $(PROGS-yes:%=%.o) cmdutils.o -TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher)) TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) @@ -82,14 +81,20 @@ ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS) %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS) +TOOLS = cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher +TOOLOBJS := $(TOOLS:%=tools/%.o) +TOOLS := $(TOOLS:%=tools/%$(EXESUF)) + alltools: $(TOOLS) tools/%$(EXESUF): tools/%.o $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) -tools/%.o: tools/%.c +$(TOOLOBJS): %.o: %.c | tools $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< +OBJDIRS += tools + -include $(wildcard tools/*.d) VERSION_SH = $(SRC_PATH)/version.sh @@ -150,5 +155,16 @@ check: test include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/tests/Makefile -.PHONY: all alltools *clean check config examples install* +$(sort $(OBJDIRS)): + $(Q)mkdir -p $@ + +# Dummy rule to stop make trying to rebuild removed or renamed headers +%.h: + @: + +# Disable suffix rules. Most of the builtin rules are suffix rules, +# so this saves some time on slow systems. +.SUFFIXES: + +.PHONY: all all-yes alltools *clean check config examples install* .PHONY: testprogs uninstall* diff --git a/common.mak b/common.mak index 9525dd44b6..989c79c1d1 100644 --- a/common.mak +++ b/common.mak @@ -91,6 +91,12 @@ $(HOSTOBJS): %.o: %.c $(HOSTPROGS): %$(HOSTEXESUF): %.o $(HOSTCC) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS) +$(OBJS): | $(dir $(OBJS)) +$(HOSTOBJS): | $(dir $(HOSTOBJS)) +$(TESTOBJS): | $(dir $(TESTOBJS)) + +OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS)) + CLEANSUFFIXES = *.d *.o *~ *.ho *.map *.ver DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp diff --git a/configure b/configure index 3092248f71..fd4b034da0 100755 --- a/configure +++ b/configure @@ -878,9 +878,9 @@ apply(){ } cp_if_changed(){ - cmp -s "$1" "$2" && - echo "$2 is unchanged" || - cp -f "$1" "$2" + cmp -s "$1" "$2" && echo "$2 is unchanged" && return + mkdir -p "$(dirname $2)" + cp -f "$1" "$2" } # CONFIG_LIST contains configurable options, while HAVE_LIST is for @@ -1098,7 +1098,6 @@ HAVE_LIST=" memalign mkstemp mmap - pld posix_memalign round roundf @@ -1708,10 +1707,8 @@ DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' # find source path if test -f configure; then source_path=. - disable source_path_used else source_path=$(cd $(dirname "$0"); pwd) - enable source_path_used echo "$source_path" | grep -q '[[:blank:]]' && die "Out of tree builds are impossible with whitespace in source path." test -e "$source_path/config.h" && @@ -2646,9 +2643,6 @@ EOF warn "Compiler does not indicate floating-point ABI, guessing $fpabi." fi - # We have to check if pld is a nop and disable it. - check_asm pld '"pld [r0]"' - enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"' enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"' enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"' @@ -3202,6 +3196,9 @@ echo "network support ${network-no}" echo "threading support ${thread_type-no}" echo "SDL support ${sdl-no}" echo "Sun medialib support ${mlib-no}" +echo "libdxva2 enabled ${dxva2-no}" +echo "libva enabled ${vaapi-no}" +echo "libvdpau enabled ${vdpau-no}" echo "AVISynth enabled ${avisynth-no}" echo "libcelt enabled ${libcelt-no}" echo "frei0r enabled ${frei0r-no}" @@ -3219,7 +3216,6 @@ echo "librtmp enabled ${librtmp-no}" echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libtheora enabled ${libtheora-no}" -echo "libva enabled ${vaapi-no}" echo "libvo-aacenc support ${libvo_aacenc-no}" echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" echo "libvorbis enabled ${libvorbis-no}" @@ -3254,31 +3250,7 @@ echo "License: $license" echo "Creating config.mak and config.h..." -# build tree in object directory if source path is different from current one -if enabled source_path_used; then - DIRS=" - doc - libavcodec - libavcodec/$arch - libavdevice - libavfilter - libavfilter/$arch - libavfilter/libmpcodecs - libavfilter/libmpcodecs/libvo - libavformat - libavutil - libavutil/$arch - libpostproc - libswscale - libswscale/$arch - tests - tests/fate - tools - " - - map 'mkdir -p $v' $DIRS; - $ln_s "$source_path/Makefile" . -fi +test -e Makefile || $ln_s "$source_path/Makefile" . enabled stripping || strip="echo skipping strip" @@ -3466,6 +3438,7 @@ version=$3 libs=$4 requires=$5 enabled ${name#lib} || return 0 +mkdir -p $name cat < $name/$name.pc prefix=$prefix exec_prefix=\${prefix} diff --git a/doc/Makefile b/doc/Makefile index da46cce647..01960b74b0 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -24,6 +24,9 @@ doc/%.1: TAG = MAN doc/%.1: doc/%.pod $(M)pod2man --section=1 --center=" " --release=" " $< > $@ +$(DOCS): | doc +OBJDIRS += doc + install-progs-$(CONFIG_DOC): install-man install-man: $(MANPAGES) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 4eba5dd83c..b61af18056 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -346,7 +346,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce float cost_stay_here, cost_get_here; float rd = 0.0f; for (w = 0; w < group_len; w++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(win+w)*16+swb]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb]; rd += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, sce->sf_idx[(win+w)*16+swb], cb, @@ -626,7 +626,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, qmin = INT_MAX; qmax = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; continue; @@ -655,7 +655,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, float dist = 0; int cb = find_min_book(maxval, sce->sf_idx[w*16+g]); for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], q + q0, cb, lambda / band->threshold, INFINITY, NULL); } @@ -728,7 +728,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, int nz = 0; float uplim = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; uplim += band->threshold; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; @@ -1028,7 +1028,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { - FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; if (band->energy <= band->threshold) { sce->sf_idx[(w+w2)*16+g] = 218; sce->zeroes[(w+w2)*16+g] = 1; @@ -1066,8 +1066,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { float dist1 = 0.0f, dist2 = 0.0f; for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { - FFPsyBand *band0 = &s->psy.psy_bands[(s->cur_channel+0)*PSY_MAX_BANDS+(w+w2)*16+g]; - FFPsyBand *band1 = &s->psy.psy_bands[(s->cur_channel+1)*PSY_MAX_BANDS+(w+w2)*16+g]; + FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; + FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g]; float minthr = FFMIN(band0->threshold, band1->threshold); float maxthr = FFMAX(band0->threshold, band1->threshold); for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 2a6dbc8ebd..b877e4eaef 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -219,7 +219,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) sizes[1] = swb_size_128[i]; lengths[0] = ff_aac_num_swb_1024[i]; lengths[1] = ff_aac_num_swb_128[i]; - ff_psy_init(&s->psy, avctx, 2, sizes, lengths); + ff_psy_init(&s->psy, avctx, 2, sizes, lengths, s->chan_map[0], &s->chan_map[1]); s->psypp = ff_psy_preprocess_init(avctx); s->coder = &ff_aac_coders[2]; @@ -373,7 +373,7 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else - cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2; + cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2; } } @@ -582,14 +582,17 @@ static int aac_encode_frame(AVCodecContext *avctx, memset(chan_el_counter, 0, sizeof(chan_el_counter)); for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; + const float *coeffs[2]; tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); + for (ch = 0; ch < chans; ch++) + coeffs[ch] = cpe->ch[ch].coeffs; + s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); for (ch = 0; ch < chans; ch++) { - s->cur_channel = start_ch + ch; - s->psy.model->analyze(&s->psy, s->cur_channel, cpe->ch[ch].coeffs, &wi[ch]); + s->cur_channel = start_ch * 2 + ch; s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); } cpe->common_window = 0; @@ -605,7 +608,7 @@ static int aac_encode_frame(AVCodecContext *avctx, } } } - s->cur_channel = start_ch; + s->cur_channel = start_ch * 2; if (s->options.stereo_mode && cpe->common_window) { if (s->options.stereo_mode > 0) { IndividualChannelStream *ics = &cpe->ch[0].ics; diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index f2b525694b..4152b70bbf 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -557,8 +557,8 @@ static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr, /** * Calculate band thresholds as suggested in 3GPP TS26.403 */ -static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, - const float *coefs, const FFPsyWindowInfo *wi) +static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel, + const float *coefs, const FFPsyWindowInfo *wi) { AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data; AacPsyChannel *pch = &pctx->ch[channel]; @@ -627,7 +627,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, } /* 5.6.1.3.2 "Calculation of the desired perceptual entropy" */ - ctx->pe[channel] = pe; + ctx->ch[channel].entropy = pe; desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8); desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits); /* NOTE: PE correction is kept simple. During initial testing it had very @@ -731,7 +731,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, for (w = 0; w < wi->num_windows*16; w += 16) { for (g = 0; g < num_bands; g++) { AacPsyBand *band = &pch->band[w+g]; - FFPsyBand *psy_band = &ctx->psy_bands[channel*PSY_MAX_BANDS+w+g]; + FFPsyBand *psy_band = &ctx->ch[channel].psy_bands[w+g]; psy_band->threshold = band->thr; psy_band->energy = band->energy; @@ -741,6 +741,16 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, memcpy(pch->prev_band, pch->band, sizeof(pch->band)); } +static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, + const float **coeffs, const FFPsyWindowInfo *wi) +{ + int ch; + FFPsyChannelGroup *group = ff_psy_find_group(ctx, channel); + + for (ch = 0; ch < group->num_ch; ch++) + psy_3gpp_analyze_channel(ctx, channel + ch, coeffs[ch], &wi[ch]); +} + static av_cold void psy_3gpp_end(FFPsyContext *apc) { AacPsyContext *pctx = (AacPsyContext*) apc->model_priv_data; diff --git a/libavcodec/arm/dsputil_arm.S b/libavcodec/arm/dsputil_arm.S index c614206bac..1247b0fa84 100644 --- a/libavcodec/arm/dsputil_arm.S +++ b/libavcodec/arm/dsputil_arm.S @@ -24,11 +24,6 @@ preserve8 -#if !HAVE_PLD -.macro pld reg -.endm -#endif - #if HAVE_ARMV5TE function ff_prefetch_arm, export=1 subs r2, r2, #1 @@ -37,6 +32,8 @@ function ff_prefetch_arm, export=1 bne ff_prefetch_arm bx lr endfunc +#else +#define pld @ #endif .macro ALIGN_QWORD_D shift, Rd0, Rd1, Rd2, Rd3, Rn0, Rn1, Rn2, Rn3, Rn4 diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 133a85f5c1..faadb1b870 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -25,16 +25,31 @@ extern const FFPsyModel ff_aac_psy_model; -av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, - int num_lens, - const uint8_t **bands, const int* num_bands) +av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, + const uint8_t **bands, const int* num_bands, + int num_groups, const uint8_t *group_map) { + int i, j, k = 0; + ctx->avctx = avctx; - ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels); + ctx->ch = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2); + ctx->group = av_mallocz(sizeof(ctx->group[0]) * num_groups); ctx->bands = av_malloc (sizeof(ctx->bands[0]) * num_lens); ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens); memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens); memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens); + + /* assign channels to groups (with virtual channels for coupling) */ + for (i = 0; i < num_groups; i++) { + /* NOTE: Add 1 to handle the AAC chan_config without modification. + * This has the side effect of allowing an array of 0s to map + * to one channel per group. + */ + ctx->group[i].num_ch = group_map[i] + 1; + for (j = 0; j < ctx->group[i].num_ch * 2; j++) + ctx->group[i].ch[j] = &ctx->ch[k++]; + } + switch (ctx->avctx->codec_id) { case CODEC_ID_AAC: ctx->model = &ff_aac_psy_model; @@ -45,13 +60,24 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, return 0; } +FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel) +{ + int i = 0, ch = 0; + + while (ch <= channel) + ch += ctx->group[i++].num_ch; + + return &ctx->group[i-1]; +} + av_cold void ff_psy_end(FFPsyContext *ctx) { if (ctx->model->end) ctx->model->end(ctx); av_freep(&ctx->bands); av_freep(&ctx->num_bands); - av_freep(&ctx->psy_bands); + av_freep(&ctx->group); + av_freep(&ctx->ch); } typedef struct FFPsyPreprocessContext{ diff --git a/libavcodec/psymodel.h b/libavcodec/psymodel.h index c65614a151..a7b7948cd2 100644 --- a/libavcodec/psymodel.h +++ b/libavcodec/psymodel.h @@ -40,6 +40,23 @@ typedef struct FFPsyBand { float perceptual_weight; } FFPsyBand; +/** + * single channel psychoacoustic information + */ +typedef struct FFPsyChannel { + FFPsyBand psy_bands[PSY_MAX_BANDS]; ///< channel bands information + float entropy; ///< total PE for this channel +} FFPsyChannel; + +/** + * psychoacoustic information for an arbitrary group of channels + */ +typedef struct FFPsyChannelGroup { + FFPsyChannel *ch[PSY_MAX_CHANS]; ///< pointers to the individual channels in the group + uint8_t num_ch; ///< number of channels in this group + uint8_t coupling[PSY_MAX_BANDS]; ///< allow coupling for this band in the group +} FFPsyChannelGroup; + /** * windowing related information */ @@ -58,14 +75,14 @@ typedef struct FFPsyContext { AVCodecContext *avctx; ///< encoder context const struct FFPsyModel *model; ///< encoder-specific model functions - FFPsyBand *psy_bands; ///< frame bands information + FFPsyChannel *ch; ///< single channel information + FFPsyChannelGroup *group; ///< channel group information + int num_groups; ///< number of channel groups uint8_t **bands; ///< scalefactor band sizes for possible frame sizes int *num_bands; ///< number of scalefactor bands for possible frame sizes int num_lens; ///< number of scalefactor band sets - float pe[PSY_MAX_CHANS]; ///< total PE for each channel in the frame - struct { int size; ///< size of the bitresevoir in bits int bits; ///< number of bits used in the bitresevoir @@ -95,14 +112,14 @@ typedef struct FFPsyModel { FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type); /** - * Perform psychoacoustic analysis and set band info (threshold, energy). + * Perform psychoacoustic analysis and set band info (threshold, energy) for a group of channels. * - * @param ctx model context - * @param channel audio channel number - * @param coeffs pointer to the transformed coefficients - * @param wi window information + * @param ctx model context + * @param channel channel number of the first channel in the group to perform analysis on + * @param coeffs array of pointers to the transformed coefficients + * @param wi window information for the channels in the group */ - void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi); + void (*analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi); void (*end) (FFPsyContext *apc); } FFPsyModel; @@ -115,12 +132,24 @@ typedef struct FFPsyModel { * @param num_lens number of possible frame lengths * @param bands scalefactor band lengths for all frame lengths * @param num_bands number of scalefactor bands for all frame lengths + * @param num_groups number of channel groups + * @param group_map array with # of channels in group - 1, for each group * * @return zero if successful, a negative value if not */ -av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, - int num_lens, - const uint8_t **bands, const int* num_bands); +av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, + const uint8_t **bands, const int* num_bands, + int num_groups, const uint8_t *group_map); + +/** + * Determine what group a channel belongs to. + * + * @param ctx psymodel context + * @param channel channel to locate the group for + * + * @return pointer to the FFPsyChannelGroup this channel belongs to + */ +FFPsyChannelGroup *ff_psy_find_group(FFPsyContext *ctx, int channel); /** * Cleanup model context at the end. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index fd011cfa19..bc08e350cf 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -141,6 +141,10 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV422P10BE: + case PIX_FMT_YUV444P9LE: + case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV444P10LE: + case PIX_FMT_YUV444P10BE: w_align= 16; //FIXME check for non mpeg style codecs and use less alignment h_align= 16; if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 6e951bac18..61fcec2472 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1681,7 +1681,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); - return res; + return AVERROR_INVALIDDATA; } st = track->stream; if (st->discard >= AVDISCARD_ALL) @@ -1918,7 +1918,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; - for (i=0; inb_elem; i++) + for (i=0; inb_elem && !res; i++) if (blocks[i].bin.size > 0 && blocks[i].bin.data) { int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; res=matroska_parse_block(matroska, @@ -1935,14 +1935,15 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; + int ret = 0; - while (matroska_deliver_packet(matroska, pkt)) { + while (!ret && matroska_deliver_packet(matroska, pkt)) { if (matroska->done) return AVERROR_EOF; - matroska_parse_cluster(matroska); + ret = matroska_parse_cluster(matroska); } - return 0; + return ret; } static int matroska_read_seek(AVFormatContext *s, int stream_index, diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 08de280c0e..9722d62101 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -240,7 +240,8 @@ static int ogg_read_page(AVFormatContext *s, int *str) for (n = 0; n < ogg->nstreams; n++) { av_freep(&ogg->streams[n].buf); - av_freep(&ogg->streams[n].private); + if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private) + av_freep(&ogg->streams[n].private); } ogg->curidx = -1; ogg->nstreams = 0; diff --git a/libavformat/utils.c b/libavformat/utils.c index e0a5455d75..4d8b9225fb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2345,7 +2345,10 @@ int av_find_stream_info(AVFormatContext *ic) /* NOTE: a new stream can be added there if no header in file (AVFMTCTX_NOHEADER) */ ret = av_read_frame_internal(ic, &pkt1); - if (ret < 0 && ret != AVERROR(EAGAIN)) { + if (ret == AVERROR(EAGAIN)) + continue; + + if (ret < 0) { /* EOF or error */ ret = -1; /* we could not have all the codec parameters before EOF */ for(i=0;inb_streams;i++) { @@ -2361,9 +2364,6 @@ int av_find_stream_info(AVFormatContext *ic) break; } - if (ret == AVERROR(EAGAIN)) - continue; - pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end); if ((ret = av_dup_packet(pkt)) < 0) goto find_stream_info_err; diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 0f170d2094..bac7b45a60 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -143,13 +143,12 @@ enum PixelFormat { PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - + PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libavutil/rational.c b/libavutil/rational.c index 701f06717e..b1bd655158 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -135,7 +135,8 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) } #ifdef TEST -main(){ +int main(void) +{ AVRational a,b; for(a.num=-2; a.num<=2; a.num++){ for(a.den=-2; a.den<=2; a.den++){ @@ -151,5 +152,6 @@ main(){ } } } + return 0; } #endif diff --git a/tests/Makefile b/tests/Makefile index 87ec0256de..38d85fbab7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -46,6 +46,8 @@ include $(SRC_PATH)/tests/fate2.mak include $(SRC_PATH)/tests/fate/aac.mak include $(SRC_PATH)/tests/fate/als.mak +include $(SRC_PATH)/tests/fate/amrnb.mak +include $(SRC_PATH)/tests/fate/amrwb.mak include $(SRC_PATH)/tests/fate/fft.mak include $(SRC_PATH)/tests/fate/h264.mak include $(SRC_PATH)/tests/fate/mp3.mak diff --git a/tests/fate/amrnb.mak b/tests/fate/amrnb.mak new file mode 100644 index 0000000000..e633fec65b --- /dev/null +++ b/tests/fate/amrnb.mak @@ -0,0 +1,47 @@ +FATE_TESTS += fate-amrnb-4k75 +fate-amrnb-4k75: CMD = pcm -i $(SAMPLES)/amrnb/4.75k.amr +fate-amrnb-4k75: CMP = stddev +fate-amrnb-4k75: REF = $(SAMPLES)/amrnb/4.75k.pcm +fate-amrnb-4k75: FUZZ = 1 + +FATE_TESTS += fate-amrnb-5k15 +fate-amrnb-5k15: CMD = pcm -i $(SAMPLES)/amrnb/5.15k.amr +fate-amrnb-5k15: CMP = stddev +fate-amrnb-5k15: REF = $(SAMPLES)/amrnb/5.15k.pcm +fate-amrnb-5k15: FUZZ = 1 + +FATE_TESTS += fate-amrnb-5k9 +fate-amrnb-5k9: CMD = pcm -i $(SAMPLES)/amrnb/5.9k.amr +fate-amrnb-5k9: CMP = stddev +fate-amrnb-5k9: REF = $(SAMPLES)/amrnb/5.9k.pcm +fate-amrnb-5k9: FUZZ = 1 + +FATE_TESTS += fate-amrnb-6k7 +fate-amrnb-6k7: CMD = pcm -i $(SAMPLES)/amrnb/6.7k.amr +fate-amrnb-6k7: CMP = stddev +fate-amrnb-6k7: REF = $(SAMPLES)/amrnb/6.7k.pcm +fate-amrnb-6k7: FUZZ = 1 + +FATE_TESTS += fate-amrnb-7k4 +fate-amrnb-7k4: CMD = pcm -i $(SAMPLES)/amrnb/7.4k.amr +fate-amrnb-7k4: CMP = stddev +fate-amrnb-7k4: REF = $(SAMPLES)/amrnb/7.4k.pcm +fate-amrnb-7k4: FUZZ = 1 + +FATE_TESTS += fate-amrnb-7k95 +fate-amrnb-7k95: CMD = pcm -i $(SAMPLES)/amrnb/7.95k.amr +fate-amrnb-7k95: CMP = stddev +fate-amrnb-7k95: REF = $(SAMPLES)/amrnb/7.95k.pcm +fate-amrnb-7k95: FUZZ = 1 + +FATE_TESTS += fate-amrnb-10k2 +fate-amrnb-10k2: CMD = pcm -i $(SAMPLES)/amrnb/10.2k.amr +fate-amrnb-10k2: CMP = stddev +fate-amrnb-10k2: REF = $(SAMPLES)/amrnb/10.2k.pcm +fate-amrnb-10k2: FUZZ = 1 + +FATE_TESTS += fate-amrnb-12k2 +fate-amrnb-12k2: CMD = pcm -i $(SAMPLES)/amrnb/12.2k.amr +fate-amrnb-12k2: CMP = stddev +fate-amrnb-12k2: REF = $(SAMPLES)/amrnb/12.2k.pcm +fate-amrnb-12k2: FUZZ = 1 diff --git a/tests/fate/amrwb.mak b/tests/fate/amrwb.mak new file mode 100644 index 0000000000..d3931c7ccb --- /dev/null +++ b/tests/fate/amrwb.mak @@ -0,0 +1,59 @@ +FATE_TESTS += fate-amrwb-6k60 +fate-amrwb-6k60: CMD = pcm -i $(SAMPLES)/amrwb/seed-6k60.awb +fate-amrwb-6k60: CMP = stddev +fate-amrwb-6k60: REF = $(SAMPLES)/amrwb/seed-6k60.pcm +fate-amrwb-6k60: FUZZ = 1 + +FATE_TESTS += fate-amrwb-8k85 +fate-amrwb-8k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-8k85.awb +fate-amrwb-8k85: CMP = stddev +fate-amrwb-8k85: REF = $(SAMPLES)/amrwb/seed-8k85.pcm +fate-amrwb-8k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-12k65 +fate-amrwb-12k65: CMD = pcm -i $(SAMPLES)/amrwb/seed-12k65.awb +fate-amrwb-12k65: CMP = stddev +fate-amrwb-12k65: REF = $(SAMPLES)/amrwb/seed-12k65.pcm +fate-amrwb-12k65: FUZZ = 1 + +FATE_TESTS += fate-amrwb-14k25 +fate-amrwb-14k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-14k25.awb +fate-amrwb-14k25: CMP = stddev +fate-amrwb-14k25: REF = $(SAMPLES)/amrwb/seed-14k25.pcm +fate-amrwb-14k25: FUZZ = 2.6 + +FATE_TESTS += fate-amrwb-15k85 +fate-amrwb-15k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-15k85.awb +fate-amrwb-15k85: CMP = stddev +fate-amrwb-15k85: REF = $(SAMPLES)/amrwb/seed-15k85.pcm +fate-amrwb-15k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-18k25 +fate-amrwb-18k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-18k25.awb +fate-amrwb-18k25: CMP = stddev +fate-amrwb-18k25: REF = $(SAMPLES)/amrwb/seed-18k25.pcm +fate-amrwb-18k25: FUZZ = 1 + +FATE_TESTS += fate-amrwb-19k85 +fate-amrwb-19k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-19k85.awb +fate-amrwb-19k85: CMP = stddev +fate-amrwb-19k85: REF = $(SAMPLES)/amrwb/seed-19k85.pcm +fate-amrwb-19k85: FUZZ = 1 + +FATE_TESTS += fate-amrwb-23k05 +fate-amrwb-23k05: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k05.awb +fate-amrwb-23k05: CMP = stddev +fate-amrwb-23k05: REF = $(SAMPLES)/amrwb/seed-23k05.pcm +fate-amrwb-23k05: FUZZ = 2 + +FATE_TESTS += fate-amrwb-23k85 +fate-amrwb-23k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k85.awb +fate-amrwb-23k85: CMP = stddev +fate-amrwb-23k85: REF = $(SAMPLES)/amrwb/seed-23k85.pcm +fate-amrwb-23k85: FUZZ = 2 + +FATE_TESTS += fate-amrwb-23k85-2 +fate-amrwb-23k85-2: CMD = pcm -i $(SAMPLES)/amrwb/deus-23k85.awb +fate-amrwb-23k85-2: CMP = stddev +fate-amrwb-23k85-2: REF = $(SAMPLES)/amrwb/deus-23k85.pcm +fate-amrwb-23k85-2: FUZZ = 1 diff --git a/tests/fate2.mak b/tests/fate2.mak index 066f9ef583..b45efdd552 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -222,111 +222,3 @@ fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc fate-musepack7: CMP = oneoff fate-musepack7: REF = $(SAMPLES)/musepack/inside-mp7.pcm fate-musepack7: FUZZ = 1 - -FATE_TESTS += fate-amrnb-4k75 -fate-amrnb-4k75: CMD = pcm -i $(SAMPLES)/amrnb/4.75k.amr -fate-amrnb-4k75: CMP = stddev -fate-amrnb-4k75: REF = $(SAMPLES)/amrnb/4.75k.pcm -fate-amrnb-4k75: FUZZ = 1 - -FATE_TESTS += fate-amrnb-5k15 -fate-amrnb-5k15: CMD = pcm -i $(SAMPLES)/amrnb/5.15k.amr -fate-amrnb-5k15: CMP = stddev -fate-amrnb-5k15: REF = $(SAMPLES)/amrnb/5.15k.pcm -fate-amrnb-5k15: FUZZ = 1 - -FATE_TESTS += fate-amrnb-5k9 -fate-amrnb-5k9: CMD = pcm -i $(SAMPLES)/amrnb/5.9k.amr -fate-amrnb-5k9: CMP = stddev -fate-amrnb-5k9: REF = $(SAMPLES)/amrnb/5.9k.pcm -fate-amrnb-5k9: FUZZ = 1 - -FATE_TESTS += fate-amrnb-6k7 -fate-amrnb-6k7: CMD = pcm -i $(SAMPLES)/amrnb/6.7k.amr -fate-amrnb-6k7: CMP = stddev -fate-amrnb-6k7: REF = $(SAMPLES)/amrnb/6.7k.pcm -fate-amrnb-6k7: FUZZ = 1 - -FATE_TESTS += fate-amrnb-7k4 -fate-amrnb-7k4: CMD = pcm -i $(SAMPLES)/amrnb/7.4k.amr -fate-amrnb-7k4: CMP = stddev -fate-amrnb-7k4: REF = $(SAMPLES)/amrnb/7.4k.pcm -fate-amrnb-7k4: FUZZ = 1 - -FATE_TESTS += fate-amrnb-7k95 -fate-amrnb-7k95: CMD = pcm -i $(SAMPLES)/amrnb/7.95k.amr -fate-amrnb-7k95: CMP = stddev -fate-amrnb-7k95: REF = $(SAMPLES)/amrnb/7.95k.pcm -fate-amrnb-7k95: FUZZ = 1 - -FATE_TESTS += fate-amrnb-10k2 -fate-amrnb-10k2: CMD = pcm -i $(SAMPLES)/amrnb/10.2k.amr -fate-amrnb-10k2: CMP = stddev -fate-amrnb-10k2: REF = $(SAMPLES)/amrnb/10.2k.pcm -fate-amrnb-10k2: FUZZ = 1 - -FATE_TESTS += fate-amrnb-12k2 -fate-amrnb-12k2: CMD = pcm -i $(SAMPLES)/amrnb/12.2k.amr -fate-amrnb-12k2: CMP = stddev -fate-amrnb-12k2: REF = $(SAMPLES)/amrnb/12.2k.pcm -fate-amrnb-12k2: FUZZ = 1 - -FATE_TESTS += fate-amrwb-6k60 -fate-amrwb-6k60: CMD = pcm -i $(SAMPLES)/amrwb/seed-6k60.awb -fate-amrwb-6k60: CMP = stddev -fate-amrwb-6k60: REF = $(SAMPLES)/amrwb/seed-6k60.pcm -fate-amrwb-6k60: FUZZ = 1 - -FATE_TESTS += fate-amrwb-8k85 -fate-amrwb-8k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-8k85.awb -fate-amrwb-8k85: CMP = stddev -fate-amrwb-8k85: REF = $(SAMPLES)/amrwb/seed-8k85.pcm -fate-amrwb-8k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-12k65 -fate-amrwb-12k65: CMD = pcm -i $(SAMPLES)/amrwb/seed-12k65.awb -fate-amrwb-12k65: CMP = stddev -fate-amrwb-12k65: REF = $(SAMPLES)/amrwb/seed-12k65.pcm -fate-amrwb-12k65: FUZZ = 1 - -FATE_TESTS += fate-amrwb-14k25 -fate-amrwb-14k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-14k25.awb -fate-amrwb-14k25: CMP = stddev -fate-amrwb-14k25: REF = $(SAMPLES)/amrwb/seed-14k25.pcm -fate-amrwb-14k25: FUZZ = 2.6 - -FATE_TESTS += fate-amrwb-15k85 -fate-amrwb-15k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-15k85.awb -fate-amrwb-15k85: CMP = stddev -fate-amrwb-15k85: REF = $(SAMPLES)/amrwb/seed-15k85.pcm -fate-amrwb-15k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-18k25 -fate-amrwb-18k25: CMD = pcm -i $(SAMPLES)/amrwb/seed-18k25.awb -fate-amrwb-18k25: CMP = stddev -fate-amrwb-18k25: REF = $(SAMPLES)/amrwb/seed-18k25.pcm -fate-amrwb-18k25: FUZZ = 1 - -FATE_TESTS += fate-amrwb-19k85 -fate-amrwb-19k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-19k85.awb -fate-amrwb-19k85: CMP = stddev -fate-amrwb-19k85: REF = $(SAMPLES)/amrwb/seed-19k85.pcm -fate-amrwb-19k85: FUZZ = 1 - -FATE_TESTS += fate-amrwb-23k05 -fate-amrwb-23k05: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k05.awb -fate-amrwb-23k05: CMP = stddev -fate-amrwb-23k05: REF = $(SAMPLES)/amrwb/seed-23k05.pcm -fate-amrwb-23k05: FUZZ = 2 - -FATE_TESTS += fate-amrwb-23k85 -fate-amrwb-23k85: CMD = pcm -i $(SAMPLES)/amrwb/seed-23k85.awb -fate-amrwb-23k85: CMP = stddev -fate-amrwb-23k85: REF = $(SAMPLES)/amrwb/seed-23k85.pcm -fate-amrwb-23k85: FUZZ = 2 - -FATE_TESTS += fate-amrwb-23k85-2 -fate-amrwb-23k85-2: CMD = pcm -i $(SAMPLES)/amrwb/deus-23k85.awb -fate-amrwb-23k85-2: CMP = stddev -fate-amrwb-23k85-2: REF = $(SAMPLES)/amrwb/deus-23k85.pcm -fate-amrwb-23k85-2: FUZZ = 1