annotate libmpcodecs/mp_image.c @ 30729:9553ab9ca41c

Remove unused static function play_tree_set_flag().
author cehoyos
date Sat, 27 Feb 2010 20:55:41 +0000
parents bbb6ebec87a0
children 6e9ece21c004
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30115
diff changeset
17 */
23994
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
18
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
19 #include "config.h"
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
20
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
21 #include <stdio.h>
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
22 #include <stdlib.h>
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
23 #include <string.h>
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
24
28594
df67d03dde3b Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents: 23994
diff changeset
25 #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
26 #include <malloc.h>
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
27 #endif
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 #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
30 #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
31
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
32 #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
33
30112
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
34 void mp_image_alloc_planes(mp_image_t *mpi) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
35 // IF09 - allocate space for 4. plane delta info - unused
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
36 if (mpi->imgfmt == IMGFMT_IF09) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
37 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
38 mpi->chroma_width*mpi->chroma_height);
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
39 } else
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
40 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
41 if (mpi->flags&MP_IMGFLAG_PLANAR) {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
42 int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
43 // 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
44 mpi->stride[0]=mpi->stride[3]=bpp*mpi->width;
30112
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
45 if(mpi->num_planes > 2){
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
46 mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
47 if(mpi->flags&MP_IMGFLAG_SWAPPED){
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
48 // I420/IYUV (Y,U,V)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
49 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
50 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
51 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
52 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
53 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
54 // YV12,YVU9,IF09 (Y,V,U)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
55 mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
56 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
57 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
58 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
59 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
60 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
61 // NV12/NV21
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
62 mpi->stride[1]=mpi->chroma_width;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
63 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
64 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
65 } else {
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
66 mpi->stride[0]=mpi->width*mpi->bpp/8;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
67 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
68 mpi->planes[1] = memalign(64, 1024);
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
69 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
70 mpi->flags|=MP_IMGFLAG_ALLOCATED;
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
71 }
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
72
23994
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
73 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
74 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
75
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
76 mp_image_setfmt(mpi,fmt);
30112
c26218c27e73 Deduplicate the mp_image planes allocation code.
reimar
parents: 30110
diff changeset
77 mp_image_alloc_planes(mpi);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
78
23994
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
79 return mpi;
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
80 }
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
81
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 } else {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
91 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
92 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
93 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
94 }
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff changeset
95 }