Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 35418:cedb0ba2b5c6
Move the code to set guiInfo's Track, Chapter and Angle start values.
Set them before checking whether there is any media opened, because
with no media opened we clear the counters.
author | ib |
---|---|
date | Thu, 29 Nov 2012 14:11:03 +0000 |
parents | 0f14ab03ec98 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
4969 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 | |
22 #include "config.h" | |
23 #include "mp_msg.h" | |
24 | |
25 #include "vd_internal.h" | |
26 | |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
27 static const vd_info_t info = { |
4969 | 28 "RAW Uncompressed Video", |
29 "raw", | |
30 "A'rpi", | |
31 "A'rpi & Alex", | |
32 "uncompressed" | |
33 }; | |
34 | |
35 LIBVD_EXTERN(raw) | |
36 | |
37 // to set/get/query special features/parameters | |
38 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
23298
4726edea2edd
Make vd_raw VDCTRL_QUERY_FORMAT simpler to understand
reimar
parents:
10742
diff
changeset
|
39 int format = sh->bih ? sh->bih->biCompression : sh->format; |
4969 | 40 switch(cmd){ |
41 case VDCTRL_QUERY_FORMAT: | |
23298
4726edea2edd
Make vd_raw VDCTRL_QUERY_FORMAT simpler to understand
reimar
parents:
10742
diff
changeset
|
42 if (*(int *)arg == format) return CONTROL_TRUE; |
25182 | 43 if (*(int *)arg == IMGFMT_YUY2 && format == MKTAG('y', 'u', 'v', '2')) return CONTROL_TRUE; |
4969 | 44 return CONTROL_FALSE; |
45 } | |
46 return CONTROL_UNKNOWN; | |
47 } | |
48 | |
49 // init driver | |
50 static int init(sh_video_t *sh){ | |
51 // set format fourcc for raw RGB: | |
6502 | 52 if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth |
4969 | 53 switch(sh->bih->biBitCount){ |
7773 | 54 case 1: sh->bih->biCompression=IMGFMT_BGR1; break; |
55 case 4: sh->bih->biCompression=IMGFMT_BGR4; break; | |
6229 | 56 case 8: sh->bih->biCompression=IMGFMT_BGR8; break; |
57 case 15: sh->bih->biCompression=IMGFMT_BGR15; break; | |
58 // workaround bitcount==16 => bgr15 case for avi files: | |
59 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break; | |
60 case 24: sh->bih->biCompression=IMGFMT_BGR24; break; | |
61 case 32: sh->bih->biCompression=IMGFMT_BGR32; break; | |
4969 | 62 default: |
63 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount); | |
64 } | |
65 } | |
6502 | 66 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format); |
4969 | 67 } |
68 | |
69 // uninit driver | |
70 static void uninit(sh_video_t *sh){ | |
71 } | |
72 | |
73 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
74 | |
75 // decode a frame | |
76 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
77 mp_image_t* mpi; | |
7773 | 78 int frame_size; |
25182 | 79 int format = sh->bih ? sh->bih->biCompression : sh->format; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25182
diff
changeset
|
80 |
4969 | 81 if(len<=0) return NULL; // skipped frame |
7773 | 82 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25182
diff
changeset
|
83 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, |
4969 | 84 sh->disp_w, sh->disp_h); |
85 if(!mpi) return NULL; | |
86 | |
87 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
88 // TODO !!! | |
89 mpi->planes[0]=data; | |
90 mpi->stride[0]=mpi->width; | |
7773 | 91 frame_size=mpi->stride[0]*mpi->h; |
10742
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
92 if((mpi->imgfmt == IMGFMT_NV12) || (mpi->imgfmt == IMGFMT_NV21)) |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
93 { |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
94 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
95 mpi->stride[1]=mpi->chroma_width; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
96 frame_size+=mpi->chroma_width*mpi->chroma_height; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
97 } else if(mpi->flags&MP_IMGFLAG_YUV) { |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
98 int cb=2, cr=1; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
99 if(mpi->flags&MP_IMGFLAG_SWAPPED) { |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
100 cb=1; cr=2; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
101 } |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
102 // Support for some common Planar YUV formats |
6480 | 103 /* YV12,I420,IYUV */ |
6667 | 104 mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height; |
105 mpi->stride[cb]=mpi->chroma_width; | |
106 mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height; | |
107 mpi->stride[cr]=mpi->chroma_width; | |
7773 | 108 frame_size+=2*mpi->chroma_width*mpi->chroma_height; |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
109 } |
4969 | 110 } else { |
111 mpi->planes[0]=data; | |
112 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 113 // .AVI files has uncompressed lines 4-byte aligned: |
114 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 115 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
116 // export palette: | |
7782 | 117 mpi->planes[1]=sh->bih ? (unsigned char*)(sh->bih+1) : NULL; |
118 #if 0 | |
119 printf("Exporting palette: %p !!\n",mpi->planes[1]); | |
120 { unsigned char* p=mpi->planes[1]; | |
121 int i; | |
122 for(i=0;i<64;i++) printf("%3d: %02X %02X %02X (%02X)\n",i,p[4*i],p[4*i+1],p[4*i+2],p[4*i+3]); | |
123 } | |
124 #endif | |
5899 | 125 } |
7773 | 126 frame_size=mpi->stride[0]*mpi->h; |
30930 | 127 if (len >= frame_size && format == MKTAG('y', 'u', 'v', '2')) { |
25182 | 128 int i; |
129 for (i = 1; i < frame_size; i += 2) | |
130 mpi->planes[0][i] ^= 128; | |
131 } | |
7773 | 132 if(mpi->bpp<8) frame_size=frame_size*mpi->bpp/8; |
133 } | |
134 | |
135 if(len<frame_size){ | |
136 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Frame too small! (%d<%d) Wrong format?\n", | |
137 len,frame_size); | |
138 return NULL; | |
4969 | 139 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25182
diff
changeset
|
140 |
4969 | 141 return mpi; |
142 } |