Mercurial > mplayer.hg
annotate libmpcodecs/vd_libdv.c @ 21100:6bc989360c8b
check we aren't short of sh_videos before allocating another one
and fail if the allocation doesn't succeed;
added support for video stream switching
author | nicodvb |
---|---|
date | Mon, 20 Nov 2006 23:31:01 +0000 |
parents | a1807995e2ab |
children | 4faee1254928 |
rev | line source |
---|---|
6927 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <sys/types.h> | |
5 #include <unistd.h> | |
6 #include <math.h> | |
7 | |
8 #include "config.h" | |
9 | |
10 #include "img_format.h" | |
11 | |
12 #include <libdv/dv.h> | |
13 #include <libdv/dv_types.h> | |
14 | |
15 #include "stream.h" | |
16 #include "demuxer.h" | |
17 #include "stheader.h" | |
18 | |
19 #include "vd_internal.h" | |
20 | |
21 static vd_info_t info = | |
22 { | |
23 "Raw DV Video Decoder", | |
24 "libdv", | |
25 "Alexander Neundorf <neundorf@kde.org>", | |
26 "http://libdv.sf.net", | |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
27 "native codec" |
6927 | 28 }; |
29 | |
30 LIBVD_EXTERN(libdv) | |
31 | |
32 // to set/get/query special features/parameters | |
33 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
34 return CONTROL_UNKNOWN; | |
35 } | |
36 | |
37 static dv_decoder_t* global_rawdv_decoder=NULL; | |
38 | |
39 dv_decoder_t* init_global_rawdv_decoder() | |
40 { | |
41 if(!global_rawdv_decoder){ | |
42 global_rawdv_decoder=dv_decoder_new(TRUE,TRUE,FALSE); | |
43 global_rawdv_decoder->quality=DV_QUALITY_BEST; | |
44 global_rawdv_decoder->prev_frame_decoded = 0; | |
45 } | |
46 return global_rawdv_decoder; | |
47 } | |
48 | |
49 // init driver | |
50 static int init(sh_video_t *sh) | |
51 { | |
52 sh->context = (void *)init_global_rawdv_decoder(); | |
53 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2); | |
54 } | |
55 | |
56 // uninit driver | |
57 static void uninit(sh_video_t *sh){ | |
58 } | |
59 | |
60 // decode a frame | |
61 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) | |
62 { | |
63 mp_image_t* mpi; | |
64 dv_decoder_t *decoder=sh->context; | |
65 | |
66 if(len<=0 || (flags&3)){ | |
67 // fprintf(stderr,"decode() (rawdv) SKIPPED\n"); | |
68 return NULL; // skipped frame | |
69 } | |
70 | |
71 dv_parse_header(decoder, data); | |
72 | |
73 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h); | |
74 | |
75 if(!mpi){ // temporary! | |
76 fprintf(stderr,"couldn't allocate image for stderr codec\n"); | |
77 return NULL; | |
78 } | |
79 | |
80 dv_decode_full_frame(decoder, data, e_dv_color_yuv, mpi->planes, mpi->stride); | |
81 | |
82 return mpi; | |
83 } |