annotate libmpcodecs/vd_svq1.c @ 7393:52b29760fe95

Added a new ASX playlist mime-type
author bertrand
date Fri, 13 Sep 2002 22:39:48 +0000
parents 28677d779205
children b465ba5897a3
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"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
5 #include "mp_msg.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
6
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
7 #include "vd_internal.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
8
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
9 static vd_info_t info = {
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
10 "SVQ1 (Sorenson v1) Video decoder",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
11 "svq1",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
12 "A'rpi",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
13 "XINE team",
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
14 "native codec"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
15 };
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
16
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
17 LIBVD_EXTERN(svq1)
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
18
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
19 #ifdef USE_LIBAVCODEC
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
20 #ifdef USE_LIBAVCODEC_SO
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
21 #include <ffmpeg/avcodec.h>
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
22 #else
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
23 #include "libavcodec/avcodec.h"
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
24 #endif
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
25 #endif
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6521
diff changeset
26
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
27 #include "native/svq1.h"
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
28
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
29 // to set/get/query special features/parameters
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
30 static int control(sh_video_t *sh,int cmd,void* arg,...){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
31 return CONTROL_UNKNOWN;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
32 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
33
6509
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
34 extern int avcodec_inited;
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
35
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
36 // init driver
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
37 static int init(sh_video_t *sh){
6509
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
38
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
39 #ifdef USE_LIBAVCODEC
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
40 if(!avcodec_inited){
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
41 avcodec_init();
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
42 avcodec_register_all();
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
43 avcodec_inited=1;
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
44 }
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
45 #endif
762d3cf8da36 init libavcodec
arpi
parents: 6506
diff changeset
46
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
47 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YVU9)) return 0;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
48
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
49 sh->context=malloc(sizeof(svq1_t));
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
50 memset(sh->context,0,sizeof(svq1_t));
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
51
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
52 return 1;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
53 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
54
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
55 // uninit driver
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
56 static void uninit(sh_video_t *sh){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
57 svq1_free(sh->context);
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
58 sh->context=NULL;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
59 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
60
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
61 // decode a frame
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
62 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
63 mp_image_t* mpi;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
64 svq1_t* svq1=sh->context;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
65 int ret;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
66
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
67 if(len<=0) return NULL; // skipped frame
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
68
6511
a2086150099b use libavcodec's get_bits() code (optional, disabled by default)
arpi
parents: 6509
diff changeset
69 ret=svq1_decode_frame(svq1,data,len);
6521
adc50c83986d do not crash by decoding error
alex
parents: 6511
diff changeset
70 if (ret != 0)
adc50c83986d do not crash by decoding error
alex
parents: 6511
diff changeset
71 return NULL;
6506
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
72
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
73 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
74 sh->disp_w, sh->disp_h);
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
75 if(!mpi) return NULL;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
76
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
77 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
78
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
79 mpi->planes[0]=svq1->base[0];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
80 mpi->planes[1]=svq1->base[1];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
81 mpi->planes[2]=svq1->base[2];
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
82 mpi->stride[0]=svq1->luma_width;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
83 mpi->stride[1]=mpi->stride[2]=svq1->chroma_width;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
84
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
85 return mpi;
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
86 }
f0788e0f7475 SVQ1 added
arpi
parents:
diff changeset
87