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 #ifdef HAVE_LIBDV095
|
|
11
|
|
12 #include "img_format.h"
|
|
13
|
|
14 #include <libdv/dv.h>
|
|
15 #include <libdv/dv_types.h>
|
|
16
|
|
17 #include "stream.h"
|
|
18 #include "demuxer.h"
|
|
19 #include "stheader.h"
|
|
20
|
|
21 #include "vd_internal.h"
|
|
22
|
|
23 static vd_info_t info =
|
|
24 {
|
|
25 "Raw DV Video Decoder",
|
|
26 "libdv",
|
|
27 "Alexander Neundorf <neundorf@kde.org>",
|
|
28 "http://libdv.sf.net",
|
|
29 ""
|
|
30 };
|
|
31
|
|
32 LIBVD_EXTERN(libdv)
|
|
33
|
|
34 // to set/get/query special features/parameters
|
|
35 static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
36 return CONTROL_UNKNOWN;
|
|
37 }
|
|
38
|
|
39 static dv_decoder_t* global_rawdv_decoder=NULL;
|
|
40
|
|
41 dv_decoder_t* init_global_rawdv_decoder()
|
|
42 {
|
|
43 if(!global_rawdv_decoder){
|
|
44 global_rawdv_decoder=dv_decoder_new(TRUE,TRUE,FALSE);
|
|
45 global_rawdv_decoder->quality=DV_QUALITY_BEST;
|
|
46 global_rawdv_decoder->prev_frame_decoded = 0;
|
|
47 }
|
|
48 return global_rawdv_decoder;
|
|
49 }
|
|
50
|
|
51 // init driver
|
|
52 static int init(sh_video_t *sh)
|
|
53 {
|
|
54 sh->context = (void *)init_global_rawdv_decoder();
|
|
55 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2);
|
|
56 }
|
|
57
|
|
58 // uninit driver
|
|
59 static void uninit(sh_video_t *sh){
|
|
60 }
|
|
61
|
|
62 // decode a frame
|
|
63 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|
64 {
|
|
65 mp_image_t* mpi;
|
|
66 dv_decoder_t *decoder=sh->context;
|
|
67
|
|
68 if(len<=0 || (flags&3)){
|
|
69 // fprintf(stderr,"decode() (rawdv) SKIPPED\n");
|
|
70 return NULL; // skipped frame
|
|
71 }
|
|
72
|
|
73 dv_parse_header(decoder, data);
|
|
74
|
|
75 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h);
|
|
76
|
|
77 if(!mpi){ // temporary!
|
|
78 fprintf(stderr,"couldn't allocate image for stderr codec\n");
|
|
79 return NULL;
|
|
80 }
|
|
81
|
|
82 dv_decode_full_frame(decoder, data, e_dv_color_yuv, mpi->planes, mpi->stride);
|
|
83
|
|
84 return mpi;
|
|
85 }
|
|
86 #endif
|
|
87
|