summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/img_format.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-30 11:08:44 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-30 11:08:44 +0000
commit92f20f876f7efac016d9b69aa01fe3d2f0fc6f68 (patch)
tree6ff28373a4f412ce4e63a733117cb6631c917af7 /libmpcodecs/img_format.c
parent427039acff27c8d9b605d9b807d6f3a2c15830aa (diff)
downloadmpv-92f20f876f7efac016d9b69aa01fe3d2f0fc6f68.tar.bz2
mpv-92f20f876f7efac016d9b69aa01fe3d2f0fc6f68.tar.xz
Add a helper function to get the chroma scale shift and use to simplify mpi setup.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30138 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/img_format.c')
-rw-r--r--libmpcodecs/img_format.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c
index 2c83a643f7..d4f4d59f38 100644
--- a/libmpcodecs/img_format.c
+++ b/libmpcodecs/img_format.c
@@ -79,3 +79,40 @@ const char *vo_format_name(int format)
snprintf(unknown_format,20,"Unknown 0x%04x",format);
return unknown_format;
}
+
+int mp_get_chroma_shift(int format, int *x_shift, int *y_shift)
+{
+ int xs = 0, ys = 0;
+ int err = 0;
+ switch (format) {
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ case IMGFMT_YV12:
+ xs = 1;
+ ys = 1;
+ break;
+ case IMGFMT_IF09:
+ case IMGFMT_YVU9:
+ xs = 2;
+ ys = 2;
+ break;
+ case IMGFMT_444P:
+ xs = 0;
+ ys = 0;
+ break;
+ case IMGFMT_422P:
+ xs = 1;
+ ys = 0;
+ break;
+ case IMGFMT_411P:
+ xs = 2;
+ ys = 0;
+ break;
+ default:
+ err = 1;
+ break;
+ }
+ if (x_shift) *x_shift = xs;
+ if (y_shift) *y_shift = ys;
+ return err ? 0 : 8 + (16 >> (xs + ys));
+}