Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.c @ 30319:841a6029e259
Remove duplicated or pointless newlines.
author | stefano |
---|---|
date | Sun, 17 Jan 2010 23:17:47 +0000 |
parents | ad61464d02a7 |
children | bbb6ebec87a0 |
rev | line source |
---|---|
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
1 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
2 #include "config.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
3 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
4 #include <stdio.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
5 #include <stdlib.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
6 #include <string.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
7 |
28594
df67d03dde3b
Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents:
23994
diff
changeset
|
8 #if HAVE_MALLOC_H |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
9 #include <malloc.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
10 #endif |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
11 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
12 #include "libmpcodecs/img_format.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
13 #include "libmpcodecs/mp_image.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
14 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
15 #include "libvo/fastmemcpy.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
16 |
30112 | 17 void mp_image_alloc_planes(mp_image_t *mpi) { |
18 // IF09 - allocate space for 4. plane delta info - unused | |
19 if (mpi->imgfmt == IMGFMT_IF09) { | |
20 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+ | |
21 mpi->chroma_width*mpi->chroma_height); | |
22 } else | |
23 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8); | |
24 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
25 int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1; | |
26 // YV12/I420/YVU9/IF09. feel free to add other planar formats here... | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
27 mpi->stride[0]=mpi->stride[3]=bpp*mpi->width; |
30112 | 28 if(mpi->num_planes > 2){ |
29 mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width; | |
30 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
31 // I420/IYUV (Y,U,V) | |
32 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
33 mpi->planes[2]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height; | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
34 if (mpi->num_planes > 3) |
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
35 mpi->planes[3]=mpi->planes[2]+mpi->stride[2]*mpi->chroma_height; |
30112 | 36 } else { |
37 // YV12,YVU9,IF09 (Y,V,U) | |
38 mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
39 mpi->planes[1]=mpi->planes[2]+mpi->stride[1]*mpi->chroma_height; | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
40 if (mpi->num_planes > 3) |
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
41 mpi->planes[3]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height; |
30112 | 42 } |
43 } else { | |
44 // NV12/NV21 | |
45 mpi->stride[1]=mpi->chroma_width; | |
46 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
47 } | |
48 } else { | |
49 mpi->stride[0]=mpi->width*mpi->bpp/8; | |
50 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) | |
51 mpi->planes[1] = memalign(64, 1024); | |
52 } | |
53 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
54 } | |
55 | |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
56 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt) { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
57 mp_image_t* mpi = new_mp_image(w,h); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
58 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
59 mp_image_setfmt(mpi,fmt); |
30112 | 60 mp_image_alloc_planes(mpi); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
61 |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
62 return mpi; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
63 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
64 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
65 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi) { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
66 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
67 memcpy_pic(dmpi->planes[0],mpi->planes[0], mpi->w, mpi->h, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
68 dmpi->stride[0],mpi->stride[0]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
69 memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->chroma_width, mpi->chroma_height, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
70 dmpi->stride[1],mpi->stride[1]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
71 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->chroma_width, mpi->chroma_height, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
72 dmpi->stride[2],mpi->stride[2]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
73 } else { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
74 memcpy_pic(dmpi->planes[0],mpi->planes[0], |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
75 mpi->w*(dmpi->bpp/8), mpi->h, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
76 dmpi->stride[0],mpi->stride[0]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
77 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
78 } |