annotate libmpcodecs/vd_svq1.c @ 9278:caea8ed36b48

The reason why mplayer crashes (in some cases) when using x11 output and -wid (>0) parameter is this: Mplayer by default creates a colormap using DirectColor visual. If the window given to mplayer uses TrueColor visual there will be an error when mplayer sets the colormap for the window. This patch modifies mplayer to use TrueColor visual if the window given to mplayer uses TrueColor. Another solution is to make sure that the window given to mplayer is created using DirectColor visual if it is supported by the display. Jouni Tulkki <jitulkki@cc.hut.fi>
author arpi
date Tue, 04 Feb 2003 18:31:44 +0000
parents b465ba5897a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
1 #include <stdio.h>
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
2 #include <stdlib.h>
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
3
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
4 #include "config.h"
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7180
diff changeset
5 #ifdef USE_SVQ1
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7180
diff changeset
6
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
7 #include "mp_msg.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
8
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
9 #include "vd_internal.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
10
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
11 static vd_info_t info = {
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
12 "SVQ1 (Sorenson v1) Video decoder",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
13 "svq1",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
14 "A'rpi",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
15 "XINE team",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
16 "native codec"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
17 };
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
18
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
19 LIBVD_EXTERN(svq1)
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
20
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
21 #ifdef USE_LIBAVCODEC
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
22 #ifdef USE_LIBAVCODEC_SO
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
23 #include <ffmpeg/avcodec.h>
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
24 #else
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
25 #include "libavcodec/avcodec.h"
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
26 #endif
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
27 #endif
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
28
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
29 #include "native/svq1.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
30
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
31 // to set/get/query special features/parameters
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
32 static int control(sh_video_t *sh,int cmd,void* arg,...){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
33 return CONTROL_UNKNOWN;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
34 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
35
6509
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
36 extern int avcodec_inited;
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
37
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
38 // init driver
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
39 static int init(sh_video_t *sh){
6509
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
40
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
41 #ifdef USE_LIBAVCODEC
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
42 if(!avcodec_inited){
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
43 avcodec_init();
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
44 avcodec_register_all();
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
45 avcodec_inited=1;
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
46 }
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
47 #endif
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
48
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
49 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YVU9)) return 0;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
50
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
51 sh->context=malloc(sizeof(svq1_t));
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
52 memset(sh->context,0,sizeof(svq1_t));
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
53
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
54 return 1;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
55 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
56
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
57 // uninit driver
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
58 static void uninit(sh_video_t *sh){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
59 svq1_free(sh->context);
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
60 sh->context=NULL;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
61 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
62
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
63 // decode a frame
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
64 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
65 mp_image_t* mpi;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
66 svq1_t* svq1=sh->context;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
67 int ret;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
68
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
69 if(len<=0) return NULL; // skipped frame
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
70
6511
a2086150099b use libavcodec's get_bits() code (optional, disabled by default)
arpi
parents: 6509
diff changeset
71 ret=svq1_decode_frame(svq1,data,len);
6521
adc50c83986d do not crash by decoding error
alex
parents: 6511
diff changeset
72 if (ret != 0)
adc50c83986d do not crash by decoding error
alex
parents: 6511
diff changeset
73 return NULL;
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
74
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
75 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
76 sh->disp_w, sh->disp_h);
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
77 if(!mpi) return NULL;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
78
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
79 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"SVQ1: ret=%d wh=%dx%d p=%p \n",ret,svq1->width,svq1->height,svq1->current);
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
80
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
81 mpi->planes[0]=svq1->base[0];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
82 mpi->planes[1]=svq1->base[1];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
83 mpi->planes[2]=svq1->base[2];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
84 mpi->stride[0]=svq1->luma_width;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
85 mpi->stride[1]=mpi->stride[2]=svq1->chroma_width;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
86
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
87 return mpi;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
88 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
89
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7180
diff changeset
90 #endif