From d0989bed226578a8f37ca90c78abc97abafb9794 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 13:36:35 +0100 Subject: [PATCH 01/13] Fix error check in av_file_map() On failure, mmap() returns MAP_FAILED, which may or may not be -1. Signed-off-by: Mans Rullgard --- libavutil/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/file.c b/libavutil/file.c index 3dcce7c2f8..f0e48b5b2f 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -75,7 +75,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, #if HAVE_MMAP ptr = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - if ((int)(ptr) == -1) { + if (ptr == MAP_FAILED) { err = AVERROR(errno); av_strerror(err, errbuf, sizeof(errbuf)); av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in mmap(): %s\n", errbuf); From 91b4941c17bcf6bd4a0cfc7feb6d7c46868db433 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 16:43:41 +0100 Subject: [PATCH 02/13] musepack: remove extraneous mpcdata.h inclusions Signed-off-by: Mans Rullgard --- libavcodec/mpc.h | 2 -- libavcodec/mpc8.c | 1 - 2 files changed, 3 deletions(-) diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index eea4b6df36..f73c658f7d 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -35,8 +35,6 @@ #include "dsputil.h" #include "mpegaudio.h" -#include "mpcdata.h" - #define BANDS 32 #define SAMPLES_PER_BAND 36 #define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND) diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 81de9cf500..3177faf1c4 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -33,7 +33,6 @@ #include "libavutil/audioconvert.h" #include "mpc.h" -#include "mpcdata.h" #include "mpc8data.h" #include "mpc8huff.h" From 67ace7f0473ff968c7c615796b7a95c90fde68d2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 16:45:15 +0100 Subject: [PATCH 03/13] musepack: remove unnecessary #include from mpcdata.h Signed-off-by: Mans Rullgard --- libavcodec/mpcdata.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/mpcdata.h b/libavcodec/mpcdata.h index ad06b7abca..397dad59d8 100644 --- a/libavcodec/mpcdata.h +++ b/libavcodec/mpcdata.h @@ -22,8 +22,6 @@ #ifndef AVCODEC_MPCDATA_H #define AVCODEC_MPCDATA_H -#include - static const float mpc_CC[18] = { 65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, 2114.0645, 1040.2539, 516.0315, 257.0039, 128.2505, 64.0626, 32.0156, 16.0039, 8.0010, From 8d459acc10d865a82b1646f91a85ae99d998faa7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 4 Jun 2011 16:58:31 +0200 Subject: [PATCH 04/13] Add missing #includes to make headers self-contained. This fixes 'make checkheaders'. --- libavcodec/mathops.h | 1 + libavcodec/mpc.h | 1 + libavcodec/mpegaudiodectab.h | 2 ++ libavcodec/put_bits.h | 1 + libavcodec/tableprint.h | 2 -- libavformat/network.h | 3 +++ 6 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index d74bc1ed70..98c9acf5ce 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -23,6 +23,7 @@ #define AVCODEC_MATHOPS_H #include "libavutil/common.h" +#include "config.h" #if ARCH_ARM # include "arm/mathops.h" diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index f73c658f7d..6d0f7b45bb 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -34,6 +34,7 @@ #include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" +#include "mpegaudiodsp.h" #define BANDS 32 #define SAMPLES_PER_BAND 36 diff --git a/libavcodec/mpegaudiodectab.h b/libavcodec/mpegaudiodectab.h index 041d1860b7..1221657988 100644 --- a/libavcodec/mpegaudiodectab.h +++ b/libavcodec/mpegaudiodectab.h @@ -27,7 +27,9 @@ #ifndef AVCODEC_MPEGAUDIODECTAB_H #define AVCODEC_MPEGAUDIODECTAB_H +#include #include + #include "mpegaudio.h" /*******************************************************/ diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index c426540291..3849e6d339 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -34,6 +34,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "mathops.h" +#include "config.h" //#define ALT_BITSTREAM_WRITER //#define ALIGNED_BITSTREAM_WRITER diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index ddf2635da0..de355fc0aa 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -26,8 +26,6 @@ #include #include -#include "libavutil/common.h" - #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ void write_##type##_array(const type *data, int len)\ {\ diff --git a/libavformat/network.h b/libavformat/network.h index db8466ce20..80d094a0de 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -21,7 +21,10 @@ #ifndef AVFORMAT_NETWORK_H #define AVFORMAT_NETWORK_H +#include + #include "config.h" +#include "libavutil/error.h" #include "os_support.h" #if HAVE_WINSOCK2_H From 61ec024d39cc53672901791923e9cb1bd0fda9f3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 4 Jun 2011 18:02:40 +0200 Subject: [PATCH 05/13] Skip headers not designed to work standalone during 'make checkheaders'. --- libavcodec/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca5839f2af..77f285eda0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -651,7 +651,8 @@ OBJS-$(!CONFIG_SMALL) += inverse.o -include $(SUBDIR)$(ARCH)/Makefile -SKIPHEADERS = %_tablegen.h +SKIPHEADERS += %_tablegen.h aac_tablegen_decl.h \ + fft-internal.h $(ARCH)/vp56_arith.h SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h From 42abb9a80da16d33ef7f54c3656b4d9524d03435 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 16:47:15 +0100 Subject: [PATCH 06/13] cmdutils: add missing const qualifier Signed-off-by: Mans Rullgard --- cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdutils.c b/cmdutils.c index 31866b5563..b9a5d1b069 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -323,7 +323,7 @@ int opt_default(const char *opt, const char *arg){ AVCodec *p = NULL; AVOutputFormat *oformat = NULL; while ((p=av_codec_next(p))){ - AVClass *c= p->priv_class; + const AVClass *c = p->priv_class; if(c && av_find_opt(&c, opt, NULL, 0, 0)) break; } From 1572484f62c59da6755fbcebf09821ada8c43728 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 3 Jun 2011 13:11:39 +0200 Subject: [PATCH 07/13] bktr: don't error when AVFormatParameters.time_base isn't set. There's a private option for it now. --- libavdevice/bktr.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 7cae48f5fd..6e19a61103 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -251,11 +251,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) AVRational fps; int ret = 0; - if (ap->time_base.den <= 0) { - ret = AVERROR(EINVAL); - goto out; - } - #if FF_API_FORMAT_PARAMETERS if (ap->standard) { if (!strcasecmp(ap->standard, "pal")) From a3b15e411d9624a37919e91fe81aec9c98457ed8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 3 Jun 2011 13:29:43 +0200 Subject: [PATCH 08/13] fbdev,v4l2: remove some forgotten uses of AVFormatParameters.time_base. --- libavdevice/fbdev.c | 2 +- libavdevice/v4l2.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 58b3ab4572..7e9ffe5c77 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -169,7 +169,7 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->width = fbdev->width; st->codec->height = fbdev->heigth; st->codec->pix_fmt = pix_fmt; - st->codec->time_base = ap->time_base; + st->codec->time_base = (AVRational){fbdev->fps.den, fbdev->fps.num}; st->codec->bit_rate = fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->fps) * 8; diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 0cd4f38389..98ff82ec0d 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -546,6 +546,8 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) return AVERROR(errno); } } + s1->streams[0]->codec->time_base.den = tpf->denominator; + s1->streams[0]->codec->time_base.num = tpf->numerator; return 0; } @@ -679,8 +681,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec->codec_id = codec_id; st->codec->width = s->width; st->codec->height = s->height; - st->codec->time_base.den = ap->time_base.den; - st->codec->time_base.num = ap->time_base.num; st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8; out: From ff494cbdafbaee57275e9227a8a2aff02184c346 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 3 Jun 2011 13:36:36 +0200 Subject: [PATCH 09/13] x11grab: add framerate private option. --- libavdevice/x11grab.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index d4fcbca873..b1ca6e699a 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -71,6 +71,7 @@ struct x11_grab int use_shm; /**< !0 when using XShm extension */ XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */ int nomouse; + char *framerate; /**< Set by a private option. */ }; /** @@ -97,6 +98,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) int use_shm; char *param, *offset; int ret = 0; + AVRational framerate; param = av_strdup(s1->filename); offset = strchr(param, '+'); @@ -110,11 +112,17 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto out; } + if ((ret = av_parse_video_rate(&framerate, x11grab->framerate)) < 0) { + av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s.\n", x11grab->framerate); + goto out; + } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) x11grab->width = ap->width; if (ap->height > 0) x11grab->height = ap->height; + if (ap->time_base.num) + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", s1->filename, param, x_off, y_off, x11grab->width, x11grab->height); @@ -126,12 +134,6 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) goto out; } - if (ap->time_base.den <= 0) { - av_log(s1, AV_LOG_ERROR, "AVParameters don't have video size and/or rate. Use -s and -r.\n"); - ret = AVERROR(EINVAL); - goto out; - } - st = av_new_stream(s1, 0); if (!st) { ret = AVERROR(ENOMEM); @@ -240,8 +242,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) x11grab->frame_size = x11grab->width * x11grab->height * image->bits_per_pixel/8; x11grab->dpy = dpy; - x11grab->time_base = ap->time_base; - x11grab->time_frame = av_gettime() / av_q2d(ap->time_base); + x11grab->time_base = (AVRational){framerate.den, framerate.num}; + x11grab->time_frame = av_gettime() / av_q2d(x11grab->time_base); x11grab->x_off = x_off; x11grab->y_off = y_off; x11grab->image = image; @@ -252,11 +254,12 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec->width = x11grab->width; st->codec->height = x11grab->height; st->codec->pix_fmt = input_pixfmt; - st->codec->time_base = ap->time_base; - st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(ap->time_base) * 8; + st->codec->time_base = x11grab->time_base; + st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(x11grab->time_base) * 8; out: av_freep(&x11grab->video_size); + av_freep(&x11grab->framerate); return ret; } @@ -468,6 +471,7 @@ x11grab_read_close(AVFormatContext *s1) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; From e762b1ce9505511b1ecbbd4868ec6879e32e8831 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 3 Jun 2011 14:13:14 +0200 Subject: [PATCH 10/13] rawdec: add framerate private option. --- libavformat/ingenientdec.c | 3 ++- libavformat/rawdec.c | 48 ++++++++++++++++++++++++-------------- libavformat/rawdec.h | 3 +++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c index 7407a04dd9..febeb2ec35 100644 --- a/libavformat/ingenientdec.c +++ b/libavformat/ingenientdec.c @@ -61,11 +61,12 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt) AVInputFormat ff_ingenient_demuxer = { "ingenient", NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"), - 0, + sizeof(FFRawVideoDemuxerContext), NULL, ff_raw_video_read_header, ingenient_read_packet, .flags= AVFMT_GENERIC_INDEX, .extensions = "cgi", // FIXME .value = CODEC_ID_MJPEG, + .priv_class = &ff_rawvideo_demuxer_class, }; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 3d8125f42c..a92200d844 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -72,11 +72,8 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) FFRawVideoDemuxerContext *s1 = s->priv_data; int width = 0, height = 0, ret = 0; enum PixelFormat pix_fmt; + AVRational framerate; - if(ap->time_base.num) - av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); - else - av_set_pts_info(st, 64, 1, 25); if (s1->video_size && (ret = av_parse_video_size(&width, &height, s1->video_size)) < 0) { av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto fail; @@ -86,6 +83,10 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) ret = AVERROR(EINVAL); goto fail; } + if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) { + av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate); + goto fail; + } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) width = ap->width; @@ -93,13 +94,17 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) height = ap->height; if (ap->pix_fmt) pix_fmt = ap->pix_fmt; + if (ap->time_base.num) + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif + av_set_pts_info(st, 64, framerate.den, framerate.num); st->codec->width = width; st->codec->height = height; st->codec->pix_fmt = pix_fmt; fail: av_freep(&s1->video_size); av_freep(&s1->pixel_format); + av_freep(&s1->framerate); return ret; } default: @@ -149,30 +154,36 @@ int ff_raw_video_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; + FFRawVideoDemuxerContext *s1 = s->priv_data; + AVRational framerate; + int ret = 0; + st = av_new_stream(s, 0); - if (!st) - return AVERROR(ENOMEM); + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s->iformat->value; st->need_parsing = AVSTREAM_PARSE_FULL; - /* for MJPEG, specify frame rate */ - /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/ - if (ap->time_base.num) { - st->codec->time_base= ap->time_base; - } else if ( st->codec->codec_id == CODEC_ID_MJPEG || - st->codec->codec_id == CODEC_ID_MPEG4 || - st->codec->codec_id == CODEC_ID_DIRAC || - st->codec->codec_id == CODEC_ID_DNXHD || - st->codec->codec_id == CODEC_ID_VC1 || - st->codec->codec_id == CODEC_ID_H264) { - st->codec->time_base= (AVRational){1,25}; + if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) { + av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate); + goto fail; } +#if FF_API_FORMAT_PARAMETERS + if (ap->time_base.num) + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; +#endif + + st->codec->time_base = (AVRational){framerate.den, framerate.num}; av_set_pts_info(st, 64, 1, 1200000); - return 0; +fail: + av_freep(&s1->framerate); + return ret; } /* Note: Do not forget to add new entries to the Makefile as well. */ @@ -195,6 +206,7 @@ const AVClass ff_rawaudio_demuxer_class = { static const AVOption video_options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; #undef OFFSET diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h index 4968915cc6..76e8053f6d 100644 --- a/libavformat/rawdec.h +++ b/libavformat/rawdec.h @@ -35,6 +35,7 @@ typedef struct FFRawVideoDemuxerContext { const AVClass *class; /**< Class for private options. */ char *video_size; /**< String describing video size, set by a private option. */ char *pixel_format; /**< Set by a private option. */ + char *framerate; /**< String describing framerate, set by a private option. */ } FFRawVideoDemuxerContext; extern const AVClass ff_rawaudio_demuxer_class; @@ -58,6 +59,8 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\ .extensions = ext,\ .flags = AVFMT_GENERIC_INDEX,\ .value = id,\ + .priv_data_size = sizeof(FFRawVideoDemuxerContext),\ + .priv_class = &ff_rawvideo_demuxer_class,\ }; #endif /* AVFORMAT_RAWDEC_H */ From 8346f60afbb23b9a3dcef8e6683060f71ec296e2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 3 Jun 2011 20:43:48 +0200 Subject: [PATCH 11/13] tty: factorise returning error codes. --- libavformat/tty.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libavformat/tty.c b/libavformat/tty.c index 432fcc0c3d..9dada16b8a 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -73,21 +73,20 @@ static int read_header(AVFormatContext *avctx, AVFormatParameters *ap) { TtyDemuxContext *s = avctx->priv_data; - int width = 0, height = 0, ret; + int width = 0, height = 0, ret = 0; AVStream *st = av_new_stream(avctx, 0); - if (!st) - return AVERROR(ENOMEM); + + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } st->codec->codec_tag = 0; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_ANSI; - if (s->video_size) { - ret = av_parse_video_size(&width, &height, s->video_size); - av_freep(&s->video_size); - if (ret < 0) { - av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n"); - return ret; - } + if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { + av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n"); + goto fail; } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) @@ -121,7 +120,9 @@ static int read_header(AVFormatContext *avctx, avio_seek(avctx->pb, 0, SEEK_SET); } - return 0; +fail: + av_freep(&s->video_size); + return ret; } static int read_packet(AVFormatContext *avctx, AVPacket *pkt) From 95912731c2eb37b538a767b2ff2b8149b16f0bde Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 17:52:30 +0100 Subject: [PATCH 12/13] mathops: use MUL64 macro where it forms part of other ops Signed-off-by: Mans Rullgard --- libavcodec/mathops.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 98c9acf5ce..ec76eaae29 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -41,13 +41,17 @@ /* generic implementation */ +#ifndef MUL64 +# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) +#endif + #ifndef MULL -# define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) +# define MULL(a,b,s) (MUL64(a, b) >> (s)) #endif #ifndef MULH static av_always_inline int MULH(int a, int b){ - return ((int64_t)(a) * (int64_t)(b))>>32; + return MUL64(a, b) >> 32; } #endif @@ -57,10 +61,6 @@ static av_always_inline unsigned UMULH(unsigned a, unsigned b){ } #endif -#ifndef MUL64 -# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) -#endif - #ifndef MAC64 # define MAC64(d, a, b) ((d) += MUL64(a, b)) #endif From 594fbe42c6b21aef76b938ce97524fa92a48e7a0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 4 Jun 2011 21:16:04 +0100 Subject: [PATCH 13/13] ARM: remove MULL inline asm Reasonable gcc versions get this one right on their own. Signed-off-by: Mans Rullgard --- libavcodec/arm/mathops.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libavcodec/arm/mathops.h b/libavcodec/arm/mathops.h index 7c2acca2e8..3870fce3e2 100644 --- a/libavcodec/arm/mathops.h +++ b/libavcodec/arm/mathops.h @@ -28,18 +28,6 @@ #if HAVE_INLINE_ASM -# define MULL MULL -static inline av_const int MULL(int a, int b, unsigned shift) -{ - int lo, hi; - __asm__("smull %0, %1, %2, %3 \n\t" - "mov %0, %0, lsr %4 \n\t" - "add %1, %0, %1, lsl %5 \n\t" - : "=&r"(lo), "=&r"(hi) - : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift)); - return hi; -} - #define MULH MULH #define MUL64 MUL64