From 30223b3bf2ab1c55499d3d52a244221d24fcc784 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 07:25:56 +0200 Subject: [PATCH 01/15] lavc: deprecate the audio resampling API. It has been superseded by lavr. --- libavcodec/avcodec.h | 10 ++++++++++ libavcodec/resample.c | 4 ++++ libavcodec/resample2.c | 4 ++++ libavcodec/version.h | 3 +++ 4 files changed, 21 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 59fff22194..8e37b8373e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -4022,9 +4022,11 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, * @} */ +#if FF_API_AVCODEC_RESAMPLE /** * @defgroup lavc_resample Audio resampling * @ingroup libavc + * @deprecated use libavresample instead * * @{ */ @@ -4049,6 +4051,7 @@ typedef struct ReSampleContext ReSampleContext; * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate * @return allocated ReSampleContext, NULL if error occurred */ +attribute_deprecated ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate, enum AVSampleFormat sample_fmt_out, @@ -4056,6 +4059,7 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int filter_length, int log2_phase_count, int linear, double cutoff); +attribute_deprecated int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); /** @@ -4064,6 +4068,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl * @param s a non-NULL pointer to a resample context previously * created with av_audio_resample_init() */ +attribute_deprecated void audio_resample_close(ReSampleContext *s); @@ -4076,6 +4081,7 @@ void audio_resample_close(ReSampleContext *s); between the 2 closest, if 0 the closest will be used * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate */ +attribute_deprecated struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); /** @@ -4087,6 +4093,7 @@ struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. * @return the number of samples written in dst or -1 if an error occurred */ +attribute_deprecated int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); @@ -4102,12 +4109,15 @@ int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consum * note, due to rounding the actual compensation might be slightly different, * especially if the compensation_distance is large and the in_rate used during init is small */ +attribute_deprecated void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); +attribute_deprecated void av_resample_close(struct AVResampleContext *c); /** * @} */ +#endif /** * @addtogroup lavc_picture diff --git a/libavcodec/resample.c b/libavcodec/resample.c index ca6a84da6e..20d7078113 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -32,6 +32,8 @@ #include "libavutil/mem.h" #include "libavutil/samplefmt.h" +#if FF_API_AVCODEC_RESAMPLE + #define MAX_CHANNELS 8 struct AVResampleContext; @@ -373,3 +375,5 @@ void audio_resample_close(ReSampleContext *s) av_audio_convert_free(s->convert_ctx[1]); av_free(s); } + +#endif diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c index 79e6279ff0..c6e5c48c1b 100644 --- a/libavcodec/resample2.c +++ b/libavcodec/resample2.c @@ -29,6 +29,8 @@ #include "dsputil.h" #include "libavutil/common.h" +#if FF_API_AVCODEC_RESAMPLE + #ifndef CONFIG_RESAMPLE_HP #define FILTER_SHIFT 15 @@ -319,3 +321,5 @@ av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->comp return dst_index; } + +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 3125db708d..5b2d7b99f7 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -82,5 +82,8 @@ #ifndef FF_API_VDA_ASYNC #define FF_API_VDA_ASYNC (LIBAVCODEC_VERSION_MAJOR < 55) #endif +#ifndef FF_API_AVCODEC_RESAMPLE +#define FF_API_AVCODEC_RESAMPLE (LIBAVCODEC_VERSION_MAJOR < 55) +#endif #endif /* AVCODEC_VERSION_H */ From e7ba5b1de063e9b1de441b0d1c5708857f739fa5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 06:56:00 +0200 Subject: [PATCH 02/15] lavr: change the type of the data buffers to uint8_t**. This is more consistent with what the rest of Libav does. This breaks API. --- avplay.c | 4 ++-- libavfilter/af_asyncts.c | 8 ++++---- libavfilter/af_resample.c | 6 +++--- libavresample/audio_data.c | 2 +- libavresample/audio_data.h | 2 +- libavresample/avresample-test.c | 4 ++-- libavresample/avresample.h | 6 +++--- libavresample/utils.c | 8 ++++---- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/avplay.c b/avplay.c index ead79f3c08..b1f2598451 100644 --- a/avplay.c +++ b/avplay.c @@ -1961,9 +1961,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) is->audio_buf1 = tmp_out; out_samples = avresample_convert(is->avr, - (void **)&is->audio_buf1, + &is->audio_buf1, out_linesize, nb_samples, - (void **)is->frame->data, + is->frame->data, is->frame->linesize[0], is->frame->nb_samples); if (out_samples < 0) { diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c index 0b8be8d557..c7eb86dd77 100644 --- a/libavfilter/af_asyncts.c +++ b/libavfilter/af_asyncts.c @@ -133,7 +133,7 @@ static int request_frame(AVFilterLink *link) nb_samples); if (!buf) return AVERROR(ENOMEM); - ret = avresample_convert(s->avr, (void**)buf->extended_data, + ret = avresample_convert(s->avr, buf->extended_data, buf->linesize[0], nb_samples, NULL, 0, 0); if (ret <= 0) { avfilter_unref_bufferp(&buf); @@ -149,7 +149,7 @@ static int request_frame(AVFilterLink *link) static int write_to_fifo(ASyncContext *s, AVFilterBufferRef *buf) { - int ret = avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data, + int ret = avresample_convert(s->avr, NULL, 0, 0, buf->extended_data, buf->linesize[0], buf->audio->nb_samples); avfilter_unref_buffer(buf); return ret; @@ -210,7 +210,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) goto fail; } - avresample_read(s->avr, (void**)buf_out->extended_data, out_size); + avresample_read(s->avr, buf_out->extended_data, out_size); buf_out->pts = s->pts; if (delta > 0) { @@ -230,7 +230,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) avresample_read(s->avr, NULL, avresample_available(s->avr)); s->pts = pts - avresample_get_delay(s->avr); - ret = avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data, + ret = avresample_convert(s->avr, NULL, 0, 0, buf->extended_data, buf->linesize[0], buf->audio->nb_samples); fail: diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index eb2d2f9e21..c51f9d243b 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -149,7 +149,7 @@ static int request_frame(AVFilterLink *outlink) if (!buf) return AVERROR(ENOMEM); - ret = avresample_convert(s->avr, (void**)buf->extended_data, + ret = avresample_convert(s->avr, buf->extended_data, buf->linesize[0], nb_samples, NULL, 0, 0); if (ret <= 0) { @@ -186,9 +186,9 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) goto fail; } - ret = avresample_convert(s->avr, (void**)buf_out->extended_data, + ret = avresample_convert(s->avr, buf_out->extended_data, buf_out->linesize[0], nb_samples, - (void**)buf->extended_data, buf->linesize[0], + buf->extended_data, buf->linesize[0], buf->audio->nb_samples); if (ret < 0) { avfilter_unref_buffer(buf_out); diff --git a/libavresample/audio_data.c b/libavresample/audio_data.c index d624ad3796..199a68cb11 100644 --- a/libavresample/audio_data.c +++ b/libavresample/audio_data.c @@ -62,7 +62,7 @@ int ff_audio_data_set_channels(AudioData *a, int channels) return 0; } -int ff_audio_data_init(AudioData *a, void **src, int plane_size, int channels, +int ff_audio_data_init(AudioData *a, uint8_t **src, int plane_size, int channels, int nb_samples, enum AVSampleFormat sample_fmt, int read_only, const char *name) { diff --git a/libavresample/audio_data.h b/libavresample/audio_data.h index 4609ebc284..558e7e67ec 100644 --- a/libavresample/audio_data.h +++ b/libavresample/audio_data.h @@ -73,7 +73,7 @@ int ff_audio_data_set_channels(AudioData *a, int channels); * @param name name for debug logging (can be NULL) * @return 0 on success, negative AVERROR value on error */ -int ff_audio_data_init(AudioData *a, void **src, int plane_size, int channels, +int ff_audio_data_init(AudioData *a, uint8_t **src, int plane_size, int channels, int nb_samples, enum AVSampleFormat sample_fmt, int read_only, const char *name); diff --git a/libavresample/avresample-test.c b/libavresample/avresample-test.c index 0d4f2df37c..ab49e489cd 100644 --- a/libavresample/avresample-test.c +++ b/libavresample/avresample-test.c @@ -305,8 +305,8 @@ int main(int argc, char **argv) goto end; } - ret = avresample_convert(s, (void **)out_data, out_linesize, out_rate * 6, - (void **) in_data, in_linesize, in_rate * 6); + ret = avresample_convert(s, out_data, out_linesize, out_rate * 6, + in_data, in_linesize, in_rate * 6); if (ret < 0) { char errbuf[256]; av_strerror(ret, errbuf, sizeof(errbuf)); diff --git a/libavresample/avresample.h b/libavresample/avresample.h index b93aba5d73..ea93952e2e 100644 --- a/libavresample/avresample.h +++ b/libavresample/avresample.h @@ -234,8 +234,8 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, * not including converted samples added to the internal * output FIFO */ -int avresample_convert(AVAudioResampleContext *avr, void **output, - int out_plane_size, int out_samples, void **input, +int avresample_convert(AVAudioResampleContext *avr, uint8_t **output, + int out_plane_size, int out_samples, uint8_t **input, int in_plane_size, int in_samples); /** @@ -287,6 +287,6 @@ int avresample_available(AVAudioResampleContext *avr); * @param nb_samples number of samples to read from the FIFO * @return the number of samples written to output */ -int avresample_read(AVAudioResampleContext *avr, void **output, int nb_samples); +int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples); #endif /* AVRESAMPLE_AVRESAMPLE_H */ diff --git a/libavresample/utils.c b/libavresample/utils.c index 4819b57977..378dd483db 100644 --- a/libavresample/utils.c +++ b/libavresample/utils.c @@ -247,8 +247,8 @@ static int handle_buffered_output(AVAudioResampleContext *avr, } int attribute_align_arg avresample_convert(AVAudioResampleContext *avr, - void **output, int out_plane_size, - int out_samples, void **input, + uint8_t **output, int out_plane_size, + int out_samples, uint8_t **input, int in_plane_size, int in_samples) { AudioData input_buffer; @@ -410,11 +410,11 @@ int avresample_available(AVAudioResampleContext *avr) return av_audio_fifo_size(avr->out_fifo); } -int avresample_read(AVAudioResampleContext *avr, void **output, int nb_samples) +int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples) { if (!output) return av_audio_fifo_drain(avr->out_fifo, nb_samples); - return av_audio_fifo_read(avr->out_fifo, output, nb_samples); + return av_audio_fifo_read(avr->out_fifo, (void**)output, nb_samples); } unsigned avresample_version(void) From 006afc7a0b439b9c34982754403a5faefd0f0388 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 06:59:22 +0200 Subject: [PATCH 03/15] lavr: bump major to 1 and declare it stable. --- doc/APIchanges | 5 +++++ libavresample/version.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4558ca7583..314622d5a4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,11 @@ libavutil: 2011-04-18 API changes, most recent first: +2012-10-xx - xxxxxxx - lavr 1.0.0 - avresample.h + Data planes parameters to avresample_convert() and + avresample_read() are now uint8_t** instead of void**. + Libavresample is now stable. + 2012-09-23 - xxxxxxx - lavc 54.28.0 - avcodec.h Add avcodec_free_frame(). This function must now be used for freeing an AVFrame. diff --git a/libavresample/version.h b/libavresample/version.h index c4741e420e..53ba802d85 100644 --- a/libavresample/version.h +++ b/libavresample/version.h @@ -19,9 +19,9 @@ #ifndef AVRESAMPLE_VERSION_H #define AVRESAMPLE_VERSION_H -#define LIBAVRESAMPLE_VERSION_MAJOR 0 +#define LIBAVRESAMPLE_VERSION_MAJOR 1 #define LIBAVRESAMPLE_VERSION_MINOR 0 -#define LIBAVRESAMPLE_VERSION_MICRO 3 +#define LIBAVRESAMPLE_VERSION_MICRO 0 #define LIBAVRESAMPLE_VERSION_INT AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR, \ LIBAVRESAMPLE_VERSION_MINOR, \ From 2f49e3da3320e49edb40713af503af0db5b3bba6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 14:01:39 +0200 Subject: [PATCH 04/15] doc/APIchanges: fill in missing dates and hashes. --- doc/APIchanges | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 314622d5a4..75c3c5268c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,23 +13,23 @@ libavutil: 2011-04-18 API changes, most recent first: -2012-10-xx - xxxxxxx - lavr 1.0.0 - avresample.h +2012-10-05 - e7ba5b1 - lavr 1.0.0 - avresample.h Data planes parameters to avresample_convert() and avresample_read() are now uint8_t** instead of void**. Libavresample is now stable. -2012-09-23 - xxxxxxx - lavc 54.28.0 - avcodec.h +2012-09-24 - a42aada - lavc 54.28.0 - avcodec.h Add avcodec_free_frame(). This function must now be used for freeing an AVFrame. -2012-09-12 - xxxxxxx - lavu 51.41.0 - audioconvert.h +2012-09-12 - 8919fee - lavu 51.41.0 - audioconvert.h Added AV_CH_LOW_FREQUENCY_2 channel mask value. -2012-09-04 - xxxxxxx - lavu 51.40.0 - opt.h +2012-09-04 - 686a329 - lavu 51.40.0 - opt.h Reordered the fields in default_val in AVOption, changed which default_val field is used for which AVOptionType. -2012-xx-xx - xxxxxxx - lavc 54.26.1 - avcodec.h +2012-08-30 - a231832 - lavc 54.26.1 - avcodec.h Add codec descriptor properties AV_CODEC_PROP_LOSSY and AV_CODEC_PROP_LOSSLESS. From 978d5bd2a7d803ed5ebfe29600811555db4f632b Mon Sep 17 00:00:00 2001 From: Dmitry Samonenko Date: Fri, 5 Oct 2012 00:36:16 +0400 Subject: [PATCH 05/15] libspeexenc: Add an option for enabling DTX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discontinuous transmission is an addition to VAD/VBR operation, that allows to greatly reduce bitrate for silent chunks or stationary noises. Signed-off-by: Martin Storsjö --- libavcodec/libspeexenc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 43f84dc5f4..5a5079b43c 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -85,6 +85,7 @@ typedef struct { int cbr_quality; ///< CBR quality 0 to 10 int abr; ///< flag to enable ABR int vad; ///< flag to enable VAD + int dtx; ///< flag to enable DTX int pkt_frame_count; ///< frame count for the current packet AudioFrameQueue afq; ///< frame queue } LibSpeexEncContext; @@ -120,6 +121,7 @@ static av_cold void print_enc_params(AVCodecContext *avctx, av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n", avctx->frame_size * s->frames_per_packet); av_log(avctx, AV_LOG_DEBUG, "voice activity detection: %d\n", s->vad); + av_log(avctx, AV_LOG_DEBUG, "discontinuous transmission: %d\n", s->dtx); } static av_cold int encode_init(AVCodecContext *avctx) @@ -196,6 +198,13 @@ static av_cold int encode_init(AVCodecContext *avctx) if (s->vad) speex_encoder_ctl(s->enc_state, SPEEX_SET_VAD, &s->vad); + /* Activiting Discontinuous Transmission */ + if (s->dtx) { + speex_encoder_ctl(s->enc_state, SPEEX_SET_DTX, &s->dtx); + if (!(s->abr || s->vad || s->header.vbr)) + av_log(avctx, AV_LOG_WARNING, "DTX is not much of use without ABR, VAD or VBR\n"); + } + /* set encoding complexity */ if (avctx->compression_level > FF_COMPRESSION_DEFAULT) { complexity = av_clip(avctx->compression_level, 0, 10); @@ -318,6 +327,7 @@ static const AVOption options[] = { { "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { .i64 = 8 }, 0, 10, AE }, { "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 8, AE }, { "vad", "Voice Activity Detection", OFFSET(vad), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE }, + { "dtx", "Discontinuous Transmission", OFFSET(dtx), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE }, { NULL }, }; From f1c6a740fcb9ea0a977855bb708c0541149fa9cf Mon Sep 17 00:00:00 2001 From: Dmitry Samonenko Date: Fri, 5 Oct 2012 00:42:31 +0400 Subject: [PATCH 06/15] libspeexenc: Updated commentary to reflect recent changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/libspeexenc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 5a5079b43c..cbfa5be92b 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -62,6 +62,23 @@ * sometimes desirable to use multiple frames-per-packet to reduce the * amount of container overhead. This can be done by setting the * 'frames_per_packet' option to a value 1 to 8. + * + * + * Optional features + * Speex encoder supports several optional features, which can be useful + * for some conditions. + * + * Voice Activity Detection + * When enabled, voice activity detection detects whether the audio + * being encoded is speech or silence/background noise. VAD is always + * implicitly activated when encoding in VBR, so the option is only useful + * in non-VBR operation. In this case, Speex detects non-speech periods and + * encodes them with just enough bits to reproduce the background noise. + * + * Discontinuous Transmission (DTX) + * DTX is an addition to VAD/VBR operation, that allows to stop transmitting + * completely when the background noise is stationary. + * In file-based operation only 5 bits are used for such frames. */ #include From bcf07a15a0aea23d2aa3eb71ea6ec7b3d21892ac Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 3 Oct 2012 22:53:00 +0100 Subject: [PATCH 07/15] x86: dsputil: kill VLA in gmc_mmx() Instead of using an evil VLA, fall back to C version when edge emulation is needed. MPEG4 GMC is a rarely used fringe feature so the speed loss is an acceptable cost for safer code. Signed-off-by: Mans Rullgard --- libavcodec/x86/dsputil_mmx.c | 58 +++++------------------------------- 1 file changed, 7 insertions(+), 51 deletions(-) diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 121e7114c7..86a08cb06c 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1909,15 +1909,10 @@ static av_noinline void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src, #if HAVE_INLINE_ASM -typedef void emulated_edge_mc_func(uint8_t *dst, const uint8_t *src, - int linesize, int block_w, int block_h, - int src_x, int src_y, int w, int h); - -static av_always_inline void gmc(uint8_t *dst, uint8_t *src, - int stride, int h, int ox, int oy, - int dxx, int dxy, int dyx, int dyy, - int shift, int r, int width, int height, - emulated_edge_mc_func *emu_edge_fn) +static void gmc_mmx(uint8_t *dst, uint8_t *src, + int stride, int h, int ox, int oy, + int dxx, int dxy, int dyx, int dyy, + int shift, int r, int width, int height) { const int w = 8; const int ix = ox >> (16 + shift); @@ -1932,7 +1927,6 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src, const uint16_t dxy4[4] = { dxys, dxys, dxys, dxys }; const uint16_t dyy4[4] = { dyys, dyys, dyys, dyys }; const uint64_t shift2 = 2 * shift; - uint8_t edge_buf[(h + 1) * stride]; int x, y; const int dxw = (dxx - (1 << (16 + shift))) * (w - 1); @@ -1943,7 +1937,9 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src, ((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) | (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift) // uses more than 16 bits of subpel mv (only at huge resolution) - || (dxx | dxy | dyx | dyy) & 15) { + || (dxx | dxy | dyx | dyy) & 15 || + (unsigned)ix >= width - w || + (unsigned)iy >= height - h) { // FIXME could still use mmx for some of the rows ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, width, height); @@ -1951,11 +1947,6 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src, } src += ix + iy * stride; - if ((unsigned)ix >= width - w || - (unsigned)iy >= height - h) { - emu_edge_fn(edge_buf, src, stride, w + 1, h + 1, ix, iy, width, height); - src = edge_buf; - } __asm__ volatile ( "movd %0, %%mm6 \n\t" @@ -2034,36 +2025,6 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src, } } -#if HAVE_YASM -#if ARCH_X86_32 -static void gmc_mmx(uint8_t *dst, uint8_t *src, - int stride, int h, int ox, int oy, - int dxx, int dxy, int dyx, int dyy, - int shift, int r, int width, int height) -{ - gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, - width, height, &emulated_edge_mc_mmx); -} -#endif -static void gmc_sse(uint8_t *dst, uint8_t *src, - int stride, int h, int ox, int oy, - int dxx, int dxy, int dyx, int dyy, - int shift, int r, int width, int height) -{ - gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, - width, height, &emulated_edge_mc_sse); -} -#else -static void gmc_mmx(uint8_t *dst, uint8_t *src, - int stride, int h, int ox, int oy, - int dxx, int dxy, int dyx, int dyy, - int shift, int r, int width, int height) -{ - gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, - width, height, &ff_emulated_edge_mc_8); -} -#endif - #define PREFETCH(name, op) \ static void name(void *mem, int stride, int h) \ { \ @@ -2469,9 +2430,7 @@ static void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx, int mm_flags) } } -#if ARCH_X86_32 || !HAVE_YASM c->gmc = gmc_mmx; -#endif c->add_bytes = add_bytes_mmx; @@ -2729,9 +2688,6 @@ static void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, int mm_flags) if (!high_bit_depth) c->emulated_edge_mc = emulated_edge_mc_sse; -#if HAVE_INLINE_ASM - c->gmc = gmc_sse; -#endif #endif /* HAVE_YASM */ } From 642b4efaf7b3055ab4b26bda252149eb35babc4b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 4 Oct 2012 01:26:50 +0100 Subject: [PATCH 08/15] ppc: fmtconvert: kill VLA in float_to_int16_interleave_altivec() Signed-off-by: Mans Rullgard --- libavcodec/ppc/fmtconvert_altivec.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c index db2c25800b..129891ad9b 100644 --- a/libavcodec/ppc/fmtconvert_altivec.c +++ b/libavcodec/ppc/fmtconvert_altivec.c @@ -83,6 +83,22 @@ static void float_to_int16_altivec(int16_t *dst, const float *src, long len) } } +static void float_to_int16_stride_altivec(int16_t *dst, const float *src, + long len, int stride) +{ + int i, j; + vector signed short d, s; + + for (i = 0; i < len - 7; i += 8) { + d = float_to_int16_one_altivec(src + i); + for (j = 0; j < 8; j++) { + s = vec_splat(d, j); + vec_ste(s, 0, dst); + dst += stride; + } + } +} + static void float_to_int16_interleave_altivec(int16_t *dst, const float **src, long len, int channels) { @@ -124,13 +140,8 @@ static void float_to_int16_interleave_altivec(int16_t *dst, const float **src, } } } else { - DECLARE_ALIGNED(16, int16_t, tmp)[len]; - int c, j; - for (c = 0; c < channels; c++) { - float_to_int16_altivec(tmp, src[c], len); - for (i = 0, j = c; i < len; i++, j+=channels) - dst[j] = tmp[i]; - } + for (i = 0; i < channels; i++) + float_to_int16_stride_altivec(dst + i, src[i], len, channels); } } } From 07eb7e20af63a244d9e1813626fac38a84e8c869 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 4 Oct 2012 17:30:34 +0100 Subject: [PATCH 09/15] ppc: swscale: rework yuv2planeX_altivec() This gets rid of the variable-length scratch buffer by filtering 16 pixels at a time and writing directly to the destination. The extra loads this requires to load the source values are compensated by not doing a round-trip to memory before shifting. Signed-off-by: Mans Rullgard --- libswscale/ppc/swscale_altivec.c | 166 +++++++++++++------------------ 1 file changed, 70 insertions(+), 96 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 0e66ec1f7b..7616ddf1fa 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -32,78 +32,37 @@ #define vzero vec_splat_s32(0) -static inline void altivec_packIntArrayToCharArray(int *val, uint8_t *dest, - int dstW) -{ - register int i; - vector unsigned int altivec_vectorShiftInt19 = - vec_add(vec_splat_u32(10), vec_splat_u32(9)); - if ((uintptr_t)dest % 16) { - /* badly aligned store, we force store alignment */ - /* and will handle load misalignment on val w/ vec_perm */ - vector unsigned char perm1; - vector signed int v1; - for (i = 0; (i < dstW) && - (((uintptr_t)dest + i) % 16); i++) { - int t = val[i] >> 19; - dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); - } - perm1 = vec_lvsl(i << 2, val); - v1 = vec_ld(i << 2, val); - for (; i < (dstW - 15); i += 16) { - int offset = i << 2; - vector signed int v2 = vec_ld(offset + 16, val); - vector signed int v3 = vec_ld(offset + 32, val); - vector signed int v4 = vec_ld(offset + 48, val); - vector signed int v5 = vec_ld(offset + 64, val); - vector signed int v12 = vec_perm(v1, v2, perm1); - vector signed int v23 = vec_perm(v2, v3, perm1); - vector signed int v34 = vec_perm(v3, v4, perm1); - vector signed int v45 = vec_perm(v4, v5, perm1); +#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do { \ + vector signed short l2 = vec_ld(((x) << 1) + 16, src); \ + vector signed short ls = vec_perm(l1, l2, perm); \ + vector signed int i1 = vec_mule(filter, ls); \ + vector signed int i2 = vec_mulo(filter, ls); \ + vector signed int vf1 = vec_mergeh(i1, i2); \ + vector signed int vf2 = vec_mergel(i1, i2); \ + d1 = vec_add(d1, vf1); \ + d2 = vec_add(d2, vf2); \ + l1 = l2; \ + } while (0) - vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); - vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); - vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19); - vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19); - vector unsigned short vs1 = vec_packsu(vA, vB); - vector unsigned short vs2 = vec_packsu(vC, vD); - vector unsigned char vf = vec_packsu(vs1, vs2); - vec_st(vf, i, dest); - v1 = v5; - } - } else { // dest is properly aligned, great - for (i = 0; i < (dstW - 15); i += 16) { - int offset = i << 2; - vector signed int v1 = vec_ld(offset, val); - vector signed int v2 = vec_ld(offset + 16, val); - vector signed int v3 = vec_ld(offset + 32, val); - vector signed int v4 = vec_ld(offset + 48, val); - vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19); - vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19); - vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19); - vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19); - vector unsigned short vs1 = vec_packsu(v5, v6); - vector unsigned short vs2 = vec_packsu(v7, v8); - vector unsigned char vf = vec_packsu(vs1, vs2); - vec_st(vf, i, dest); - } - } - for (; i < dstW; i++) { - int t = val[i] >> 19; - dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); - } -} - -// FIXME remove the usage of scratch buffers. -static void yuv2planeX_altivec(const int16_t *filter, int filterSize, - const int16_t **src, uint8_t *dest, int dstW, - const uint8_t *dither, int offset) +static void yuv2planeX_16_altivec(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, + const uint8_t *dither, int offset, int x) { register int i, j; - DECLARE_ALIGNED(16, int, val)[dstW]; + DECLARE_ALIGNED(16, int, val)[16]; + vector signed int vo1, vo2, vo3, vo4; + vector unsigned short vs1, vs2; + vector unsigned char vf; + vector unsigned int altivec_vectorShiftInt19 = + vec_add(vec_splat_u32(10), vec_splat_u32(9)); - for (i = 0; i < dstW; i++) - val[i] = dither[(i + offset) & 7] << 12; + for (i = 0; i < 16; i++) + val[i] = dither[(x + i + offset) & 7] << 12; + + vo1 = vec_ld(0, val); + vo2 = vec_ld(16, val); + vo3 = vec_ld(32, val); + vo4 = vec_ld(48, val); for (j = 0; j < filterSize; j++) { vector signed short l1, vLumFilter = vec_ld(j << 1, filter); @@ -111,36 +70,51 @@ static void yuv2planeX_altivec(const int16_t *filter, int filterSize, vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0); vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter - perm = vec_lvsl(0, src[j]); - l1 = vec_ld(0, src[j]); + perm = vec_lvsl(x << 1, src[j]); + l1 = vec_ld(x << 1, src[j]); - for (i = 0; i < (dstW - 7); i += 8) { - int offset = i << 2; - vector signed short l2 = vec_ld((i << 1) + 16, src[j]); - - vector signed int v1 = vec_ld(offset, val); - vector signed int v2 = vec_ld(offset + 16, val); - - vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7] - - vector signed int i1 = vec_mule(vLumFilter, ls); - vector signed int i2 = vec_mulo(vLumFilter, ls); - - vector signed int vf1 = vec_mergeh(i1, i2); - vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j] - - vector signed int vo1 = vec_add(v1, vf1); - vector signed int vo2 = vec_add(v2, vf2); - - vec_st(vo1, offset, val); - vec_st(vo2, offset + 16, val); - - l1 = l2; - } - for (; i < dstW; i++) - val[i] += src[j][i] * filter[j]; + yuv2planeX_8(vo1, vo2, l1, src[j], x, perm, vLumFilter); + yuv2planeX_8(vo3, vo4, l1, src[j], x + 8, perm, vLumFilter); } - altivec_packIntArrayToCharArray(val, dest, dstW); + + vo1 = vec_sra(vo1, altivec_vectorShiftInt19); + vo2 = vec_sra(vo2, altivec_vectorShiftInt19); + vo3 = vec_sra(vo3, altivec_vectorShiftInt19); + vo4 = vec_sra(vo4, altivec_vectorShiftInt19); + vs1 = vec_packsu(vo1, vo2); + vs2 = vec_packsu(vo3, vo4); + vf = vec_packsu(vs1, vs2); + vec_st(vf, 0, dest); +} + +static inline void yuv2planeX_u(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset, int x) +{ + int i, j; + + for (i = x; i < dstW; i++) { + int t = dither[(i + offset) & 7] << 12; + for (j = 0; j < filterSize; j++) + t += src[j][i] * filter[j]; + dest[i] = av_clip_uint8(t >> 19); + } +} + +static void yuv2planeX_altivec(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + int dst_u = -(uintptr_t)dest & 15; + int i; + + yuv2planeX_u(filter, filterSize, src, dest, dst_u, dither, offset, 0); + + for (i = dst_u; i < dstW - 15; i += 16) + yuv2planeX_16_altivec(filter, filterSize, src, dest + i, dither, + offset, i); + + yuv2planeX_u(filter, filterSize, src, dest, dstW, dither, offset, i); } static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, From c07d56a684372e5001eb6ab927708082f1df9c21 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 3 Oct 2012 23:00:44 +0100 Subject: [PATCH 10/15] build: error on variable-length arrays With all the VLAs gone, make sure they never come back. Signed-off-by: Mans Rullgard --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index cd72f36376..34680d4784 100755 --- a/configure +++ b/configure @@ -3504,6 +3504,7 @@ elif enabled gcc; then check_cflags -Werror=implicit-function-declaration check_cflags -Werror=missing-prototypes check_cflags -Werror=declaration-after-statement + check_cflags -Werror=vla elif enabled llvm_gcc; then check_cflags -mllvm -stack-alignment=16 elif enabled clang; then From ba04177eeb690ba4e93ec30fc8eb02f5319f844b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 14:45:30 +0200 Subject: [PATCH 11/15] vf_pad/scale: use double precision for aspect ratios. Fixes Bug 203. CC:libav-stable@libav.org --- libavfilter/vf_pad.c | 2 +- libavfilter/vf_scale.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 2291b138fb..8adab3bb8b 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -160,7 +160,7 @@ static int config_input(AVFilterLink *inlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_A] = (double) inlink->w / inlink->h; var_values[VAR_HSUB] = 1<hsub; var_values[VAR_VSUB] = 1<vsub; diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 949691f797..4941e8dd4c 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -167,9 +167,9 @@ static int config_props(AVFilterLink *outlink) var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; - var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_DAR] = var_values[VAR_A] = (double) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? - (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; + (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; var_values[VAR_HSUB] = 1<format].log2_chroma_w; var_values[VAR_VSUB] = 1<format].log2_chroma_h; From c010fce6c91f80245c6d38f6281ffb054b379f45 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 5 Oct 2012 23:33:02 +0200 Subject: [PATCH 12/15] parseutils-test: Drop random colors from parsing test This guarantees stable output for comparing test results. --- libavutil/parseutils.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 3149537f6a..0ca179ea80 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -693,8 +693,6 @@ int main(void) int i; uint8_t rgba[4]; const char *color_names[] = { - "bikeshed", - "RaNdOm", "foo", "red", "Red ", From 76f644d9f7f511a4e8dbc4938d40c43b49383c22 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 5 Oct 2012 23:34:52 +0200 Subject: [PATCH 13/15] fate: Add parseutils test --- tests/fate/libavutil.mak | 4 ++++ tests/ref/fate/parseutils | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/ref/fate/parseutils diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 1052b1d239..afb0a2c98b 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -37,6 +37,10 @@ FATE_LIBAVUTIL += fate-md5 fate-md5: libavutil/md5-test$(EXESUF) fate-md5: CMD = run libavutil/md5-test +FATE_LIBAVUTIL += fate-parseutils +fate-parseutils: libavutil/parseutils-test$(EXESUF) +fate-parseutils: CMD = run libavutil/parseutils-test + FATE_LIBAVUTIL += fate-sha fate-sha: libavutil/sha-test$(EXESUF) fate-sha: CMD = run libavutil/sha-test diff --git a/tests/ref/fate/parseutils b/tests/ref/fate/parseutils new file mode 100644 index 0000000000..896c14d60d --- /dev/null +++ b/tests/ref/fate/parseutils @@ -0,0 +1,45 @@ +Testing av_parse_video_rate() +'-inf' -> -1/0 ret:-22 +'inf' -> 1/0 ret:-22 +'nan' -> 0/0 ret:-22 +'123/0' -> 1/0 ret:-22 +'-123 / 0' -> -1/0 ret:-22 +'' -> 0/0 ret:-22 +'/' -> 0/0 ret:-22 +' 123 / 321' -> 41/107 ret:0 +'foo/foo' -> 0/0 ret:-22 +'foo/1' -> 0/0 ret:-22 +'1/foo' -> 0/0 ret:-22 +'0/0' -> 0/0 ret:-22 +'/0' -> 0/0 ret:-22 +'1/' -> 0/0 ret:-22 +'1' -> 1/1 ret:0 +'0' -> 0/1 ret:-22 +'-123/123' -> -1/1 ret:-22 +'-foo' -> 0/0 ret:-22 +'123.23' -> 12323/100 ret:0 +'.23' -> 23/100 ret:0 +'-.23' -> -23/100 ret:-22 +'-0.234' -> -117/500 ret:-22 +'-0.0000001' -> 0/1 ret:-22 +' 21332.2324 ' -> 917286/43 ret:0 +' -21332.2324 ' -> -917286/43 ret:-22 + +Testing av_parse_color() +red -> R(255) G(0) B(0) A(255) +RED -> R(255) G(0) B(0) A(255) +Violet -> R(238) G(130) B(238) A(255) +Yellow -> R(255) G(255) B(0) A(255) +Red -> R(255) G(0) B(0) A(255) +0x000000 -> R(0) G(0) B(0) A(255) +0xff000000 -> R(255) G(0) B(0) A(0) +0x3e34ff -> R(62) G(52) B(255) A(255) +0x3e34ffaa -> R(62) G(52) B(255) A(170) +#ff0000 -> R(255) G(0) B(0) A(255) +ff0000 -> R(255) G(0) B(0) A(255) +0xff0000@1.0 -> R(255) G(0) B(0) A(255) +red@0xf -> R(255) G(0) B(0) A(15) +red@0.1 -> R(255) G(0) B(0) A(25) +red@0.5 -> R(255) G(0) B(0) A(127) +red@1.0 -> R(255) G(0) B(0) A(255) +red@-0.0 -> R(255) G(0) B(0) A(0) From e4cbf7529ba4bcfff47c44b0d026ecb356004c8c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 27 Sep 2012 10:19:53 +0200 Subject: [PATCH 14/15] Give all anonymously typedeffed structs in headers a name Anonymous structs cannot be forward declared and have no benefit. --- cmdutils.h | 4 ++-- libavcodec/aac.h | 22 +++++++++++----------- libavcodec/aacadtsdec.h | 2 +- libavcodec/aacps.h | 2 +- libavcodec/ac3.h | 2 +- libavcodec/ac3dec.h | 2 +- libavcodec/acelp_vectors.h | 2 +- libavcodec/adx.h | 4 ++-- libavcodec/amrnbdata.h | 4 ++-- libavcodec/amrwbdata.h | 4 ++-- libavcodec/bytestream.h | 4 ++-- libavcodec/cavs.h | 2 +- libavcodec/dirac.h | 2 +- libavcodec/dnxhddata.h | 2 +- libavcodec/dnxhdenc.h | 4 ++-- libavcodec/dwt.h | 2 +- libavcodec/g722.h | 2 +- libavcodec/gsmdec_data.h | 2 +- libavcodec/huffman.h | 2 +- libavcodec/indeo3data.h | 2 +- libavcodec/intrax8.h | 2 +- libavcodec/ivi_common.h | 16 ++++++++-------- libavcodec/libschroedinger.h | 2 +- libavcodec/mlp.h | 4 ++-- libavcodec/mpc.h | 4 ++-- libavcodec/mpeg4audio.h | 2 +- libavcodec/proresdsp.h | 2 +- libavcodec/qcelpdata.h | 4 ++-- libavcodec/ra144.h | 2 +- libavcodec/roqvideo.h | 6 +++--- libavcodec/rtjpeg.h | 2 +- libavcodec/sbr.h | 6 +++--- libavcodec/vorbis.h | 2 +- libavcodec/vp56.h | 10 +++++----- libavcodec/vp56data.h | 2 +- libavcodec/vp8.h | 8 ++++---- libavcodec/w32pthreads.h | 6 +++--- libavcodec/x86/dsputil_mmx.h | 2 +- libavdevice/alsa-audio.h | 2 +- libavdevice/sndio_common.h | 2 +- libavfilter/gradfun.h | 2 +- libavfilter/yadif.h | 2 +- libavformat/asf.h | 6 +++--- libavformat/audiointerleave.h | 2 +- libavformat/httpauth.h | 4 ++-- libavformat/isom.h | 14 +++++++------- libavformat/mms.h | 4 ++-- libavformat/movenc.h | 4 ++-- libavformat/mpegts.h | 4 ++-- libavformat/mxf.h | 4 ++-- libavformat/nut.h | 12 ++++++------ libavformat/rtpdec.h | 2 +- libavformat/swf.h | 2 +- libavutil/dict.h | 2 +- libavutil/lfg.h | 2 +- libswscale/swscale.h | 4 ++-- 56 files changed, 114 insertions(+), 114 deletions(-) diff --git a/cmdutils.h b/cmdutils.h index 7dc9e8f14f..3cf34ffae3 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -121,7 +121,7 @@ typedef struct SpecifierOpt { } u; } SpecifierOpt; -typedef struct { +typedef struct OptionDef { const char *name; int flags; #define HAS_ARG 0x0001 @@ -356,7 +356,7 @@ int read_yesno(void); */ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size); -typedef struct { +typedef struct PtsCorrectionContext { int64_t num_faulty_pts; /// Number of incorrect PTS values so far int64_t num_faulty_dts; /// Number of incorrect DTS values so far int64_t last_pts; /// PTS of the last frame diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 45aacd1071..32baf9d0c5 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -113,7 +113,7 @@ enum OCStatus { OC_LOCKED, ///< Output configuration locked in place }; -typedef struct { +typedef struct OutputConfiguration { MPEG4AudioConfig m4ac; uint8_t layout_map[MAX_ELEM_ID*4][3]; int layout_map_tags; @@ -125,7 +125,7 @@ typedef struct { /** * Predictor State */ -typedef struct { +typedef struct PredictorState { float cor0; float cor1; float var0; @@ -146,7 +146,7 @@ typedef struct { /** * Long Term Prediction */ -typedef struct { +typedef struct LongTermPrediction { int8_t present; int16_t lag; float coef; @@ -156,7 +156,7 @@ typedef struct { /** * Individual Channel Stream */ -typedef struct { +typedef struct IndividualChannelStream { uint8_t max_sfb; ///< number of scalefactor bands per group enum WindowSequence window_sequence[2]; uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sinus window. @@ -177,7 +177,7 @@ typedef struct { /** * Temporal Noise Shaping */ -typedef struct { +typedef struct TemporalNoiseShaping { int present; int n_filt[8]; int length[8][4]; @@ -189,7 +189,7 @@ typedef struct { /** * Dynamic Range Control - decoded from the bitstream but not processed further. */ -typedef struct { +typedef struct DynamicRangeControl { int pce_instance_tag; ///< Indicates with which program the DRC info is associated. int dyn_rng_sgn[17]; ///< DRC sign information; 0 - positive, 1 - negative int dyn_rng_ctl[17]; ///< DRC magnitude information @@ -202,7 +202,7 @@ typedef struct { */ } DynamicRangeControl; -typedef struct { +typedef struct Pulse { int num_pulse; int start; int pos[4]; @@ -212,7 +212,7 @@ typedef struct { /** * coupling parameters */ -typedef struct { +typedef struct ChannelCoupling { enum CouplingPoint coupling_point; ///< The point during decoding at which coupling is applied. int num_coupled; ///< number of target elements enum RawDataBlockType type[8]; ///< Type of channel element to be coupled - SCE or CPE. @@ -226,7 +226,7 @@ typedef struct { /** * Single Channel Element - used for both SCE and LFE elements. */ -typedef struct { +typedef struct SingleChannelElement { IndividualChannelStream ics; TemporalNoiseShaping tns; Pulse pulse; @@ -245,7 +245,7 @@ typedef struct { /** * channel element - generic struct for SCE/CPE/CCE/LFE */ -typedef struct { +typedef struct ChannelElement { // CPE specific int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream. int ms_mode; ///< Signals mid/side stereo flags coding mode (used by encoder) @@ -260,7 +260,7 @@ typedef struct { /** * main AAC context */ -typedef struct { +typedef struct AACContext { AVCodecContext *avctx; AVFrame frame; diff --git a/libavcodec/aacadtsdec.h b/libavcodec/aacadtsdec.h index 60fdd221a2..6319efcea3 100644 --- a/libavcodec/aacadtsdec.h +++ b/libavcodec/aacadtsdec.h @@ -28,7 +28,7 @@ #define AAC_ADTS_HEADER_SIZE 7 -typedef struct { +typedef struct AACADTSHeaderInfo { uint32_t sample_rate; uint32_t samples; uint32_t bit_rate; diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h index 6cdac249f9..e8a195ab2b 100644 --- a/libavcodec/aacps.h +++ b/libavcodec/aacps.h @@ -38,7 +38,7 @@ #define PS_AP_LINKS 3 #define PS_MAX_AP_DELAY 5 -typedef struct { +typedef struct PSContext { int start; int enable_iid; int iid_quant; diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index 304c86c181..647432f02e 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -91,7 +91,7 @@ typedef struct AC3BitAllocParameters { * @struct AC3HeaderInfo * Coded AC-3 header values up to the lfeon element, plus derived values. */ -typedef struct { +typedef struct AC3HeaderInfo { /** @name Coded elements * @{ */ diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index a2625a6023..eabfd29e76 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -65,7 +65,7 @@ /** Large enough for maximum possible frame size when the specification limit is ignored */ #define AC3_FRAME_BUFFER_SIZE 32768 -typedef struct { +typedef struct AC3DecodeContext { AVClass *class; ///< class for AVOptions AVCodecContext *avctx; ///< parent context AVFrame frame; ///< AVFrame for decoded output diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h index 2c5d319e45..d6226bf020 100644 --- a/libavcodec/acelp_vectors.h +++ b/libavcodec/acelp_vectors.h @@ -26,7 +26,7 @@ #include /** Sparse representation for the algebraic codebook (fixed) vector */ -typedef struct { +typedef struct AMRFixed { int n; int x[10]; float y[10]; diff --git a/libavcodec/adx.h b/libavcodec/adx.h index 92abe5f163..47d9f24a85 100644 --- a/libavcodec/adx.h +++ b/libavcodec/adx.h @@ -35,11 +35,11 @@ #include "avcodec.h" -typedef struct { +typedef struct ADXChannelState { int s1,s2; } ADXChannelState; -typedef struct { +typedef struct ADXContext { AVFrame frame; int channels; ADXChannelState prev[2]; diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h index c2e2f8a5e5..b7d1b89608 100644 --- a/libavcodec/amrnbdata.h +++ b/libavcodec/amrnbdata.h @@ -55,7 +55,7 @@ enum Mode { /** * AMRNB unpacked data subframe */ -typedef struct { +typedef struct AMRNBSubframe { uint16_t p_lag; ///< index to decode the pitch lag uint16_t p_gain; ///< index to decode the pitch gain uint16_t fixed_gain; ///< index to decode the fixed gain factor, for MODE_12k2 and MODE_7k95 @@ -65,7 +65,7 @@ typedef struct { /** * AMRNB unpacked data frame */ -typedef struct { +typedef struct AMRNBFrame { uint16_t lsf[5]; ///< lsf parameters: 5 parameters for MODE_12k2, only 3 for other modes AMRNBSubframe subframe[4]; ///< unpacked data for each subframe } AMRNBFrame; diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h index 83a93e997a..81f8b47d1b 100644 --- a/libavcodec/amrwbdata.h +++ b/libavcodec/amrwbdata.h @@ -66,7 +66,7 @@ enum Mode { /* All decoded parameters in these structs must be 2 bytes long * because of the direct indexing at the frame parsing */ -typedef struct { +typedef struct AMRWBSubFrame { uint16_t adap; ///< adaptive codebook index uint16_t ltp; ///< ltp-filtering flag uint16_t vq_gain; ///< VQ adaptive and innovative gains @@ -75,7 +75,7 @@ typedef struct { uint16_t pul_il[4]; ///< LSBs part of codebook index } AMRWBSubFrame; -typedef struct { +typedef struct AMRWBFrame { uint16_t vad; ///< voice activity detection flag uint16_t isp_id[7]; ///< index of ISP subvectors AMRWBSubFrame subframe[4]; ///< data for subframes diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index 444f758e5d..0f89558e3d 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -29,11 +29,11 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" -typedef struct { +typedef struct GetByteContext { const uint8_t *buffer, *buffer_end, *buffer_start; } GetByteContext; -typedef struct { +typedef struct PutByteContext { uint8_t *buffer, *buffer_end, *buffer_start; int eof; } PutByteContext; diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index 8f5da54b3a..2e43124927 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -152,7 +152,7 @@ struct dec_2dvlc { int8_t max_run; }; -typedef struct { +typedef struct AVSContext { MpegEncContext s; CAVSDSPContext cdsp; Picture picture; ///< currently decoded frame diff --git a/libavcodec/dirac.h b/libavcodec/dirac.h index f8063d9e28..e5b79b09d2 100644 --- a/libavcodec/dirac.h +++ b/libavcodec/dirac.h @@ -31,7 +31,7 @@ #include "avcodec.h" #include "get_bits.h" -typedef struct { +typedef struct dirac_source_params { unsigned width; unsigned height; uint8_t chroma_format; ///< 0: 444 1: 422 2: 420 diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h index 74cf0b522f..66b03499d7 100644 --- a/libavcodec/dnxhddata.h +++ b/libavcodec/dnxhddata.h @@ -25,7 +25,7 @@ #include #include "avcodec.h" -typedef struct { +typedef struct CIDEntry { int cid; unsigned int width, height; int interlaced; diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 4484cf8023..c74b9a78ca 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -29,12 +29,12 @@ #include "mpegvideo.h" #include "dnxhddata.h" -typedef struct { +typedef struct RCCMPEntry { uint16_t mb; int value; } RCCMPEntry; -typedef struct { +typedef struct RCEntry { int ssd; int bits; } RCEntry; diff --git a/libavcodec/dwt.h b/libavcodec/dwt.h index f2d7864c65..e06f3f9393 100644 --- a/libavcodec/dwt.h +++ b/libavcodec/dwt.h @@ -26,7 +26,7 @@ typedef int DWTELEM; typedef short IDWTELEM; -typedef struct { +typedef struct DWTCompose { IDWTELEM *b0; IDWTELEM *b1; IDWTELEM *b2; diff --git a/libavcodec/g722.h b/libavcodec/g722.h index eb3b9b872e..bab1da48cc 100644 --- a/libavcodec/g722.h +++ b/libavcodec/g722.h @@ -30,7 +30,7 @@ #define PREV_SAMPLES_BUF_SIZE 1024 -typedef struct { +typedef struct G722Context { const AVClass *class; AVFrame frame; int bits_per_codeword; diff --git a/libavcodec/gsmdec_data.h b/libavcodec/gsmdec_data.h index 2ff2322ab1..61715c8858 100644 --- a/libavcodec/gsmdec_data.h +++ b/libavcodec/gsmdec_data.h @@ -25,7 +25,7 @@ #include #include "avcodec.h" -typedef struct { +typedef struct GSMContext { AVFrame frame; // Contains first 120 elements from the previous frame // (used by long_term_synth according to the "lag"), diff --git a/libavcodec/huffman.h b/libavcodec/huffman.h index 881c30db47..043e6e3991 100644 --- a/libavcodec/huffman.h +++ b/libavcodec/huffman.h @@ -29,7 +29,7 @@ #include "avcodec.h" #include "get_bits.h" -typedef struct { +typedef struct Node { int16_t sym; int16_t n0; uint32_t count; diff --git a/libavcodec/indeo3data.h b/libavcodec/indeo3data.h index 55164c2531..2ef8ea74bd 100644 --- a/libavcodec/indeo3data.h +++ b/libavcodec/indeo3data.h @@ -320,7 +320,7 @@ static const int32_t delta_tab_3_4_m10[79] = { TAB_3_4 }; static const int32_t delta_tab_3_5_m10[79] = { TAB_3_5 }; -typedef struct { +typedef struct vqEntry { const int16_t *deltas; ///< delta tables for 4x4 block modes const int32_t *deltas_m10; ///< delta tables for 8x8 block modes uint8_t num_dyads; ///< number of two-pixel deltas diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h index be984f8df7..69673171a8 100644 --- a/libavcodec/intrax8.h +++ b/libavcodec/intrax8.h @@ -23,7 +23,7 @@ #include "mpegvideo.h" #include "intrax8dsp.h" -typedef struct{ +typedef struct IntraX8Context { VLC * j_ac_vlc[4];//they point to the static j_mb_vlc VLC * j_orient_vlc; VLC * j_dc_vlc[3]; diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h index 1b654f8ead..7c6d1314de 100644 --- a/libavcodec/ivi_common.h +++ b/libavcodec/ivi_common.h @@ -40,7 +40,7 @@ /** * huffman codebook descriptor */ -typedef struct { +typedef struct IVIHuffDesc { int32_t num_rows; uint8_t xbits[16]; } IVIHuffDesc; @@ -48,7 +48,7 @@ typedef struct { /** * macroblock/block huffman table descriptor */ -typedef struct { +typedef struct IVIHuffTab { int32_t tab_sel; /// index of one of the predefined tables /// or "7" for custom one VLC *tab; /// pointer to the table associated with tab_sel @@ -85,7 +85,7 @@ typedef void (DCTransformPtr) (const int32_t *in, int16_t *out, uint32_t pitch, /** * run-value (RLE) table descriptor */ -typedef struct { +typedef struct RVMapDesc { uint8_t eob_sym; ///< end of block symbol uint8_t esc_sym; ///< escape symbol uint8_t runtab[256]; @@ -98,7 +98,7 @@ extern const RVMapDesc ff_ivi_rvmap_tabs[9]; /** * information for Indeo macroblock (16x16, 8x8 or 4x4) */ -typedef struct { +typedef struct IVIMbInfo { int16_t xpos; int16_t ypos; uint32_t buf_offs; ///< address in the output buffer for this mb @@ -113,7 +113,7 @@ typedef struct { /** * information for Indeo tile */ -typedef struct { +typedef struct IVITile { int xpos; int ypos; int width; @@ -130,7 +130,7 @@ typedef struct { /** * information for Indeo wavelet band */ -typedef struct { +typedef struct IVIBandDesc { int plane; ///< plane number this band belongs to int band_num; ///< band number int width; @@ -177,7 +177,7 @@ typedef struct { /** * color plane (luma or chroma) information */ -typedef struct { +typedef struct IVIPlaneDesc { uint16_t width; uint16_t height; uint8_t num_bands; ///< number of bands this plane subdivided into @@ -185,7 +185,7 @@ typedef struct { } IVIPlaneDesc; -typedef struct { +typedef struct IVIPicConfig { uint16_t pic_width; uint16_t pic_height; uint16_t chroma_width; diff --git a/libavcodec/libschroedinger.h b/libavcodec/libschroedinger.h index 8d04d2cdcb..f33014d766 100644 --- a/libavcodec/libschroedinger.h +++ b/libavcodec/libschroedinger.h @@ -31,7 +31,7 @@ #include "avcodec.h" -typedef struct { +typedef struct SchroVideoFormatInfo { uint16_t width; uint16_t height; uint16_t frame_rate_num; diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h index b001ad270d..d7711126b8 100644 --- a/libavcodec/mlp.h +++ b/libavcodec/mlp.h @@ -71,7 +71,7 @@ #define IIR 1 /** filter data */ -typedef struct { +typedef struct FilterParams { uint8_t order; ///< number of taps in filter uint8_t shift; ///< Right shift to apply to output of filter. @@ -79,7 +79,7 @@ typedef struct { } FilterParams; /** sample data coding information */ -typedef struct { +typedef struct ChannelParams { FilterParams filter_params[NUM_FILTERS]; int32_t coeff[NUM_FILTERS][MAX_FIR_ORDER]; diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index 2ee3c6d416..86d4b6d393 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -41,7 +41,7 @@ #define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND) /** Subband structure - hold all variables for each subband */ -typedef struct { +typedef struct Band { int msf; ///< mid-stereo flag int res[2]; int scfi[2]; @@ -49,7 +49,7 @@ typedef struct { int Q[2]; }Band; -typedef struct { +typedef struct MPCContext { AVFrame frame; DSPContext dsp; MPADSPContext mpadsp; diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index 7560f3f4e4..1ee2d7e2c7 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -26,7 +26,7 @@ #include "get_bits.h" #include "put_bits.h" -typedef struct { +typedef struct MPEG4AudioConfig { int object_type; int sampling_index; int sample_rate; diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h index f6578258a1..ba22259fcb 100644 --- a/libavcodec/proresdsp.h +++ b/libavcodec/proresdsp.h @@ -27,7 +27,7 @@ #define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder -typedef struct { +typedef struct ProresDSPContext { int idct_permutation_type; uint8_t idct_permutation[64]; int dct_permutation_type; diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h index 4c6cf15e3e..319833e904 100644 --- a/libavcodec/qcelpdata.h +++ b/libavcodec/qcelpdata.h @@ -37,7 +37,7 @@ /** * QCELP unpacked data frame */ -typedef struct { +typedef struct QCELPFrame { /// @name QCELP excitation codebook parameters /// @{ uint8_t cbsign[16]; ///< sign of the codebook gain for each codebook subframe @@ -73,7 +73,7 @@ typedef struct { */ static const float qcelp_hammsinc_table[4] = { -0.006822, 0.041249, -0.143459, 0.588863}; -typedef struct { +typedef struct QCELPBitmap { uint8_t index; /**< index into the QCELPContext structure */ uint8_t bitpos; /**< position of the lowest bit in the value's byte */ uint8_t bitlen; /**< number of bits to read */ diff --git a/libavcodec/ra144.h b/libavcodec/ra144.h index 967afe02ee..73f83f0865 100644 --- a/libavcodec/ra144.h +++ b/libavcodec/ra144.h @@ -33,7 +33,7 @@ #define FRAMESIZE 20 ///< size of encoded frame #define LPC_ORDER 10 ///< order of LPC filter -typedef struct { +typedef struct RA144Context { AVCodecContext *avctx; AVFrame frame; LPCContext lpc_ctx; diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h index 4018e357a9..33d77edc8b 100644 --- a/libavcodec/roqvideo.h +++ b/libavcodec/roqvideo.h @@ -27,16 +27,16 @@ #include "bytestream.h" #include "dsputil.h" -typedef struct { +typedef struct roq_cell { unsigned char y[4]; unsigned char u, v; } roq_cell; -typedef struct { +typedef struct roq_qcell { int idx[4]; } roq_qcell; -typedef struct { +typedef struct motion_vect { int d[2]; } motion_vect; diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h index 18f843ba82..9fbfb34ddc 100644 --- a/libavcodec/rtjpeg.h +++ b/libavcodec/rtjpeg.h @@ -29,7 +29,7 @@ #define RTJPEG_FILE_VERSION 0 #define RTJPEG_HEADER_SIZE 12 -typedef struct { +typedef struct RTJpegContext { int w, h; DSPContext *dsp; uint8_t scan[64]; diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index 228b158e10..a47ad6eedb 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -37,7 +37,7 @@ /** * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header. */ -typedef struct { +typedef struct SpectrumParameters { uint8_t bs_start_freq; uint8_t bs_stop_freq; uint8_t bs_xover_band; @@ -57,7 +57,7 @@ typedef struct { /** * Spectral Band Replication per channel data */ -typedef struct { +typedef struct SBRData { /** * @name Main bitstream data variables * @{ @@ -111,7 +111,7 @@ typedef struct { /** * Spectral Band Replication */ -typedef struct { +typedef struct SpectralBandReplication { int sample_rate; int start; int reset; diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h index ee4967cdfe..6b72f6ad7e 100644 --- a/libavcodec/vorbis.h +++ b/libavcodec/vorbis.h @@ -29,7 +29,7 @@ extern const uint8_t ff_vorbis_channel_layout_offsets[8][8]; extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8]; extern const uint64_t ff_vorbis_channel_layouts[9]; -typedef struct { +typedef struct vorbis_floor1_entry { uint16_t x; uint16_t sort; uint16_t low; diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 000dfe0098..27539c7932 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -35,7 +35,7 @@ typedef struct vp56_context VP56Context; -typedef struct { +typedef struct VP56mv { DECLARE_ALIGNED(4, int16_t, x); int16_t y; } VP56mv; @@ -52,7 +52,7 @@ typedef int (*VP56ParseCoeffModels)(VP56Context *s); typedef int (*VP56ParseHeader)(VP56Context *s, const uint8_t *buf, int buf_size, int *golden_frame); -typedef struct { +typedef struct VP56RangeCoder { int high; int bits; /* stored negated (i.e. negative "bits" is a positive number of bits left) in order to eliminate a negate in cache refilling */ @@ -61,18 +61,18 @@ typedef struct { unsigned int code_word; } VP56RangeCoder; -typedef struct { +typedef struct VP56RefDc { uint8_t not_null_dc; VP56Frame ref_frame; DCTELEM dc_coeff; } VP56RefDc; -typedef struct { +typedef struct VP56Macroblock { uint8_t type; VP56mv mv; } VP56Macroblock; -typedef struct { +typedef struct VP56Model { uint8_t coeff_reorder[64]; /* used in vp6 only */ uint8_t coeff_index_to_pos[64]; /* used in vp6 only */ uint8_t vector_sig[2]; /* delta sign */ diff --git a/libavcodec/vp56data.h b/libavcodec/vp56data.h index 39bb36d3eb..0535425d3d 100644 --- a/libavcodec/vp56data.h +++ b/libavcodec/vp56data.h @@ -51,7 +51,7 @@ typedef enum { VP56_MB_INTER_V2_GF = 9, /**< Inter MB, second vector, from golden frame */ } VP56mb; -typedef struct { +typedef struct VP56Tree { int8_t val; int8_t prob_idx; } VP56Tree; diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h index a337173520..073a0335e0 100644 --- a/libavcodec/vp8.h +++ b/libavcodec/vp8.h @@ -72,13 +72,13 @@ enum inter_splitmvmode { VP8_SPLITMVMODE_NONE, ///< (only used in prediction) no split MVs }; -typedef struct { +typedef struct VP8FilterStrength { uint8_t filter_level; uint8_t inner_limit; uint8_t inner_filter; } VP8FilterStrength; -typedef struct { +typedef struct VP8Macroblock { uint8_t skip; // todo: make it possible to check for at least (i4x4 or split_mv) // in one op. are others needed? @@ -93,7 +93,7 @@ typedef struct { VP56mv bmv[16]; } VP8Macroblock; -typedef struct { +typedef struct VP8ThreadData { DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16]; DECLARE_ALIGNED(16, DCTELEM, block_dc)[16]; /** @@ -123,7 +123,7 @@ typedef struct { } VP8ThreadData; #define MAX_THREADS 8 -typedef struct { +typedef struct VP8Context { VP8ThreadData *thread_data; AVCodecContext *avctx; AVFrame *framep[4]; diff --git a/libavcodec/w32pthreads.h b/libavcodec/w32pthreads.h index 8489f715db..91e7353fbb 100644 --- a/libavcodec/w32pthreads.h +++ b/libavcodec/w32pthreads.h @@ -42,7 +42,7 @@ #include "libavutil/internal.h" #include "libavutil/mem.h" -typedef struct { +typedef struct pthread_t { void *handle; void *(*func)(void* arg); void *arg; @@ -56,7 +56,7 @@ typedef CRITICAL_SECTION pthread_mutex_t; /* This is the CONDITIONAL_VARIABLE typedef for using Window's native * conditional variables on kernels 6.0+. * MinGW does not currently have this typedef. */ -typedef struct { +typedef struct pthread_cond_t { void *ptr; } pthread_cond_t; @@ -117,7 +117,7 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m) /* for pre-Windows 6.0 platforms we need to define and use our own condition * variable and api */ -typedef struct { +typedef struct win32_cond_t { pthread_mutex_t mtx_broadcast; pthread_mutex_t mtx_waiter_count; volatile int waiter_count; diff --git a/libavcodec/x86/dsputil_mmx.h b/libavcodec/x86/dsputil_mmx.h index 00c7fb12bf..bd14c5ad41 100644 --- a/libavcodec/x86/dsputil_mmx.h +++ b/libavcodec/x86/dsputil_mmx.h @@ -26,7 +26,7 @@ #include "libavcodec/dsputil.h" #include "libavutil/x86/asm.h" -typedef struct { uint64_t a, b; } xmm_reg; +typedef struct xmm_reg { uint64_t a, b; } xmm_reg; extern const uint64_t ff_bone; extern const uint64_t ff_wtwo; diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index a0e81d9e3e..26eaee6acf 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -42,7 +42,7 @@ #define ALSA_BUFFER_SIZE_MAX 32768 -typedef struct { +typedef struct AlsaData { AVClass *class; snd_pcm_t *h; int frame_size; ///< preferred size for reads and writes diff --git a/libavdevice/sndio_common.h b/libavdevice/sndio_common.h index dc75237b86..2f70213aed 100644 --- a/libavdevice/sndio_common.h +++ b/libavdevice/sndio_common.h @@ -28,7 +28,7 @@ #include "libavformat/avformat.h" #include "libavutil/log.h" -typedef struct { +typedef struct SndioData { AVClass *class; struct sio_hdl *hdl; enum AVCodecID codec_id; diff --git a/libavfilter/gradfun.h b/libavfilter/gradfun.h index 5d011309c6..876579a182 100644 --- a/libavfilter/gradfun.h +++ b/libavfilter/gradfun.h @@ -25,7 +25,7 @@ #include "avfilter.h" /// Holds instance-specific information for gradfun. -typedef struct { +typedef struct GradFunContext { int thresh; ///< threshold for gradient algorithm int radius; ///< blur radius int chroma_w; ///< width of the chroma planes diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h index 9d23870cd1..06b39c69de 100644 --- a/libavfilter/yadif.h +++ b/libavfilter/yadif.h @@ -22,7 +22,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" -typedef struct { +typedef struct YADIFContext { /** * 0: send 1 frame for each frame * 1: send 1 frame for each field diff --git a/libavformat/asf.h b/libavformat/asf.h index b72445def9..1d94a2c924 100644 --- a/libavformat/asf.h +++ b/libavformat/asf.h @@ -27,7 +27,7 @@ #define PACKET_SIZE 3200 -typedef struct { +typedef struct ASFStream { int num; unsigned char seq; /* use for reading */ @@ -50,7 +50,7 @@ typedef struct { typedef uint8_t ff_asf_guid[16]; -typedef struct { +typedef struct ASFMainHeader { ff_asf_guid guid; ///< generated by client computer uint64_t file_size; /**< in bytes * invalid if broadcasting */ @@ -76,7 +76,7 @@ typedef struct { } ASFMainHeader; -typedef struct { +typedef struct ASFIndex { uint32_t packet_number; uint16_t packet_count; } ASFIndex; diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h index af29629b8a..9c7b548c1d 100644 --- a/libavformat/audiointerleave.h +++ b/libavformat/audiointerleave.h @@ -26,7 +26,7 @@ #include "libavutil/fifo.h" #include "avformat.h" -typedef struct { +typedef struct AudioInterleaveContext { AVFifoBuffer *fifo; unsigned fifo_size; ///< size of currently allocated FIFO uint64_t dts; ///< current dts diff --git a/libavformat/httpauth.h b/libavformat/httpauth.h index bd0644906a..99bf43ffdc 100644 --- a/libavformat/httpauth.h +++ b/libavformat/httpauth.h @@ -32,7 +32,7 @@ typedef enum HTTPAuthType { HTTP_AUTH_DIGEST, /**< HTTP 1.1 Digest auth from RFC 2617 */ } HTTPAuthType; -typedef struct { +typedef struct DigestParams { char nonce[300]; /**< Server specified nonce */ char algorithm[10]; /**< Server specified digest algorithm */ char qop[30]; /**< Quality of protection, containing the one @@ -52,7 +52,7 @@ typedef struct { * HTTP Authentication state structure. Must be zero-initialized * before used with the functions below. */ -typedef struct { +typedef struct HTTPAuthState { /** * The currently chosen auth type. */ diff --git a/libavformat/isom.h b/libavformat/isom.h index b191699711..932b1d0a68 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -42,18 +42,18 @@ int ff_mov_lang_to_iso639(unsigned code, char to[4]); * Here we just use what is needed to read the chunks */ -typedef struct { +typedef struct MOVStts { int count; int duration; } MOVStts; -typedef struct { +typedef struct MOVStsc { int first; int count; int id; } MOVStsc; -typedef struct { +typedef struct MOVDref { uint32_t type; char *path; char *dir; @@ -62,14 +62,14 @@ typedef struct { int16_t nlvl_to, nlvl_from; } MOVDref; -typedef struct { +typedef struct MOVAtom { uint32_t type; int64_t size; /* total size (excluding the size and type fields) */ } MOVAtom; struct MOVParseTableEntry; -typedef struct { +typedef struct MOVFragment { unsigned track_id; uint64_t base_data_offset; uint64_t moof_offset; @@ -79,7 +79,7 @@ typedef struct { unsigned flags; } MOVFragment; -typedef struct { +typedef struct MOVTrackExt { unsigned track_id; unsigned stsd_id; unsigned duration; @@ -87,7 +87,7 @@ typedef struct { unsigned flags; } MOVTrackExt; -typedef struct { +typedef struct MOVSbgp { unsigned int count; unsigned int index; } MOVSbgp; diff --git a/libavformat/mms.h b/libavformat/mms.h index 5235581645..e89da41bb6 100644 --- a/libavformat/mms.h +++ b/libavformat/mms.h @@ -23,11 +23,11 @@ #include "url.h" -typedef struct { +typedef struct MMSStream { int id; }MMSStream; -typedef struct { +typedef struct MMSContext { URLContext *mms_hd; ///< TCP connection handle MMSStream *streams; diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 3be43e0fc9..e20ef1475b 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -60,13 +60,13 @@ typedef struct HintSample { int own_data; } HintSample; -typedef struct { +typedef struct HintSampleQueue { int size; int len; HintSample *samples; } HintSampleQueue; -typedef struct { +typedef struct MOVFragmentInfo { int64_t offset; int64_t time; int64_t duration; diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 9f2ba3f8f3..89544f06f8 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -65,7 +65,7 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len); void ff_mpegts_parse_close(MpegTSContext *ts); -typedef struct { +typedef struct SLConfigDescr { int use_au_start; int use_au_end; int use_rand_acc_pt; @@ -82,7 +82,7 @@ typedef struct { int packet_seq_num_len; } SLConfigDescr; -typedef struct { +typedef struct Mp4Descr { int es_id; int dec_config_descr_len; uint8_t *dec_config_descr; diff --git a/libavformat/mxf.h b/libavformat/mxf.h index f39a013f7b..88322d1591 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -54,13 +54,13 @@ enum MXFFrameLayout { SeparateFields }; -typedef struct { +typedef struct KLVPacket { UID key; int64_t offset; uint64_t length; } KLVPacket; -typedef struct { +typedef struct MXFCodecUL { UID uid; unsigned matching_len; int id; diff --git a/libavformat/nut.h b/libavformat/nut.h index 419b123bee..3f09689bd1 100644 --- a/libavformat/nut.h +++ b/libavformat/nut.h @@ -53,14 +53,14 @@ typedef enum{ FLAG_INVALID =8192, /// -typedef struct { +typedef struct SWFContext { int64_t duration_pos; int64_t tag_pos; int64_t vframes_pos; diff --git a/libavutil/dict.h b/libavutil/dict.h index 72d1e9d25b..492da9a41c 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -68,7 +68,7 @@ #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no delimiter is added, the strings are simply concatenated. */ -typedef struct { +typedef struct AVDictionaryEntry { char *key; char *value; } AVDictionaryEntry; diff --git a/libavutil/lfg.h b/libavutil/lfg.h index 904d00a669..5e526c1dae 100644 --- a/libavutil/lfg.h +++ b/libavutil/lfg.h @@ -22,7 +22,7 @@ #ifndef AVUTIL_LFG_H #define AVUTIL_LFG_H -typedef struct { +typedef struct AVLFG { unsigned int state[64]; int index; } AVLFG; diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 3b304d5629..8f4605ea6b 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -115,13 +115,13 @@ const int *sws_getCoefficients(int colorspace); // when used for filters they must have an odd number of elements // coeffs cannot be shared between vectors -typedef struct { +typedef struct SwsVector { double *coeff; ///< pointer to the list of coefficients int length; ///< number of coefficients in the vector } SwsVector; // vectors can be shared -typedef struct { +typedef struct SwsFilter { SwsVector *lumH; SwsVector *lumV; SwsVector *chrH; From d3a72becc6371563185a509b94f5daf32ddbb485 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 5 Oct 2012 15:53:32 +0200 Subject: [PATCH 15/15] yuv4mpeg: return proper error codes. Fixes Bug 373. CC:libav-stable@libav.org --- libavformat/yuv4mpeg.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index c17d7e5246..23fb129971 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -367,7 +367,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) { int i; char header[MAX_FRAME_HEADER+1]; - int packet_size, width, height; + int packet_size, width, height, ret; AVStream *st = s->streams[0]; struct frame_attributes *s1 = s->priv_data; @@ -378,20 +378,28 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) break; } } - if (i == MAX_FRAME_HEADER) - return -1; + if (s->pb->error) + return s->pb->error; + else if (s->pb->eof_reached) + return AVERROR_EOF; + else if (i == MAX_FRAME_HEADER) + return AVERROR_INVALIDDATA; + if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) - return -1; + return AVERROR_INVALIDDATA; width = st->codec->width; height = st->codec->height; packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); if (packet_size < 0) - return -1; + return packet_size; - if (av_get_packet(s->pb, pkt, packet_size) != packet_size) - return AVERROR(EIO); + ret = av_get_packet(s->pb, pkt, packet_size); + if (ret < 0) + return ret; + else if (ret != packet_size) + return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); if (st->codec->coded_frame) { st->codec->coded_frame->interlaced_frame = s1->interlaced_frame;