annotate libmpcodecs/mp_image.c @ 30245:bef93e623403

Make sure that sfence is used after any non temporal stores.
author zuxy
date Tue, 12 Jan 2010 02:34:33 +0000
parents ad61464d02a7
children bbb6ebec87a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
17 void mp_image_alloc_planes(mp_image_t *mpi) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
18 // IF09 - allocate space for 4. plane delta info - unused
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
19 if (mpi->imgfmt == IMGFMT_IF09) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
20 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
21 mpi->chroma_width*mpi->chroma_height);
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
22 } else
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
23 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
24 if (mpi->flags&MP_IMGFLAG_PLANAR) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
25 int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
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
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
28 if(mpi->num_planes > 2){
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
29 mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
30 if(mpi->flags&MP_IMGFLAG_SWAPPED){
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
31 // I420/IYUV (Y,U,V)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
32 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
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
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
36 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
37 // YV12,YVU9,IF09 (Y,V,U)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
38 mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
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
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
42 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
43 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
44 // NV12/NV21
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
45 mpi->stride[1]=mpi->chroma_width;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
46 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
47 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
48 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
49 mpi->stride[0]=mpi->width*mpi->bpp/8;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
50 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
51 mpi->planes[1] = memalign(64, 1024);
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
52 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
53 mpi->flags|=MP_IMGFLAG_ALLOCATED;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
54 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
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
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
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 }