Mercurial > mplayer.hg
annotate libmpcodecs/vd_raw.c @ 24814:1903b15e6fb7
A missing break statement caused SDLK_PLUS to be triggered twice on one press.
patch by Michael Mauch, michael.mauch gmx de
Subject: [MPlayer-dev-eng] [PATCH] Add two breaks in the key handling of vo_sdl
Date: Tue, 23 Oct 2007 00:04:20 +0200
author | diego |
---|---|
date | Mon, 22 Oct 2007 22:42:47 +0000 |
parents | 4726edea2edd |
children | b90f13d1f7eb |
rev | line source |
---|---|
4969 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 #include "mp_msg.h" | |
6 | |
7 #include "vd_internal.h" | |
8 | |
9 static vd_info_t info = { | |
10 "RAW Uncompressed Video", | |
11 "raw", | |
12 "A'rpi", | |
13 "A'rpi & Alex", | |
14 "uncompressed" | |
15 }; | |
16 | |
17 LIBVD_EXTERN(raw) | |
18 | |
19 // to set/get/query special features/parameters | |
20 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
|
21 int format = sh->bih ? sh->bih->biCompression : sh->format; |
4969 | 22 switch(cmd){ |
23 case VDCTRL_QUERY_FORMAT: | |
23298
4726edea2edd
Make vd_raw VDCTRL_QUERY_FORMAT simpler to understand
reimar
parents:
10742
diff
changeset
|
24 if (*(int *)arg == format) return CONTROL_TRUE; |
4969 | 25 return CONTROL_FALSE; |
26 } | |
27 return CONTROL_UNKNOWN; | |
28 } | |
29 | |
30 // init driver | |
31 static int init(sh_video_t *sh){ | |
32 // set format fourcc for raw RGB: | |
6502 | 33 if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth |
4969 | 34 switch(sh->bih->biBitCount){ |
7773 | 35 case 1: sh->bih->biCompression=IMGFMT_BGR1; break; |
36 case 4: sh->bih->biCompression=IMGFMT_BGR4; break; | |
6229 | 37 case 8: sh->bih->biCompression=IMGFMT_BGR8; break; |
38 case 15: sh->bih->biCompression=IMGFMT_BGR15; break; | |
39 // workaround bitcount==16 => bgr15 case for avi files: | |
40 case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break; | |
41 case 24: sh->bih->biCompression=IMGFMT_BGR24; break; | |
42 case 32: sh->bih->biCompression=IMGFMT_BGR32; break; | |
4969 | 43 default: |
44 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount); | |
45 } | |
46 } | |
6502 | 47 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format); |
4969 | 48 } |
49 | |
50 // uninit driver | |
51 static void uninit(sh_video_t *sh){ | |
52 } | |
53 | |
54 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
55 | |
56 // decode a frame | |
57 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
58 mp_image_t* mpi; | |
7773 | 59 int frame_size; |
60 | |
4969 | 61 if(len<=0) return NULL; // skipped frame |
7773 | 62 |
4969 | 63 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, |
64 sh->disp_w, sh->disp_h); | |
65 if(!mpi) return NULL; | |
66 | |
67 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
68 // TODO !!! | |
69 mpi->planes[0]=data; | |
70 mpi->stride[0]=mpi->width; | |
7773 | 71 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
|
72 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
|
73 { |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
74 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
|
75 mpi->stride[1]=mpi->chroma_width; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
76 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
|
77 } 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
|
78 int cb=2, cr=1; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
79 if(mpi->flags&MP_IMGFLAG_SWAPPED) { |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
80 cb=1; cr=2; |
794b55a44528
basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents:
7782
diff
changeset
|
81 } |
5271
81f31373837e
adding support for 12 bit planar YUV formats (for YUV4MPEG(2))
rik
parents:
5124
diff
changeset
|
82 // Support for some common Planar YUV formats |
6480 | 83 /* YV12,I420,IYUV */ |
6667 | 84 mpi->planes[cb]=mpi->planes[0]+mpi->width*mpi->height; |
85 mpi->stride[cb]=mpi->chroma_width; | |
86 mpi->planes[cr]=mpi->planes[cb]+mpi->chroma_width*mpi->chroma_height; | |
87 mpi->stride[cr]=mpi->chroma_width; | |
7773 | 88 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
|
89 } |
4969 | 90 } else { |
91 mpi->planes[0]=data; | |
92 mpi->stride[0]=mpi->width*(mpi->bpp/8); | |
6229 | 93 // .AVI files has uncompressed lines 4-byte aligned: |
94 if(sh->format==0 || sh->format==3) mpi->stride[0]=(mpi->stride[0]+3)&(~3); | |
5899 | 95 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
96 // export palette: | |
7782 | 97 mpi->planes[1]=sh->bih ? (unsigned char*)(sh->bih+1) : NULL; |
98 #if 0 | |
99 printf("Exporting palette: %p !!\n",mpi->planes[1]); | |
100 { unsigned char* p=mpi->planes[1]; | |
101 int i; | |
102 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]); | |
103 } | |
104 #endif | |
5899 | 105 } |
7773 | 106 frame_size=mpi->stride[0]*mpi->h; |
107 if(mpi->bpp<8) frame_size=frame_size*mpi->bpp/8; | |
108 } | |
109 | |
110 if(len<frame_size){ | |
111 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Frame too small! (%d<%d) Wrong format?\n", | |
112 len,frame_size); | |
113 return NULL; | |
4969 | 114 } |
115 | |
116 return mpi; | |
117 } |