From 4719ea7e1e6113010da2ccdb9a84e45104ab4de7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 2 Jul 2012 13:49:13 +0100 Subject: [PATCH 01/13] flacdec: remove redundant setting of avctx->sample_fmt Signed-off-by: Mans Rullgard --- libavcodec/flacdec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index cd2a69390a..6a06d1922d 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -108,8 +108,6 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) FLACContext *s = avctx->priv_data; s->avctx = avctx; - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - /* for now, the raw FLAC header is allowed to be passed to the decoder as frame data instead of extradata. */ if (!avctx->extradata) From 4d8516fdb15d0177ad745228508254dee187dff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 2 Jul 2012 10:39:25 +0300 Subject: [PATCH 02/13] snow: Check mallocs at init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/snow.c | 19 ++++++++++++------- libavcodec/snowdec.c | 7 ++++++- libavcodec/snowenc.c | 7 +++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 821b81bf47..96de9f36d2 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -394,7 +394,7 @@ mca( 8, 8,8) av_cold int ff_snow_common_init(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int width, height; - int i, j; + int i, j, ret; s->avctx= avctx; s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe @@ -447,19 +447,24 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ width= s->avctx->width; height= s->avctx->height; - s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM)); - s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here - s->temp_dwt_buffer = av_mallocz(width * sizeof(DWTELEM)); - s->temp_idwt_buffer = av_mallocz(width * sizeof(IDWTELEM)); + FF_ALLOCZ_OR_GOTO(avctx, s->spatial_idwt_buffer, width * height * sizeof(IDWTELEM), fail); + FF_ALLOCZ_OR_GOTO(avctx, s->spatial_dwt_buffer, width * height * sizeof(DWTELEM), fail); //FIXME this does not belong here + FF_ALLOCZ_OR_GOTO(avctx, s->temp_dwt_buffer, width * sizeof(DWTELEM), fail); + FF_ALLOCZ_OR_GOTO(avctx, s->temp_idwt_buffer, width * sizeof(IDWTELEM), fail); for(i=0; iavctx->get_buffer(s->avctx, &s->mconly_picture); - s->scratchbuf = av_malloc(s->mconly_picture.linesize[0]*7*MB_SIZE); + if ((ret = s->avctx->get_buffer(s->avctx, &s->mconly_picture)) < 0) { + av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; + } + FF_ALLOC_OR_GOTO(avctx, s->scratchbuf, s->mconly_picture.linesize[0]*7*MB_SIZE, fail); return 0; +fail: + return AVERROR(ENOMEM); } int ff_snow_common_init_after_header(AVCodecContext *avctx) { diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 5dec277eb0..9ea8c493fd 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -354,9 +354,14 @@ static int decode_header(SnowContext *s){ static av_cold int decode_init(AVCodecContext *avctx) { + int ret; + avctx->pix_fmt= PIX_FMT_YUV420P; - ff_snow_common_init(avctx); + if ((ret = ff_snow_common_init(avctx)) < 0) { + ff_snow_common_end(avctx->priv_data); + return ret; + } return 0; } diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 627a406af9..f8694ae813 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -155,7 +155,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; - int plane_index; + int plane_index, ret; if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){ av_log(avctx, AV_LOG_ERROR, "This codec is under development, files encoded with it may not be decodable with future versions!!!\n" @@ -184,7 +184,10 @@ static av_cold int encode_init(AVCodecContext *avctx) s->plane[plane_index].fast_mc= 1; } - ff_snow_common_init(avctx); + if ((ret = ff_snow_common_init(avctx)) < 0) { + ff_snow_common_end(avctx->priv_data); + return ret; + } ff_snow_alloc_blocks(s); s->version=0; From cbd9b2f918af681d206d10340f87fc6aced5cf3e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 30 Jun 2012 10:34:39 -0700 Subject: [PATCH 03/13] snow: remove the runs[] VLA. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/snow.c | 2 ++ libavcodec/snow.h | 1 + libavcodec/snowenc.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 96de9f36d2..629367ac44 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -451,6 +451,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ FF_ALLOCZ_OR_GOTO(avctx, s->spatial_dwt_buffer, width * height * sizeof(DWTELEM), fail); //FIXME this does not belong here FF_ALLOCZ_OR_GOTO(avctx, s->temp_dwt_buffer, width * sizeof(DWTELEM), fail); FF_ALLOCZ_OR_GOTO(avctx, s->temp_idwt_buffer, width * sizeof(IDWTELEM), fail); + FF_ALLOC_OR_GOTO(avctx, s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) * sizeof(*s->run_buffer), fail); for(i=0; itemp_dwt_buffer); av_freep(&s->spatial_idwt_buffer); av_freep(&s->temp_idwt_buffer); + av_freep(&s->run_buffer); s->m.me.temp= NULL; av_freep(&s->m.me.scratchpad); diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 3ceb6af99d..aa27a50fd1 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -135,6 +135,7 @@ typedef struct SnowContext{ DWTELEM *temp_dwt_buffer; IDWTELEM *spatial_idwt_buffer; IDWTELEM *temp_idwt_buffer; + int *run_buffer; int colorspace_type; int chroma_h_shift; int chroma_v_shift; diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index f8694ae813..7503953e11 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -836,7 +836,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, IDWTELEM *src, IDWTE if(1){ int run=0; - int runs[w*h]; + int *runs = s->run_buffer; int run_index=0; int max_index; From fb93e61e2b7baa44ff991bc0ce96291490a0188e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 2 Jul 2012 23:04:04 +0100 Subject: [PATCH 04/13] x86: lavfi: fix gradfun/yadif build with mmx/sse disabled These functions are defined conditionally so any uses need to have preprocessor guards. Signed-off-by: Mans Rullgard --- libavfilter/x86/gradfun.c | 12 +++++++++--- libavfilter/x86/yadif.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/gradfun.c index 1d6a7ab363..07569de146 100644 --- a/libavfilter/x86/gradfun.c +++ b/libavfilter/x86/gradfun.c @@ -168,10 +168,16 @@ av_cold void ff_gradfun_init_x86(GradFunContext *gf) { int cpu_flags = av_get_cpu_flags(); - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) +#if HAVE_MMX2 + if (cpu_flags & AV_CPU_FLAG_MMX2) gf->filter_line = gradfun_filter_line_mmx2; - if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3) +#endif +#if HAVE_SSSE3 + if (cpu_flags & AV_CPU_FLAG_SSSE3) gf->filter_line = gradfun_filter_line_ssse3; - if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2) +#endif +#if HAVE_SSE + if (cpu_flags & AV_CPU_FLAG_SSE2) gf->blur_line = gradfun_blur_line_sse2; +#endif } diff --git a/libavfilter/x86/yadif.c b/libavfilter/x86/yadif.c index fe77f3a99c..6d9f9b2880 100644 --- a/libavfilter/x86/yadif.c +++ b/libavfilter/x86/yadif.c @@ -53,10 +53,16 @@ av_cold void ff_yadif_init_x86(YADIFContext *yadif) { int cpu_flags = av_get_cpu_flags(); - if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) +#if HAVE_MMX + if (cpu_flags & AV_CPU_FLAG_MMX) yadif->filter_line = yadif_filter_line_mmx; - if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2) +#endif +#if HAVE_SSE + if (cpu_flags & AV_CPU_FLAG_SSE2) yadif->filter_line = yadif_filter_line_sse2; - if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3) +#endif +#if HAVE_SSSE3 + if (cpu_flags & AV_CPU_FLAG_SSSE3) yadif->filter_line = yadif_filter_line_ssse3; +#endif } From 33895451570742c47404fec52d87a5c71de26b83 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 2 Jul 2012 10:39:54 +0300 Subject: [PATCH 05/13] snow: remove a VLA used for edge emulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/snow.c | 4 ++++ libavcodec/snow.h | 1 + libavcodec/snowenc.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 629367ac44..d69f452e5d 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -395,6 +395,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int width, height; int i, j, ret; + int emu_buf_size; s->avctx= avctx; s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe @@ -462,6 +463,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ return ret; } FF_ALLOC_OR_GOTO(avctx, s->scratchbuf, s->mconly_picture.linesize[0]*7*MB_SIZE, fail); + emu_buf_size = s->mconly_picture.linesize[0] * (2 * MB_SIZE + HTAPS_MAX - 1); + FF_ALLOC_OR_GOTO(avctx, s->emu_edge_buffer, emu_buf_size, fail); return 0; fail: @@ -648,6 +651,7 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->block); av_freep(&s->scratchbuf); + av_freep(&s->emu_edge_buffer); for(i=0; iref_mvs[i]); diff --git a/libavcodec/snow.h b/libavcodec/snow.h index aa27a50fd1..abf330962c 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -165,6 +165,7 @@ typedef struct SnowContext{ MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) uint8_t *scratchbuf; + uint8_t *emu_edge_buffer; }SnowContext; /* Tables */ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 7503953e11..f732820bd3 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -675,7 +675,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin uint8_t *src= s-> input_picture.data[plane_index]; IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; uint8_t *cur = s->scratchbuf; - uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)]; + uint8_t *tmp = s->emu_edge_buffer; const int b_stride = s->b_width << s->block_max_depth; const int b_height = s->b_height<< s->block_max_depth; const int w= p->width; From 906f9dce85eeb8c7f29ed2a37ec737a64c0275c6 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 28 Jun 2012 20:55:04 +0200 Subject: [PATCH 06/13] avplay: fix write on freed memory for rawvideo Do not assume avpacket and the decoded frames are independent. To be absolutely sure and not sprinkle av_free_packet around the code the call had been placed before getting the frame and on the error path. --- avplay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/avplay.c b/avplay.c index 71844c274d..e05016964b 100644 --- a/avplay.c +++ b/avplay.c @@ -1597,6 +1597,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c static int video_thread(void *arg) { + AVPacket pkt = { 0 }; VideoState *is = arg; AVFrame *frame = avcodec_alloc_frame(); int64_t pts_int; @@ -1617,7 +1618,6 @@ static int video_thread(void *arg) #endif for (;;) { - AVPacket pkt; #if CONFIG_AVFILTER AVFilterBufferRef *picref; AVRational tb; @@ -1625,10 +1625,11 @@ static int video_thread(void *arg) while (is->paused && !is->videoq.abort_request) SDL_Delay(10); + av_free_packet(&pkt); + ret = get_video_frame(is, frame, &pts_int, &pkt); if (ret < 0) goto the_end; - av_free_packet(&pkt); if (!ret) continue; @@ -1708,6 +1709,7 @@ static int video_thread(void *arg) av_freep(&vfilters); avfilter_graph_free(&graph); #endif + av_free_packet(&pkt); av_free(frame); return 0; } From 09a445ce3426081da1254af62cb185180099e74e Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 1 Jul 2012 23:01:00 +0200 Subject: [PATCH 07/13] flvdec: initial stream switch support Codec change midstream gets mapped to a separate stream. --- libavformat/flvdec.c | 95 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 078c2a213e..093cd0a39f 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -76,6 +76,59 @@ static AVStream *create_stream(AVFormatContext *s, int tag, int codec_type) avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ return st; } +static int flv_same_audio_codec(AVCodecContext *acodec, int flags) +{ + int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8; + int flv_codecid = flags & FLV_AUDIO_CODECID_MASK; + int codec_id; + + if (!acodec->codec_id && !acodec->codec_tag) + return 1; + + if (acodec->bits_per_coded_sample != bits_per_coded_sample) + return 0; + + switch(flv_codecid) { + //no distinction between S16 and S8 PCM codec flags + case FLV_CODECID_PCM: + codec_id = bits_per_coded_sample == 8 ? CODEC_ID_PCM_U8 : +#if HAVE_BIGENDIAN + CODEC_ID_PCM_S16BE; +#else + CODEC_ID_PCM_S16LE; +#endif + return codec_id == acodec->codec_id; + case FLV_CODECID_PCM_LE: + codec_id = bits_per_coded_sample == 8 ? CODEC_ID_PCM_U8 : CODEC_ID_PCM_S16LE; + return codec_id == acodec->codec_id; + case FLV_CODECID_AAC: + return acodec->codec_id == CODEC_ID_AAC; + case FLV_CODECID_ADPCM: + return acodec->codec_id == CODEC_ID_ADPCM_SWF; + case FLV_CODECID_SPEEX: + return acodec->codec_id == CODEC_ID_SPEEX; + case FLV_CODECID_MP3: + return acodec->codec_id == CODEC_ID_MP3; + case FLV_CODECID_NELLYMOSER_8KHZ_MONO: + return acodec->sample_rate == 8000 && + acodec->codec_id == CODEC_ID_NELLYMOSER; + case FLV_CODECID_NELLYMOSER_16KHZ_MONO: + return acodec->sample_rate == 16000 && + acodec->codec_id == CODEC_ID_NELLYMOSER; + case FLV_CODECID_NELLYMOSER: + return acodec->codec_id == CODEC_ID_NELLYMOSER; + case FLV_CODECID_PCM_MULAW: + return acodec->sample_rate == 8000 && + acodec->codec_id == CODEC_ID_PCM_MULAW; + case FLV_CODECID_PCM_ALAW: + return acodec->sample_rate = 8000 && + acodec->codec_id == CODEC_ID_PCM_ALAW; + default: + return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET); + } + + return 0; +} static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, AVCodecContext *acodec, int flv_codecid) { switch(flv_codecid) { @@ -122,6 +175,33 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, AVCodecCo } } +static int flv_same_video_codec(AVCodecContext *vcodec, int flags) +{ + int flv_codecid = flags & FLV_VIDEO_CODECID_MASK; + + if (!vcodec->codec_id && !vcodec->codec_tag) + return 1; + + switch (flv_codecid) { + case FLV_CODECID_H263: + return vcodec->codec_id == CODEC_ID_FLV1; + case FLV_CODECID_SCREEN: + return vcodec->codec_id == CODEC_ID_FLASHSV; + case FLV_CODECID_SCREEN2: + return vcodec->codec_id == CODEC_ID_FLASHSV2; + case FLV_CODECID_VP6: + return vcodec->codec_id == CODEC_ID_VP6F; + case FLV_CODECID_VP6A: + return vcodec->codec_id == CODEC_ID_VP6A; + case FLV_CODECID_H264: + return vcodec->codec_id == CODEC_ID_H264; + default: + return vcodec->codec_tag == flv_codecid; + } + + return 0; +} + static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid) { AVCodecContext *vcodec = vstream->codec; switch(flv_codecid) { @@ -511,7 +591,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; - if (st->id == 2) + if (st->codec->codec_type == AVMEDIA_TYPE_DATA) break; } @@ -605,11 +685,18 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) /* now find stream */ for(i=0;inb_streams;i++) { st = s->streams[i]; - if (st->id == is_audio) - break; + if (is_audio && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + if (flv_same_audio_codec(st->codec, flags)) { + break; + } + } else + if (!is_audio && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (flv_same_video_codec(st->codec, flags)) { + break; + } + } } if(i == s->nb_streams){ - av_log(s, AV_LOG_ERROR, "invalid stream\n"); st = create_stream(s, is_audio, is_audio ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO); s->ctx_flags &= ~AVFMTCTX_NOHEADER; From 06eb4f0885746b7e8a652d7b6026abf834e04b73 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 1 Jul 2012 20:21:10 +0100 Subject: [PATCH 08/13] configure: do not disable av_always_inline with --enable-small Currently, --enable-small turns av_always_inline into plain inline, which is more or less ignored by the compiler. While the intent of this is probably to reduce code size by avoiding some inlining, it has more far-reaching effects. We use av_always_inline in two situations: 1. The body of a function is smaller than the call overhead. Instances of these are abundant in libavutil, the bswap.h functions being good examples. 2. The function is a template relying on constant propagation through inlined calls for sane code generation. These are often found in motion compensation code. Both of these types of functions should be inlined even if targeting small code size. Although GCC has heuristics for detecting the first of these types, it is not always reliable, especially when the function uses inline assembler, which is often the reason for having those functions in the first place, so making it explicit is generally a good idea. The size increase from inlining template-type functions is usually much smaller than it seems due to different branches being mutually exclusive between the different invocations. The dead branches can, however, only be removed after inlining and constant propagation have been performed, which means the initial cost estimate for inlining these is much higher than is actually the case, resulting in GCC often making bad choices if left to its own devices. Furthermore, the GCC inliner limits how much it allows a function to grow due to automatic inlining of calls, and this appears to not take call overhead into account. When nested inlining is used, the limit may be hit before the innermost level is reached. In some cases, this has prevented inlining of type 1 functions as defined above, resulting in significant performance loss. Signed-off-by: Mans Rullgard --- configure | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configure b/configure index a7ac43fa07..3a1b4361b8 100755 --- a/configure +++ b/configure @@ -3403,15 +3403,6 @@ EOF test -n "$malloc_prefix" && echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH -if enabled small || disabled optimizations; then - echo "#undef av_always_inline" >> $TMPH - if enabled small; then - echo "#define av_always_inline inline" >> $TMPH - else - echo "#define av_always_inline av_unused" >> $TMPH - fi -fi - if enabled yasm; then append config_files $TMPASM printf '' >$TMPASM From a1641e954091760a759e6281ccc360d3817f9397 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 1 Jul 2012 20:36:03 +0200 Subject: [PATCH 09/13] attributes: drop pointless define guards the av_-prefixed attributes must not be defined outside of this file --- libavutil/attributes.h | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/libavutil/attributes.h b/libavutil/attributes.h index c0bac3f309..7a9b18b808 100644 --- a/libavutil/attributes.h +++ b/libavutil/attributes.h @@ -32,7 +32,6 @@ # define AV_GCC_VERSION_AT_LEAST(x,y) 0 #endif -#ifndef av_always_inline #if AV_GCC_VERSION_AT_LEAST(3,1) # define av_always_inline __attribute__((always_inline)) inline #elif defined(_MSC_VER) @@ -40,92 +39,71 @@ #else # define av_always_inline inline #endif -#endif -#ifndef av_noinline #if AV_GCC_VERSION_AT_LEAST(3,1) # define av_noinline __attribute__((noinline)) #else # define av_noinline #endif -#endif -#ifndef av_pure #if AV_GCC_VERSION_AT_LEAST(3,1) # define av_pure __attribute__((pure)) #else # define av_pure #endif -#endif -#ifndef av_const #if AV_GCC_VERSION_AT_LEAST(2,6) # define av_const __attribute__((const)) #else # define av_const #endif -#endif -#ifndef av_cold #if AV_GCC_VERSION_AT_LEAST(4,3) # define av_cold __attribute__((cold)) #else # define av_cold #endif -#endif -#ifndef av_flatten #if AV_GCC_VERSION_AT_LEAST(4,1) # define av_flatten __attribute__((flatten)) #else # define av_flatten #endif -#endif -#ifndef attribute_deprecated #if AV_GCC_VERSION_AT_LEAST(3,1) # define attribute_deprecated __attribute__((deprecated)) #else # define attribute_deprecated #endif -#endif -#ifndef av_unused #if defined(__GNUC__) # define av_unused __attribute__((unused)) #else # define av_unused #endif -#endif /** * Mark a variable as used and prevent the compiler from optimizing it * away. This is useful for variables accessed only from inline * assembler without the compiler being aware. */ -#ifndef av_used #if AV_GCC_VERSION_AT_LEAST(3,1) # define av_used __attribute__((used)) #else # define av_used #endif -#endif -#ifndef av_alias #if AV_GCC_VERSION_AT_LEAST(3,3) # define av_alias __attribute__((may_alias)) #else # define av_alias #endif -#endif -#ifndef av_uninit #if defined(__GNUC__) && !defined(__ICC) # define av_uninit(x) x=x #else # define av_uninit(x) x #endif -#endif #ifdef __GNUC__ # define av_builtin_constant_p __builtin_constant_p From 22662ca56086ddb7240dc84a68ad89c785682f36 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 1 Jul 2012 19:38:40 +0200 Subject: [PATCH 10/13] attributes: add av_noreturn Also use it in the declaration of the various exit_program implementations in avtools. inspired by a clang-scan report. --- cmdutils.h | 2 +- libavutil/attributes.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmdutils.h b/cmdutils.h index 793a1e83c4..ca4f4c1e8c 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -373,7 +373,7 @@ FILE *get_preset_file(char *filename, size_t filename_size, * Do all the necessary cleanup and abort. * This function is implemented in the avtools, not cmdutils. */ -void exit_program(int ret); +av_noreturn void exit_program(int ret); /** * Realloc array to hold new_size elements of elem_size. diff --git a/libavutil/attributes.h b/libavutil/attributes.h index 7a9b18b808..292a0a1a88 100644 --- a/libavutil/attributes.h +++ b/libavutil/attributes.h @@ -113,4 +113,10 @@ # define av_printf_format(fmtpos, attrpos) #endif +#if AV_GCC_VERSION_AT_LEAST(2,5) +# define av_noreturn __attribute__((noreturn)) +#else +# define av_noreturn +#endif + #endif /* AVUTIL_ATTRIBUTES_H */ From 09f211987cddf279390f8abe24d6a7a69622e356 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 13 Jun 2012 11:41:12 +0200 Subject: [PATCH 11/13] misc typo and wording fixes --- libavcodec/anm.c | 4 ++-- libavcodec/dsputil.h | 4 ++-- libavcodec/h264.c | 4 ++-- libavcodec/version.h | 2 +- libavcodec/xvmc.h | 2 +- libavfilter/version.h | 2 +- libavformat/rtp.h | 2 +- libavformat/version.h | 2 +- tools/patcheck | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/anm.c b/libavcodec/anm.c index 831cdfb9ac..b86b7c0ffb 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -65,8 +65,8 @@ static av_cold int decode_init(AVCodecContext *avctx) * @return non-zero if destination buffer is exhausted * * a copy operation is achieved when 'gb' is set - * a fill operation is acheived when 'gb' is null and pixel is >= 0 - * a skip operation is acheived when 'gb' is null and pixel is < 0 + * a fill operation is achieved when 'gb' is null and pixel is >= 0 + * a skip operation is achieved when 'gb' is null and pixel is < 0 */ static inline int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index e54ae69831..77980e02f8 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -548,9 +548,9 @@ typedef struct DSPContext { * @param src source array * constraints: 16-byte aligned * @param min minimum value - * constraints: must in the the range [-(1<<24), 1<<24] + * constraints: must be in the range [-(1 << 24), 1 << 24] * @param max maximum value - * constraints: must in the the range [-(1<<24), 1<<24] + * constraints: must be in the range [-(1 << 24), 1 << 24] * @param len number of elements in the array * constraints: multiple of 32 greater than zero */ diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 025a0dd156..2d6a08e032 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1744,7 +1744,7 @@ static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, } top_border = h->top_borders[top_idx][s->mb_x]; - /* There are two lines saved, the line above the the top macroblock + /* There are two lines saved, the line above the top macroblock * of a pair, and the line above the bottom macroblock. */ AV_COPY128(top_border, src_y + 16 * linesize); if (pixel_shift) @@ -4375,7 +4375,7 @@ again: if (ff_h264_decode_seq_parameter_set(h) < 0 && h->is_avc && (nalsize != consumed) && nalsize) { av_log(h->s.avctx, AV_LOG_DEBUG, - "SPS decoding failure, try parsing the coomplete NAL\n"); + "SPS decoding failure, trying again with the complete NAL\n"); init_get_bits(&s->gb, buf + buf_index + 1 - consumed, 8 * (nalsize - 1)); ff_h264_decode_seq_parameter_set(h); diff --git a/libavcodec/version.h b/libavcodec/version.h index f42aebe2bb..1e189f6390 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,7 +41,7 @@ #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) /** - * Those FF_API_* defines are not part of public API. + * These FF_API_* defines are not part of the public API. * They may change, break or disappear at any time. */ #ifndef FF_API_REQUEST_CHANNELS diff --git a/libavcodec/xvmc.h b/libavcodec/xvmc.h index cdec161c80..1f77e4efca 100644 --- a/libavcodec/xvmc.h +++ b/libavcodec/xvmc.h @@ -147,7 +147,7 @@ struct xvmc_pix_fmt { */ int filled_mv_blocks_num; - /** Number of the the next free data block; one data block consists of + /** Number of the next free data block; one data block consists of 64 short values in the data_blocks array. All blocks before this one have already been claimed by placing their position into the corresponding block description structure field, diff --git a/libavfilter/version.h b/libavfilter/version.h index 0f4353fea9..56ebc27dfd 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -41,7 +41,7 @@ #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT /** - * Those FF_API_* defines are not part of public API. + * These FF_API_* defines are not part of the public API. * They may change, break or disappear at any time. */ #ifndef FF_API_AVFILTERPAD_PUBLIC diff --git a/libavformat/rtp.h b/libavformat/rtp.h index e9f87782fa..0ffe18fd84 100644 --- a/libavformat/rtp.h +++ b/libavformat/rtp.h @@ -77,7 +77,7 @@ enum CodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type); #define RTCP_TX_RATIO_DEN 1000 /* An arbitrary id value for RTP Xiph streams - only relevant to indicate - * the the configuration has changed within a stream (by changing the + * that the configuration has changed within a stream (by changing the * ident value sent). */ #define RTP_XIPH_IDENT 0xfecdba diff --git a/libavformat/version.h b/libavformat/version.h index e2fa56188b..26bb2c596e 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -44,7 +44,7 @@ #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) /** - * Those FF_API_* defines are not part of public API. + * These FF_API_* defines are not part of the public API. * They may change, break or disappear at any time. */ #ifndef FF_API_CLOSE_INPUT_FILE diff --git a/tools/patcheck b/tools/patcheck index b3943c5d7c..78ca8246f7 100755 --- a/tools/patcheck +++ b/tools/patcheck @@ -67,7 +67,7 @@ $EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^ cat $TMP hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $* -hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention)\b' 'common typos' $* +hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention|acheive)\b' 'common typos' $* hiegrep 'av_log\( *NULL' 'Missing context in av_log' $* hiegrep '[^sn]printf' 'Please use av_log' $* From 4051be6f50ff6a089195809cfdc872457b49ab02 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 2 Jul 2012 20:40:26 +0200 Subject: [PATCH 12/13] anm: fix a few Doxygen comments --- libavcodec/anm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/anm.c b/libavcodec/anm.c index b86b7c0ffb..d979ba4323 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -55,8 +55,9 @@ static av_cold int decode_init(AVCodecContext *avctx) /** * Perform decode operation - * @param dst, dst_end Destination image buffer - * @param gb, GetByteContext (optional, see below) + * @param dst pointer to destination image buffer + * @param dst_end pointer to end of destination image buffer + * @param gb GetByteContext (optional, see below) * @param pixel Fill color (optional, see below) * @param count Pixel count * @param x Pointer to x-axis counter From 1a068bfefd5da09f596e5079b39b418933bad0ea Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 2 Jul 2012 10:17:07 +0200 Subject: [PATCH 13/13] cosmetics: Consistently use C-style comments with multiple inclusion guards --- libavfilter/formats.h | 2 +- libavfilter/version.h | 2 +- libavutil/dict.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 4f95c16262..0e1628c850 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -218,4 +218,4 @@ void ff_formats_unref(AVFilterFormats **ref); */ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref); -#endif // AVFILTER_FORMATS_H +#endif /* AVFILTER_FORMATS_H */ diff --git a/libavfilter/version.h b/libavfilter/version.h index 56ebc27dfd..88bdd4a821 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -51,4 +51,4 @@ #define FF_API_FOO_COUNT (LIBAVFILTER_VERSION_MAJOR < 4) #endif -#endif // AVFILTER_VERSION_H +#endif /* AVFILTER_VERSION_H */ diff --git a/libavutil/dict.h b/libavutil/dict.h index fd53036dd0..aa07626535 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -118,4 +118,4 @@ void av_dict_free(AVDictionary **m); * @} */ -#endif // AVUTIL_DICT_H +#endif /* AVUTIL_DICT_H */