2
* This file is part of MPlayer.
4
* MPlayer is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* MPlayer is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
#include "vd_internal.h"
27
static const vd_info_t info = {
28
"RAW Uncompressed Video",
37
// to set/get/query special features/parameters
38
static int control(sh_video_t *sh,int cmd,void* arg,...){
39
int format = sh->bih ? sh->bih->biCompression : sh->format;
41
case VDCTRL_QUERY_FORMAT:
42
if (*(int *)arg == format) return CONTROL_TRUE;
43
if (*(int *)arg == IMGFMT_YUY2 && format == MKTAG('y', 'u', 'v', '2')) return CONTROL_TRUE;
46
return CONTROL_UNKNOWN;
50
static int init(sh_video_t *sh){
51
// set format fourcc for raw RGB:
52
if(sh->bih && sh->bih->biCompression==0){ // set based on bit depth
53
switch(sh->bih->biBitCount){
54
case 1: sh->bih->biCompression=IMGFMT_BGR1; break;
55
case 4: sh->bih->biCompression=IMGFMT_BGR4; break;
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;
63
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount);
66
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format);
70
static void uninit(sh_video_t *sh){
73
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
76
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
79
int format = sh->bih ? sh->bih->biCompression : sh->format;
81
if(len<=0) return NULL; // skipped frame
83
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
84
sh->disp_w, sh->disp_h);
87
if(mpi->flags&MP_IMGFLAG_PLANAR){
90
mpi->stride[0]=mpi->width;
91
frame_size=mpi->stride[0]*mpi->h;
92
if((mpi->imgfmt == IMGFMT_NV12) || (mpi->imgfmt == IMGFMT_NV21))
94
mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
95
mpi->stride[1]=mpi->chroma_width;
96
frame_size+=mpi->chroma_width*mpi->chroma_height;
97
} else if(mpi->flags&MP_IMGFLAG_YUV) {
99
if(mpi->flags&MP_IMGFLAG_SWAPPED) {
102
// Support for some common Planar YUV formats
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;
108
frame_size+=2*mpi->chroma_width*mpi->chroma_height;
112
mpi->stride[0]=mpi->width*(mpi->bpp/8);
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);
115
if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
117
mpi->planes[1]=sh->bih ? (unsigned char*)(sh->bih+1) : NULL;
119
printf("Exporting palette: %p !!\n",mpi->planes[1]);
120
{ unsigned char* p=mpi->planes[1];
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]);
126
frame_size=mpi->stride[0]*mpi->h;
127
if (len >= frame_size && format == MKTAG('y', 'u', 'v', '2')) {
129
for (i = 1; i < frame_size; i += 2)
130
mpi->planes[0][i] ^= 128;
132
if(mpi->bpp<8) frame_size=frame_size*mpi->bpp/8;
136
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Frame too small! (%d<%d) Wrong format?\n",