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
|
|
18 #include "aviwrite.h"
|
|
19
|
5607
|
20 #include "img_format.h"
|
|
21 #include "mp_image.h"
|
5577
|
22 #include "vf.h"
|
|
23
|
|
24 #include <libdv/dv.h>
|
|
25
|
7127
|
26 extern void mencoder_write_chunk(aviwrite_stream_t *s,int len,unsigned int flags);
|
|
27
|
5577
|
28 #ifndef DV_WIDTH
|
|
29 #define DV_WIDTH 720
|
|
30 #define DV_PAL_HEIGHT 576
|
|
31 #define DV_NTSC_HEIGHT 480
|
|
32 #endif
|
|
33
|
|
34 struct vf_priv_s {
|
|
35 aviwrite_stream_t* mux;
|
|
36 dv_encoder_t* enc;
|
|
37
|
|
38 };
|
|
39 #define mux_v (vf->priv->mux)
|
|
40
|
|
41 //===========================================================================//
|
|
42
|
|
43 static int config(struct vf_instance_s* vf,
|
|
44 int width, int height, int d_width, int d_height,
|
|
45 unsigned int flags, unsigned int outfmt){
|
|
46
|
|
47 if(width!=DV_WIDTH || (height!=DV_PAL_HEIGHT && height!=DV_NTSC_HEIGHT)){
|
|
48 mp_msg(MSGT_VFILTER,MSGL_ERR,"DV: only 720x480 (NTSC) and 720x576 (PAL) resolutions allowed! try with -vop scale=720:480\n");
|
|
49 }
|
|
50
|
|
51 vf->priv->enc->isPAL=(height==DV_PAL_HEIGHT);
|
|
52 vf->priv->enc->is16x9=(d_width/(float)d_height > 1.7); // 16:9=1.777777
|
|
53 vf->priv->enc->vlc_encode_passes=3;
|
|
54 vf->priv->enc->static_qno=0;
|
|
55 vf->priv->enc->force_dct=0;
|
|
56
|
|
57 mux_v->bih->biWidth=width;
|
|
58 mux_v->bih->biHeight=height;
|
|
59 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
|
|
60
|
|
61 return 1;
|
|
62 }
|
|
63
|
|
64 static int control(struct vf_instance_s* vf, int request, void* data){
|
|
65
|
|
66 return CONTROL_UNKNOWN;
|
|
67 }
|
|
68
|
|
69 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|
70 if(fmt==IMGFMT_YUY2) return 3;
|
|
71 if(fmt==IMGFMT_RGB24) return 1;
|
|
72 return 0;
|
|
73 }
|
|
74
|
7368
|
75 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
5577
|
76
|
|
77 dv_encode_full_frame(vf->priv->enc, mpi->planes,
|
|
78 (mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb,
|
|
79 mux_v->buffer);
|
|
80
|
|
81 mencoder_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10);
|
7368
|
82 return 1;
|
5577
|
83 }
|
|
84
|
|
85 //===========================================================================//
|
|
86
|
|
87 static int vf_open(vf_instance_t *vf, char* args){
|
|
88 vf->config=config;
|
|
89 vf->control=control;
|
|
90 vf->query_format=query_format;
|
|
91 vf->put_image=put_image;
|
|
92 vf->priv=malloc(sizeof(struct vf_priv_s));
|
|
93 memset(vf->priv,0,sizeof(struct vf_priv_s));
|
7557
|
94 vf->priv->mux=(aviwrite_stream_t*)args;
|
5577
|
95
|
|
96 vf->priv->enc=dv_encoder_new(1,1,1); // FIXME, parse some options!
|
|
97 if(!vf->priv->enc) return 0;
|
|
98
|
|
99 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER));
|
|
100 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
|
|
101 mux_v->bih->biWidth=0;
|
|
102 mux_v->bih->biHeight=0;
|
|
103 mux_v->bih->biCompression=mmioFOURCC('d','v','s','d');
|
|
104 mux_v->bih->biPlanes=1;
|
|
105 mux_v->bih->biBitCount=24;
|
|
106
|
|
107 return 1;
|
|
108 }
|
|
109
|
|
110 vf_info_t ve_info_libdv = {
|
|
111 "DV encoder using libdv",
|
|
112 "libdv",
|
|
113 "A'rpi",
|
|
114 "for internal use by mencoder",
|
|
115 vf_open
|
|
116 };
|
|
117
|
|
118 //===========================================================================//
|
|
119 #endif
|