Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.c @ 26742:0c1db5fd3f79
Use standard license headers with standard formatting.
author | diego |
---|---|
date | Wed, 14 May 2008 18:01:51 +0000 |
parents | 8572d2ef5263 |
children | df67d03dde3b |
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 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
8 #ifdef HAVE_MALLOC_H |
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 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
17 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
|
18 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
|
19 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
20 mp_image_setfmt(mpi,fmt); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
21 // IF09 - allocate space for 4. plane delta info - unused |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
22 if (mpi->imgfmt == IMGFMT_IF09) |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
23 { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
24 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+ |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
25 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
|
26 /* delta table, just for fun ;) */ |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
27 mpi->planes[3]=mpi->planes[0]+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
|
28 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
29 else |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
30 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
31 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
|
32 // YV12/I420/YVU9/IF09. feel free to add other planar formats here... |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
33 if(!mpi->stride[0]) mpi->stride[0]=mpi->width; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
34 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->chroma_width; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
35 if(mpi->flags&MP_IMGFLAG_SWAPPED){ |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
36 // I420/IYUV (Y,U,V) |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
37 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
38 mpi->planes[2]=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
|
39 } else { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
40 // YV12,YVU9,IF09 (Y,V,U) |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
41 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
42 mpi->planes[1]=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
|
43 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
44 } else { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
45 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
46 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
47 mpi->flags|=MP_IMGFLAG_ALLOCATED; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
48 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
49 return mpi; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
50 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
51 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 } else { |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
61 memcpy_pic(dmpi->planes[0],mpi->planes[0], |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
62 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
|
63 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
|
64 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
65 } |