Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.c @ 36327:797bbffdd112
vo png: Switch to avcodec_encode_video2
The older function is deprecated and the newer function seems to not
have the minimum buffer size limitation.
Patch by Jiang Jiang >gzjjgod at gmail com<
author | al |
---|---|
date | Wed, 14 Aug 2013 10:16:46 +0000 |
parents | 72818542220d |
children | 5ae43d2a425d |
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 #include "libvo/fastmemcpy.h" |
31003
00825525514e
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents:
30996
diff
changeset
|
32 #include "libavutil/mem.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
34157
diff
changeset
|
33 #include "mp_msg.h" |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
34 |
30112 | 35 void mp_image_alloc_planes(mp_image_t *mpi) { |
36 // IF09 - allocate space for 4. plane delta info - unused | |
37 if (mpi->imgfmt == IMGFMT_IF09) { | |
31003
00825525514e
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents:
30996
diff
changeset
|
38 mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+ |
30112 | 39 mpi->chroma_width*mpi->chroma_height); |
40 } else | |
31003
00825525514e
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents:
30996
diff
changeset
|
41 mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8); |
30112 | 42 if (mpi->flags&MP_IMGFLAG_PLANAR) { |
43 int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1; | |
44 // 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
|
45 mpi->stride[0]=mpi->stride[3]=bpp*mpi->width; |
30112 | 46 if(mpi->num_planes > 2){ |
47 mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width; | |
48 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
49 // I420/IYUV (Y,U,V) | |
50 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
51 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
|
52 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
|
53 mpi->planes[3]=mpi->planes[2]+mpi->stride[2]*mpi->chroma_height; |
30112 | 54 } else { |
55 // YV12,YVU9,IF09 (Y,V,U) | |
56 mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
57 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
|
58 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
|
59 mpi->planes[3]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height; |
30112 | 60 } |
61 } else { | |
62 // NV12/NV21 | |
63 mpi->stride[1]=mpi->chroma_width; | |
64 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
65 } | |
66 } else { | |
67 mpi->stride[0]=mpi->width*mpi->bpp/8; | |
68 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) | |
31003
00825525514e
Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents:
30996
diff
changeset
|
69 mpi->planes[1] = av_malloc(1024); |
30112 | 70 } |
71 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
72 } | |
73 | |
23994
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* 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
|
75 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
|
76 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
77 mp_image_setfmt(mpi,fmt); |
30112 | 78 mp_image_alloc_planes(mpi); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
79 |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
80 return mpi; |
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 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
83 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
|
84 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
|
85 memcpy_pic(dmpi->planes[0],mpi->planes[0], mpi->w, mpi->h, |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
86 dmpi->stride[0],mpi->stride[0]); |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
87 memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->chroma_width, mpi->chroma_height, |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
88 dmpi->stride[1],mpi->stride[1]); |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
89 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->chroma_width, mpi->chroma_height, |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
90 dmpi->stride[2],mpi->stride[2]); |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
91 } else { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
92 memcpy_pic(dmpi->planes[0],mpi->planes[0], |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
93 mpi->w*(dmpi->bpp/8), mpi->h, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
94 dmpi->stride[0],mpi->stride[0]); |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
95 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
96 } |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
97 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
98 void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
99 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
100 mpi->imgfmt=out_fmt; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
101 // compressed formats |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
102 if(out_fmt == IMGFMT_MPEGPES || |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
103 out_fmt == IMGFMT_ZRMJPEGNI || out_fmt == IMGFMT_ZRMJPEGIT || out_fmt == IMGFMT_ZRMJPEGIB || |
32488 | 104 IMGFMT_IS_HWACCEL(out_fmt)){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
105 mpi->bpp=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
106 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
107 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
108 mpi->num_planes=1; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
109 if (IMGFMT_IS_RGB(out_fmt)) { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
110 if (IMGFMT_RGB_DEPTH(out_fmt) < 8 && !(out_fmt&128)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
111 mpi->bpp = IMGFMT_RGB_DEPTH(out_fmt); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
112 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
113 mpi->bpp=(IMGFMT_RGB_DEPTH(out_fmt)+7)&(~7); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
114 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
115 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
116 if (IMGFMT_IS_BGR(out_fmt)) { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
117 if (IMGFMT_BGR_DEPTH(out_fmt) < 8 && !(out_fmt&128)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
118 mpi->bpp = IMGFMT_BGR_DEPTH(out_fmt); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
119 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
120 mpi->bpp=(IMGFMT_BGR_DEPTH(out_fmt)+7)&(~7); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
121 mpi->flags|=MP_IMGFLAG_SWAPPED; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
122 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
123 } |
36104
4e3c56728d1e
Support playback of JPEG 2000 digital cinema files.
cehoyos
parents:
34932
diff
changeset
|
124 if (IMGFMT_IS_XYZ(out_fmt)) { |
36107 | 125 mpi->bpp=3*((IMGFMT_XYZ_DEPTH(out_fmt) + 7) & ~7); |
36104
4e3c56728d1e
Support playback of JPEG 2000 digital cinema files.
cehoyos
parents:
34932
diff
changeset
|
126 return; |
4e3c56728d1e
Support playback of JPEG 2000 digital cinema files.
cehoyos
parents:
34932
diff
changeset
|
127 } |
34157 | 128 mpi->num_planes=3; |
129 if (out_fmt == IMGFMT_GBR24P) { | |
130 mpi->bpp=24; | |
131 mpi->flags|=MP_IMGFLAG_PLANAR; | |
132 return; | |
34923
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
133 } else if (out_fmt == IMGFMT_GBR12P) { |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
134 mpi->bpp=36; |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
135 mpi->flags|=MP_IMGFLAG_PLANAR; |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
136 return; |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
137 } else if (out_fmt == IMGFMT_GBR14P) { |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
138 mpi->bpp=42; |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
139 mpi->flags|=MP_IMGFLAG_PLANAR; |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
140 return; |
34157 | 141 } |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
142 mpi->flags|=MP_IMGFLAG_YUV; |
33365
706871635af7
Make mp_get_chroma_shift simpler/more generic and add an argument
reimar
parents:
33364
diff
changeset
|
143 if (mp_get_chroma_shift(out_fmt, NULL, NULL, NULL)) { |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
144 mpi->flags|=MP_IMGFLAG_PLANAR; |
33365
706871635af7
Make mp_get_chroma_shift simpler/more generic and add an argument
reimar
parents:
33364
diff
changeset
|
145 mpi->bpp = mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift, NULL); |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
146 mpi->chroma_width = mpi->width >> mpi->chroma_x_shift; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
147 mpi->chroma_height = mpi->height >> mpi->chroma_y_shift; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
148 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
149 switch(out_fmt){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
150 case IMGFMT_I420: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
151 case IMGFMT_IYUV: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
152 mpi->flags|=MP_IMGFLAG_SWAPPED; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
153 case IMGFMT_YV12: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
154 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
155 case IMGFMT_420A: |
34805
0eba64545a27
Improve Avid Meridien (AVUI) decoding with FFmpeg.
cehoyos
parents:
34565
diff
changeset
|
156 case IMGFMT_422A: |
34565 | 157 case IMGFMT_444A: |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
158 case IMGFMT_IF09: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
159 mpi->num_planes=4; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
160 case IMGFMT_YVU9: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
161 case IMGFMT_444P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
162 case IMGFMT_422P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
163 case IMGFMT_411P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
164 case IMGFMT_440P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
165 case IMGFMT_444P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
166 case IMGFMT_444P16_BE: |
34923
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
167 case IMGFMT_444P14_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
168 case IMGFMT_444P14_BE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
169 case IMGFMT_444P12_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
170 case IMGFMT_444P12_BE: |
34028 | 171 case IMGFMT_444P10_LE: |
172 case IMGFMT_444P10_BE: | |
34189 | 173 case IMGFMT_444P9_LE: |
174 case IMGFMT_444P9_BE: | |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
175 case IMGFMT_422P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
176 case IMGFMT_422P16_BE: |
34923
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
177 case IMGFMT_422P14_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
178 case IMGFMT_422P14_BE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
179 case IMGFMT_422P12_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
180 case IMGFMT_422P12_BE: |
33364
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
181 case IMGFMT_422P10_LE: |
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
182 case IMGFMT_422P10_BE: |
34436 | 183 case IMGFMT_422P9_LE: |
184 case IMGFMT_422P9_BE: | |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
185 case IMGFMT_420P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
186 case IMGFMT_420P16_BE: |
34923
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
187 case IMGFMT_420P14_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
188 case IMGFMT_420P14_BE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
189 case IMGFMT_420P12_LE: |
eb76937af57e
Support FFmpeg pix_fmts YUV4xxP12*, YUV4xxP14*, GBR12P* and GBR14P*.
cehoyos
parents:
34805
diff
changeset
|
190 case IMGFMT_420P12_BE: |
33364
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
191 case IMGFMT_420P10_LE: |
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
192 case IMGFMT_420P10_BE: |
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
193 case IMGFMT_420P9_LE: |
e1ee4895e500
Support displaying of 9- and 10-bit pixel formats,
cehoyos
parents:
32702
diff
changeset
|
194 case IMGFMT_420P9_BE: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
195 return; |
34932
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
196 case IMGFMT_Y16_LE: |
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
197 case IMGFMT_Y16_BE: |
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
198 mpi->bpp=16; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
199 case IMGFMT_Y800: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
200 case IMGFMT_Y8: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
201 /* they're planar ones, but for easier handling use them as packed */ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
202 mpi->flags&=~MP_IMGFLAG_PLANAR; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
203 mpi->num_planes=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
204 return; |
34932
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
205 case IMGFMT_Y8A: |
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
206 mpi->num_planes=2; |
19212dea7a97
Add missing aequivalents for PIX_FMT_GRAY8A and PIX_FMT_GRAY16*.
cehoyos
parents:
34923
diff
changeset
|
207 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
208 case IMGFMT_UYVY: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
209 mpi->flags|=MP_IMGFLAG_SWAPPED; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
210 case IMGFMT_YUY2: |
34267 | 211 mpi->chroma_x_shift = 1; |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
212 mpi->bpp=16; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
213 mpi->num_planes=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
214 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
215 case IMGFMT_NV12: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
216 mpi->flags|=MP_IMGFLAG_SWAPPED; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
217 case IMGFMT_NV21: |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
218 mpi->flags|=MP_IMGFLAG_PLANAR; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
219 mpi->bpp=12; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
220 mpi->num_planes=2; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
221 mpi->chroma_width=(mpi->width>>0); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
222 mpi->chroma_height=(mpi->height>>1); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
223 mpi->chroma_x_shift=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
224 mpi->chroma_y_shift=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
225 return; |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
226 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
227 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"mp_image: unknown out_fmt: 0x%X\n",out_fmt); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
228 mpi->bpp=0; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
229 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
230 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
231 mp_image_t* new_mp_image(int w,int h){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
232 mp_image_t* mpi = malloc(sizeof(mp_image_t)); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
233 if(!mpi) return NULL; // error! |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
234 memset(mpi,0,sizeof(mp_image_t)); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
235 mpi->width=mpi->w=w; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
236 mpi->height=mpi->h=h; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
237 return mpi; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
238 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
239 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
240 void free_mp_image(mp_image_t* mpi){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
241 if(!mpi) return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
242 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
243 /* becouse we allocate the whole image in once */ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
244 av_free(mpi->planes[0]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
245 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32537
diff
changeset
|
246 av_free(mpi->planes[1]); |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
247 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
248 free(mpi); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
249 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
250 |