7 #include "vd_internal.h"
9 static vd_info_t info
= {
10 "RAW Uncompressed Video",
19 // to set/get/query special features/parameters
20 static int control(sh_video_t
*sh
,int cmd
,void* arg
,...){
22 case VDCTRL_QUERY_FORMAT
:
23 if( (*((int*)arg
)) == (sh
->bih
? sh
->bih
->biCompression
: sh
->format
) ) return CONTROL_TRUE
;
26 return CONTROL_UNKNOWN
;
30 static int init(sh_video_t
*sh
){
31 // set format fourcc for raw RGB:
32 if(sh
->bih
&& sh
->bih
->biCompression
==0){ // set based on bit depth
33 switch(sh
->bih
->biBitCount
){
34 case 1: sh
->bih
->biCompression
=IMGFMT_BGR1
; break;
35 case 4: sh
->bih
->biCompression
=IMGFMT_BGR4
; break;
36 case 8: sh
->bih
->biCompression
=IMGFMT_BGR8
; break;
37 case 15: sh
->bih
->biCompression
=IMGFMT_BGR15
; break;
38 // workaround bitcount==16 => bgr15 case for avi files:
39 case 16: sh
->bih
->biCompression
=(sh
->format
)?IMGFMT_BGR16
:IMGFMT_BGR15
; break;
40 case 24: sh
->bih
->biCompression
=IMGFMT_BGR24
; break;
41 case 32: sh
->bih
->biCompression
=IMGFMT_BGR32
; break;
43 mp_msg(MSGT_DECVIDEO
,MSGL_WARN
,"RAW: depth %d not supported\n",sh
->bih
->biBitCount
);
46 return mpcodecs_config_vo(sh
,sh
->disp_w
,sh
->disp_h
,sh
->bih
? sh
->bih
->biCompression
: sh
->format
);
50 static void uninit(sh_video_t
*sh
){
53 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
56 static mp_image_t
* decode(sh_video_t
*sh
,void* data
,int len
,int flags
){
60 if(len
<=0) return NULL
; // skipped frame
62 mpi
=mpcodecs_get_image(sh
, MP_IMGTYPE_EXPORT
, 0,
63 sh
->disp_w
, sh
->disp_h
);
66 if(mpi
->flags
&MP_IMGFLAG_PLANAR
){
69 mpi
->stride
[0]=mpi
->width
;
70 frame_size
=mpi
->stride
[0]*mpi
->h
;
71 if((mpi
->imgfmt
== IMGFMT_NV12
) || (mpi
->imgfmt
== IMGFMT_NV21
))
73 mpi
->planes
[1]=mpi
->planes
[0]+mpi
->width
*mpi
->height
;
74 mpi
->stride
[1]=mpi
->chroma_width
;
75 frame_size
+=mpi
->chroma_width
*mpi
->chroma_height
;
76 } else if(mpi
->flags
&MP_IMGFLAG_YUV
) {
78 if(mpi
->flags
&MP_IMGFLAG_SWAPPED
) {
81 // Support for some common Planar YUV formats
83 mpi
->planes
[cb
]=mpi
->planes
[0]+mpi
->width
*mpi
->height
;
84 mpi
->stride
[cb
]=mpi
->chroma_width
;
85 mpi
->planes
[cr
]=mpi
->planes
[cb
]+mpi
->chroma_width
*mpi
->chroma_height
;
86 mpi
->stride
[cr
]=mpi
->chroma_width
;
87 frame_size
+=2*mpi
->chroma_width
*mpi
->chroma_height
;
91 mpi
->stride
[0]=mpi
->width
*(mpi
->bpp
/8);
92 // .AVI files has uncompressed lines 4-byte aligned:
93 if(sh
->format
==0 || sh
->format
==3) mpi
->stride
[0]=(mpi
->stride
[0]+3)&(~3);
94 if(mpi
->imgfmt
==IMGFMT_RGB8
|| mpi
->imgfmt
==IMGFMT_BGR8
){
96 mpi
->planes
[1]=sh
->bih
? (unsigned char*)(sh
->bih
+1) : NULL
;
98 printf("Exporting palette: %p !!\n",mpi
->planes
[1]);
99 { unsigned char* p
=mpi
->planes
[1];
101 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]);
105 frame_size
=mpi
->stride
[0]*mpi
->h
;
106 if(mpi
->bpp
<8) frame_size
=frame_size
*mpi
->bpp
/8;
110 mp_msg(MSGT_DECVIDEO
,MSGL_WARN
,"Frame too small! (%d<%d) Wrong format?\n",