Mercurial > mplayer.hg
annotate libmpcodecs/ve_libdv.c @ 10774:3a6ed2ad244d
FFASV2
author | michael |
---|---|
date | Mon, 01 Sep 2003 08:29:54 +0000 |
parents | c671e9adbe22 |
children | 835822ce4bb1 |
rev | line source |
---|---|
5577 | 1 // requires libdv-0.9.5 !!! |
2 // (v0.9.0 is too old and has no encoding functionality exported!) | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 | |
8 #include "../config.h" | |
9 #include "../mp_msg.h" | |
10 | |
11 #ifdef HAVE_LIBDV095 | |
12 | |
13 #include "codec-cfg.h" | |
14 #include "stream.h" | |
15 #include "demuxer.h" | |
16 #include "stheader.h" | |
17 | |
8585 | 18 #include "muxer.h" |
5577 | 19 |
5607 | 20 #include "img_format.h" |
21 #include "mp_image.h" | |
5577 | 22 #include "vf.h" |
23 | |
24 #include <libdv/dv.h> | |
25 | |
26 #ifndef DV_WIDTH | |
27 #define DV_WIDTH 720 | |
28 #define DV_PAL_HEIGHT 576 | |
29 #define DV_NTSC_HEIGHT 480 | |
30 #endif | |
31 | |
32 struct vf_priv_s { | |
8585 | 33 muxer_stream_t* mux; |
5577 | 34 dv_encoder_t* enc; |
35 | |
36 }; | |
37 #define mux_v (vf->priv->mux) | |
38 | |
39 //===========================================================================// | |
40 | |
41 static int config(struct vf_instance_s* vf, | |
42 int width, int height, int d_width, int d_height, | |
43 unsigned int flags, unsigned int outfmt){ | |
44 | |
45 if(width!=DV_WIDTH || (height!=DV_PAL_HEIGHT && height!=DV_NTSC_HEIGHT)){ | |
46 mp_msg(MSGT_VFILTER,MSGL_ERR,"DV: only 720x480 (NTSC) and 720x576 (PAL) resolutions allowed! try with -vop scale=720:480\n"); | |
47 } | |
48 | |
49 vf->priv->enc->isPAL=(height==DV_PAL_HEIGHT); | |
50 vf->priv->enc->is16x9=(d_width/(float)d_height > 1.7); // 16:9=1.777777 | |
51 vf->priv->enc->vlc_encode_passes=3; | |
52 vf->priv->enc->static_qno=0; | |
53 vf->priv->enc->force_dct=0; | |
54 | |
55 mux_v->bih->biWidth=width; | |
56 mux_v->bih->biHeight=height; | |
57 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8); | |
58 | |
59 return 1; | |
60 } | |
61 | |
62 static int control(struct vf_instance_s* vf, int request, void* data){ | |
63 | |
64 return CONTROL_UNKNOWN; | |
65 } | |
66 | |
67 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
68 if(fmt==IMGFMT_YUY2) return 3; | |
69 if(fmt==IMGFMT_RGB24) return 1; | |
70 return 0; | |
71 } | |
72 | |
7368 | 73 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
5577 | 74 |
75 dv_encode_full_frame(vf->priv->enc, mpi->planes, | |
76 (mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb, | |
77 mux_v->buffer); | |
78 | |
9014
c671e9adbe22
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
79 muxer_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10); |
7368 | 80 return 1; |
5577 | 81 } |
82 | |
83 //===========================================================================// | |
84 | |
85 static int vf_open(vf_instance_t *vf, char* args){ | |
86 vf->config=config; | |
87 vf->control=control; | |
88 vf->query_format=query_format; | |
89 vf->put_image=put_image; | |
90 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
91 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
8585 | 92 vf->priv->mux=(muxer_stream_t*)args; |
5577 | 93 |
94 vf->priv->enc=dv_encoder_new(1,1,1); // FIXME, parse some options! | |
95 if(!vf->priv->enc) return 0; | |
96 | |
97 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); | |
98 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); | |
99 mux_v->bih->biWidth=0; | |
100 mux_v->bih->biHeight=0; | |
101 mux_v->bih->biCompression=mmioFOURCC('d','v','s','d'); | |
102 mux_v->bih->biPlanes=1; | |
103 mux_v->bih->biBitCount=24; | |
104 | |
105 return 1; | |
106 } | |
107 | |
108 vf_info_t ve_info_libdv = { | |
109 "DV encoder using libdv", | |
110 "libdv", | |
111 "A'rpi", | |
112 "for internal use by mencoder", | |
113 vf_open | |
114 }; | |
115 | |
116 //===========================================================================// | |
117 #endif |