vo_gl: Some small whitespace and {} cosmetics
[mplayer/glamo.git] / libmpcodecs / ve_libdv.c
blobf1e265398e3b89ee883e9387f8edd3afaa495a47
1 /*
2 * requires libdv-0.9.5 !!!
3 * (v0.9.0 is too old and has no encoding functionality exported!)
5 * This file is part of MPlayer.
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "config.h"
27 #include "mp_msg.h"
29 #include "codec-cfg.h"
30 #include "stream/stream.h"
31 #include "libmpdemux/demuxer.h"
32 #include "libmpdemux/stheader.h"
34 #include "stream/stream.h"
35 #include "libmpdemux/muxer.h"
37 #include "img_format.h"
38 #include "mp_image.h"
39 #include "vf.h"
41 #include <libdv/dv.h>
43 #ifndef DV_WIDTH
44 #define DV_WIDTH 720
45 #define DV_PAL_HEIGHT 576
46 #define DV_NTSC_HEIGHT 480
47 #endif
49 struct vf_priv_s {
50 muxer_stream_t* mux;
51 dv_encoder_t* enc;
54 #define mux_v (vf->priv->mux)
56 //===========================================================================//
58 static int config(struct vf_instance *vf,
59 int width, int height, int d_width, int d_height,
60 unsigned int flags, unsigned int outfmt){
62 if(width!=DV_WIDTH || (height!=DV_PAL_HEIGHT && height!=DV_NTSC_HEIGHT)){
63 mp_msg(MSGT_VFILTER,MSGL_ERR,"DV: only 720x480 (NTSC) and 720x576 (PAL) resolutions allowed! Try with -vf scale=720:480\n");
66 vf->priv->enc->isPAL=(height==DV_PAL_HEIGHT);
67 vf->priv->enc->is16x9=(d_width/(float)d_height > 1.7); // 16:9=1.777777
68 vf->priv->enc->vlc_encode_passes=3;
69 vf->priv->enc->static_qno=0;
70 vf->priv->enc->force_dct=0;
72 mux_v->bih->biWidth=width;
73 mux_v->bih->biHeight=height;
74 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
75 mux_v->aspect = (float)d_width/d_height;
77 return 1;
80 static int control(struct vf_instance *vf, int request, void* data){
82 return CONTROL_UNKNOWN;
85 static int query_format(struct vf_instance *vf, unsigned int fmt){
86 if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
87 if(fmt==IMGFMT_RGB24) return VFCAP_CSP_SUPPORTED;
88 return 0;
91 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
93 dv_encode_full_frame(vf->priv->enc, mpi->planes,
94 (mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb,
95 mux_v->buffer);
97 muxer_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10, pts, pts);
98 return 1;
101 //===========================================================================//
103 static int vf_open(vf_instance_t *vf, char* args){
104 vf->config=config;
105 vf->default_caps=VFCAP_CONSTANT;
106 vf->control=control;
107 vf->query_format=query_format;
108 vf->put_image=put_image;
109 vf->priv=malloc(sizeof(struct vf_priv_s));
110 memset(vf->priv,0,sizeof(struct vf_priv_s));
111 vf->priv->mux=(muxer_stream_t*)args;
113 vf->priv->enc=dv_encoder_new(0,1,1); // FIXME, parse some options!
114 if(!vf->priv->enc) return 0;
116 mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER));
117 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
118 mux_v->bih->biWidth=0;
119 mux_v->bih->biHeight=0;
120 mux_v->bih->biCompression=mmioFOURCC('d','v','s','d');
121 mux_v->bih->biPlanes=1;
122 mux_v->bih->biBitCount=24;
124 return 1;
127 vf_info_t ve_info_libdv = {
128 "DV encoder using libdv",
129 "libdv",
130 "A'rpi",
131 "for internal use by mencoder",
132 vf_open
135 //===========================================================================//