aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-05-07 16:31:02 +0200
committerClément Bœsch <ubitux@gmail.com>2013-05-09 16:59:42 +0200
commit570d63eef3f911869672cd20fa9c2abedb11093d (patch)
tree2b993b08de62362e2e59e8049e28a92e6c2bb0af /libavutil
parentd9cb1e0e15e5cabb0b36f10cba079ea6532ed8e7 (diff)
downloadffmpeg-570d63eef3f911869672cd20fa9c2abedb11093d.tar.gz
lavu: add FF_CEIL_RSHIFT and use it in various places.
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/common.h2
-rw-r--r--libavutil/frame.c2
-rw-r--r--libavutil/imgutils.c2
3 files changed, 4 insertions, 2 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index 13f2ffbd11..9091070a01 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -48,6 +48,8 @@
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
/* assume b>0 */
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
+/* assume a>0 and b>0 */
+#define FF_CEIL_RSHIFT(a,b) (-((-(a)) >> (b)))
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
diff --git a/libavutil/frame.c b/libavutil/frame.c
index ca6814ce27..d50e9b2569 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -138,7 +138,7 @@ static int get_video_buffer(AVFrame *frame, int align)
for (i = 0; i < 4 && frame->linesize[i]; i++) {
int h = FFALIGN(frame->height, 32);
if (i == 1 || i == 2)
- h = -((-h) >> desc->log2_chroma_h);
+ h = FF_CEIL_RSHIFT(h, desc->log2_chroma_h);
frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h + 16);
if (!frame->buf[i])
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 3060b0705f..45d8ebe7df 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -284,7 +284,7 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
return;
}
if (i == 1 || i == 2) {
- h= -((-height)>>desc->log2_chroma_h);
+ h = FF_CEIL_RSHIFT(height, desc->log2_chroma_h);
}
av_image_copy_plane(dst_data[i], dst_linesizes[i],
src_data[i], src_linesizes[i],