comparison libmpcodecs/vd_libdv.c @ 6927:0145bba6e201

native DV audio/video decoders using libdv based on patch by Alexander Neundorf <neundorf@kde.org>
author arpi
date Mon, 05 Aug 2002 17:23:22 +0000
parents
children 28677d779205
comparison
equal deleted inserted replaced
6926:9f325578fac9 6927:0145bba6e201
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 VFM_LIBDV,
28 "Alexander Neundorf <neundorf@kde.org>",
29 "http://libdv.sf.net",
30 ""
31 };
32
33 LIBVD_EXTERN(libdv)
34
35 // to set/get/query special features/parameters
36 static int control(sh_video_t *sh,int cmd,void* arg,...){
37 return CONTROL_UNKNOWN;
38 }
39
40 static dv_decoder_t* global_rawdv_decoder=NULL;
41
42 dv_decoder_t* init_global_rawdv_decoder()
43 {
44 if(!global_rawdv_decoder){
45 global_rawdv_decoder=dv_decoder_new(TRUE,TRUE,FALSE);
46 global_rawdv_decoder->quality=DV_QUALITY_BEST;
47 global_rawdv_decoder->prev_frame_decoded = 0;
48 }
49 return global_rawdv_decoder;
50 }
51
52 // init driver
53 static int init(sh_video_t *sh)
54 {
55 sh->context = (void *)init_global_rawdv_decoder();
56 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2);
57 }
58
59 // uninit driver
60 static void uninit(sh_video_t *sh){
61 }
62
63 // decode a frame
64 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
65 {
66 mp_image_t* mpi;
67 dv_decoder_t *decoder=sh->context;
68
69 if(len<=0 || (flags&3)){
70 // fprintf(stderr,"decode() (rawdv) SKIPPED\n");
71 return NULL; // skipped frame
72 }
73
74 dv_parse_header(decoder, data);
75
76 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h);
77
78 if(!mpi){ // temporary!
79 fprintf(stderr,"couldn't allocate image for stderr codec\n");
80 return NULL;
81 }
82
83 dv_decode_full_frame(decoder, data, e_dv_color_yuv, mpi->planes, mpi->stride);
84
85 return mpi;
86 }
87 #endif
88