Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.h @ 34757:da38eb1e2069
subassconvert: handle "\r\n" line ends
Previously the code converting text subtitles to ASS format converted newline
characters, and only those, to ASS "new line" markup. If the subtitles
contained "\r\n", the "\r" was thus left in the text. In previous libass
versions the "\r" was not visible, but in the current one it produces an empty
box. Improve the conversion to remove the "\r" in that case. Also treat a lone
"\r" as a newline.
Picked from mplayer2/3e0a2705
author | cboesch |
---|---|
date | Sat, 07 Apr 2012 11:17:09 +0000 |
parents | a93891202051 |
children | b371a630600c |
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 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
18 |
26029 | 19 #ifndef MPLAYER_MP_IMAGE_H |
20 #define MPLAYER_MP_IMAGE_H | |
4185 | 21 |
26147
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
22 #include <stdio.h> |
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
23 #include <stdlib.h> |
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
24 #include <string.h> |
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
25 |
6875 | 26 //--------- codec's requirements (filled by the codec/vf) --------- |
27 | |
28 //--- buffer content restrictions: | |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
29 // set if buffer content shouldn't be modified: |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
30 #define MP_IMGFLAG_PRESERVE 0x01 |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
31 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames) |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
32 #define MP_IMGFLAG_READABLE 0x02 |
6875 | 33 |
34 //--- buffer width/stride/plane restrictions: (used for direct rendering) | |
35 // stride _have_to_ be aligned to MB boundary: [for DR restrictions] | |
36 #define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4 | |
37 // stride should be aligned to MB boundary: [for buffer allocation] | |
38 #define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8 | |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
39 // codec accept any stride (>=width): |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
40 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10 |
6875 | 41 // codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width): |
4962 | 42 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20 |
6875 | 43 //--- for planar formats only: |
44 // uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift | |
45 #define MP_IMGFLAG_COMMON_STRIDE 0x40 | |
46 // uses only planes[0], and calculates planes[1,2] from width,height,imgfmt | |
47 #define MP_IMGFLAG_COMMON_PLANE 0x80 | |
4185 | 48 |
6875 | 49 #define MP_IMGFLAGMASK_RESTRICTIONS 0xFF |
50 | |
51 //--------- color info (filled by mp_image_setfmt() ) ----------- | |
4185 | 52 // set if number of planes > 1 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
53 #define MP_IMGFLAG_PLANAR 0x100 |
4185 | 54 // set if it's YUV colorspace |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
55 #define MP_IMGFLAG_YUV 0x200 |
6875 | 56 // set if it's swapped (BGR or YVU) plane/byteorder |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
57 #define MP_IMGFLAG_SWAPPED 0x400 |
30074 | 58 // set if you want memory for palette allocated and managed by vf_get_image etc. |
6875 | 59 #define MP_IMGFLAG_RGB_PALETTE 0x800 |
60 | |
61 #define MP_IMGFLAGMASK_COLORS 0xF00 | |
62 | |
63 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2) | |
64 // [the codec will set this flag if it supports callbacks, and the vo _may_ | |
65 // clear it in get_image() if draw_slice() not implemented] | |
66 #define MP_IMGFLAG_DRAW_CALLBACK 0x1000 | |
67 // set if it's in video buffer/memory: [set by vo/vf's get_image() !!!] | |
68 #define MP_IMGFLAG_DIRECT 0x2000 | |
69 // set if buffer is allocated (used in destination images): | |
70 #define MP_IMGFLAG_ALLOCATED 0x4000 | |
71 | |
72 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!) | |
73 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000 | |
4185 | 74 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
75 // codec doesn't support any form of direct rendering - it has own buffer |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
76 // allocation. so we just export its buffer pointers: |
4186 | 77 #define MP_IMGTYPE_EXPORT 0 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
78 // codec requires a static WO buffer, but it does only partial updates later: |
4186 | 79 #define MP_IMGTYPE_STATIC 1 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
80 // codec just needs some WO memory, where it writes/copies the whole frame to: |
4186 | 81 #define MP_IMGTYPE_TEMP 2 |
4877
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
82 // I+P type, requires 2+ independent static R/W buffers |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
83 #define MP_IMGTYPE_IP 3 |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
84 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers |
9d97874d8691
new flags added for direct rendering (libmpcodecs core)
arpi
parents:
4187
diff
changeset
|
85 #define MP_IMGTYPE_IPB 4 |
28515
134689b7b548
Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents:
26147
diff
changeset
|
86 // Upper 16 bits give desired buffer number, -1 means get next available |
134689b7b548
Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents:
26147
diff
changeset
|
87 #define MP_IMGTYPE_NUMBERED 5 |
31953 | 88 // Doesn't need any buffer, incomplete image (probably a first field only) |
89 // we need this type to be able to differentiate between half frames and | |
90 // all other cases | |
91 #define MP_IMGTYPE_INCOMPLETE 6 | |
4186 | 92 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31953
diff
changeset
|
93 #define MP_MAX_PLANES 4 |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
94 |
10663 | 95 #define MP_IMGFIELD_ORDERED 0x01 |
96 #define MP_IMGFIELD_TOP_FIRST 0x02 | |
97 #define MP_IMGFIELD_REPEAT_FIRST 0x04 | |
98 #define MP_IMGFIELD_TOP 0x08 | |
99 #define MP_IMGFIELD_BOTTOM 0x10 | |
11669
bcf9862f61b2
set top_field first for lavc decoding and add MP_IMGFIELD_INTERLACED
michael
parents:
11386
diff
changeset
|
100 #define MP_IMGFIELD_INTERLACED 0x20 |
10510
73b3e4336cd4
Add mpeg2_flags to mp_image_t, copy flags in vd_libmpeg2.c,
ranma
parents:
10316
diff
changeset
|
101 |
31173
b35751576d17
cosmetics: Drop pointless _s suffix from 'struct mp_image'.
diego
parents:
30996
diff
changeset
|
102 typedef struct mp_image { |
28515
134689b7b548
Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents:
26147
diff
changeset
|
103 unsigned int flags; |
4186 | 104 unsigned char type; |
28515
134689b7b548
Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents:
26147
diff
changeset
|
105 int number; |
4186 | 106 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8 |
4185 | 107 unsigned int imgfmt; |
108 int width,height; // stored dimensions | |
109 int x,y,w,h; // visible dimensions | |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
110 unsigned char* planes[MP_MAX_PLANES]; |
14792
6c12ee26fab9
stride must be signed! otherwise negative stride is broken on 64bit systems
rfelker
parents:
11669
diff
changeset
|
111 int stride[MP_MAX_PLANES]; |
7984
a57c1fc0c2fc
change qscale type to int8 and fix qscale ordering
michael
parents:
7957
diff
changeset
|
112 char * qscale; |
4185 | 113 int qstride; |
7957
31fd09cc9ba2
passing picture_type (might be usefull for postprocessing)
michael
parents:
6911
diff
changeset
|
114 int pict_type; // 0->unknown, 1->I, 2->P, 3->B |
10663 | 115 int fields; |
9925
420640a0f6d0
passing qscale_type around so the pp code can fix the mpeg2 <<1 thing
michael
parents:
9171
diff
changeset
|
116 int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2 |
6538
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
117 int num_planes; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
118 /* these are only used by planar formats Y,U(Cb),V(Cr) */ |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
119 int chroma_width; |
afb4f3c107e7
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6525
diff
changeset
|
120 int chroma_height; |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
121 int chroma_x_shift; // horizontal |
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6538
diff
changeset
|
122 int chroma_y_shift; // vertical |
28956
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28518
diff
changeset
|
123 int usage_count; |
6759
415be01747ae
added 'priv' field to mpi - requires for tracking frames with different
arpi
parents:
6707
diff
changeset
|
124 /* for private use by filter or vo driver (to store buffer id or dmpi) */ |
415be01747ae
added 'priv' field to mpi - requires for tracking frames with different
arpi
parents:
6707
diff
changeset
|
125 void* priv; |
4185 | 126 } mp_image_t; |
127 | |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30702
diff
changeset
|
128 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:
30702
diff
changeset
|
129 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:
30702
diff
changeset
|
130 void free_mp_image(mp_image_t* mpi); |
5737 | 131 |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
23689
diff
changeset
|
132 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt); |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30110
diff
changeset
|
133 void mp_image_alloc_planes(mp_image_t *mpi); |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
23689
diff
changeset
|
134 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:
23689
diff
changeset
|
135 |
26029 | 136 #endif /* MPLAYER_MP_IMAGE_H */ |