From 117f79de2d0cbae22d997c79ea442ee139e8dcf6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 23 Dec 2012 18:43:19 +0100 Subject: [PATCH 1/3] truemotion2: Sanitize tm2_read_header() Also give a variable a more sensible name. --- libavcodec/truemotion2.c | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 5b441e11eb..2d7a5102c2 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -200,27 +200,23 @@ static inline int tm2_get_token(GetBitContext *gb, TM2Codes *code) return code->recode[val]; } +#define TM2_OLD_HEADER_MAGIC 0x00000100 +#define TM2_NEW_HEADER_MAGIC 0x00000101 + static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf) { - uint32_t magic; - const uint8_t *obuf; + uint32_t magic = AV_RL32(buf); - obuf = buf; - - magic = AV_RL32(buf); - buf += 4; - - if(magic == 0x00000100) { /* old header */ + switch (magic) { + case TM2_OLD_HEADER_MAGIC: av_log_missing_feature(ctx->avctx, "TM2 old header", 1); - return 40; - } else if(magic == 0x00000101) { /* new header */ - return 40; - } else { - av_log (ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic); - return -1; + return 0; + case TM2_NEW_HEADER_MAGIC: + return 0; + default: + av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic); + return AVERROR_INVALIDDATA; } - - return buf - obuf; } static int tm2_read_deltas(TM2Context *ctx, int stream_id) { @@ -810,6 +806,8 @@ static const int tm2_stream_order[TM2_NUM_STREAMS] = { TM2_C_HI, TM2_C_LO, TM2_L_HI, TM2_L_LO, TM2_UPD, TM2_MOT, TM2_TYPE }; +#define TM2_HEADER_SIZE 40 + static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) @@ -818,7 +816,7 @@ static int decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size & ~3; TM2Context * const l = avctx->priv_data; AVFrame * const p = &l->pic; - int i, skip, t; + int i, offset = TM2_HEADER_SIZE, t, ret; uint8_t *swbuf; swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); @@ -835,24 +833,24 @@ static int decode_frame(AVCodecContext *avctx, } l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2); - skip = tm2_read_header(l, swbuf); - if(skip == -1){ + if ((ret = tm2_read_header(l, swbuf)) < 0) { av_free(swbuf); - return -1; + return ret; } for(i = 0; i < TM2_NUM_STREAMS; i++){ - if (skip >= buf_size) { + if (offset >= buf_size) { av_free(swbuf); return AVERROR_INVALIDDATA; } - t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i], buf_size - skip); + t = tm2_read_stream(l, swbuf + offset, tm2_stream_order[i], + buf_size - offset); if(t < 0){ av_free(swbuf); return t; } - skip += t; + offset += t; } p->key_frame = tm2_decode_blocks(l, p); if(p->key_frame) From bcb8d9eb8ff6e8f1e4c02d0143407373cffdbdeb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 31 Dec 2012 00:29:36 +0100 Subject: [PATCH 2/3] Drop unnecessary 'l' length modifier when printfing double values. %f denotes a double argument and 'l' does nothing in this case according to the C spec. --- libavfilter/vf_frei0r.c | 2 +- libavfilter/vf_hqdn3d.c | 2 +- libavfilter/vsrc_movie.c | 2 +- libavutil/opt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index fd053906ce..955d0b9f83 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -189,7 +189,7 @@ static int set_params(AVFilterContext *ctx, const char *params) case F0R_PARAM_POSITION: v = &pos; frei0r->get_param_value(frei0r->instance, v, i); - av_log(ctx, AV_LOG_DEBUG, "%lf/%lf", pos.x, pos.y); + av_log(ctx, AV_LOG_DEBUG, "%f/%f", pos.x, pos.y); break; default: /* F0R_PARAM_STRING */ v = s; diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 7365b8d502..085900fbce 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -236,7 +236,7 @@ static int init(AVFilterContext *ctx, const char *args) hqdn3d->strength[2] = chrom_spac; hqdn3d->strength[3] = chrom_tmp; - av_log(ctx, AV_LOG_VERBOSE, "ls:%lf cs:%lf lt:%lf ct:%lf\n", + av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\n", lum_spac, chrom_spac, lum_tmp, chrom_tmp); if (lum_spac < 0 || chrom_spac < 0 || isnan(chrom_tmp)) { av_log(ctx, AV_LOG_ERROR, diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index e6185d686e..0023d55bbc 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -255,7 +255,7 @@ static int movie_get_frame(AVFilterLink *outlink) if (!movie->frame->sample_aspect_ratio.num) movie->picref->video->pixel_aspect = st->sample_aspect_ratio; av_dlog(outlink->src, - "movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n", + "movie_get_frame(): file:'%s' pts:%"PRId64" time:%f pos:%"PRId64" aspect:%d/%d\n", movie->file_name, movie->picref->pts, (double)movie->picref->pts * av_q2d(st->time_base), movie->picref->pos, diff --git a/libavutil/opt.c b/libavutil/opt.c index 8a98a9ef55..04f441338d 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -62,7 +62,7 @@ static int read_number(const AVOption *o, void *dst, double *num, int *den, int6 static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum) { if (o->max*den < num*intnum || o->min*den > num*intnum) { - av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", + av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n", num*intnum/den, o->name); return AVERROR(ERANGE); } From 506409776c49910050f3150d0e51d11b44d323ed Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 30 Oct 2012 22:57:37 +0100 Subject: [PATCH 3/3] configure: suppress -fPIC in msvc builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MSVC doesn't understand the option, and emits a warning on every call to cl.exe. Signed-off-by: Martin Storsjö --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 0ede1d53c3..e87a3261de 100755 --- a/configure +++ b/configure @@ -2187,6 +2187,7 @@ msvc_flags(){ -fno-math-errno) ;; -fno-common) ;; -fno-signed-zeros) ;; + -fPIC) ;; -lz) echo zlib.lib ;; -lavifil32) echo vfw32.lib ;; -lavicap32) echo vfw32.lib user32.lib ;;