Fix planarCopy to ignore the GRAY8 "pseudo"-palette, fixes libavtest regression test.
[mplayer/glamo.git] / libmpcodecs / ve_libdv.c
blobfab9628d3c6c605632d23858fb82f5ff8ed3e8ee
1 // requires libdv-0.9.5 !!!
2 // (v0.9.0 is too old and has no encoding functionality exported!)
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
8 #include "config.h"
9 #include "mp_msg.h"
11 #include "codec-cfg.h"
12 #include "stream/stream.h"
13 #include "libmpdemux/demuxer.h"
14 #include "libmpdemux/stheader.h"
16 #include "stream/stream.h"
17 #include "libmpdemux/muxer.h"
19 #include "img_format.h"
20 #include "mp_image.h"
21 #include "vf.h"
23 #include <libdv/dv.h>
25 #ifndef DV_WIDTH
26 #define DV_WIDTH 720
27 #define DV_PAL_HEIGHT 576
28 #define DV_NTSC_HEIGHT 480
29 #endif
31 struct vf_priv_s {
32 muxer_stream_t* mux;
33 dv_encoder_t* enc;
36 #define mux_v (vf->priv->mux)
38 //===========================================================================//
40 static int config(struct vf_instance_s* vf,
41 int width, int height, int d_width, int d_height,
42 unsigned int flags, unsigned int outfmt){
44 if(width!=DV_WIDTH || (height!=DV_PAL_HEIGHT && height!=DV_NTSC_HEIGHT)){
45 mp_msg(MSGT_VFILTER,MSGL_ERR,"DV: only 720x480 (NTSC) and 720x576 (PAL) resolutions allowed! Try with -vf scale=720:480\n");
48 vf->priv->enc->isPAL=(height==DV_PAL_HEIGHT);
49 vf->priv->enc->is16x9=(d_width/(float)d_height > 1.7); // 16:9=1.777777
50 vf->priv->enc->vlc_encode_passes=3;
51 vf->priv->enc->static_qno=0;
52 vf->priv->enc->force_dct=0;
54 mux_v->bih->biWidth=width;
55 mux_v->bih->biHeight=height;
56 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
57 mux_v->aspect = (float)d_width/d_height;
59 return 1;
62 static int control(struct vf_instance_s* vf, int request, void* data){
64 return CONTROL_UNKNOWN;
67 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
68 if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
69 if(fmt==IMGFMT_RGB24) return VFCAP_CSP_SUPPORTED;
70 return 0;
73 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
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);
79 muxer_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10, pts, pts);
80 return 1;
83 //===========================================================================//
85 static int vf_open(vf_instance_t *vf, char* args){
86 vf->config=config;
87 vf->default_caps=VFCAP_CONSTANT;
88 vf->control=control;
89 vf->query_format=query_format;
90 vf->put_image=put_image;
91 vf->priv=malloc(sizeof(struct vf_priv_s));
92 memset(vf->priv,0,sizeof(struct vf_priv_s));
93 vf->priv->mux=(muxer_stream_t*)args;
95 vf->priv->enc=dv_encoder_new(0,1,1); // FIXME, parse some options!
96 if(!vf->priv->enc) return 0;
98 mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER));
99 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
100 mux_v->bih->biWidth=0;
101 mux_v->bih->biHeight=0;
102 mux_v->bih->biCompression=mmioFOURCC('d','v','s','d');
103 mux_v->bih->biPlanes=1;
104 mux_v->bih->biBitCount=24;
106 return 1;
109 vf_info_t ve_info_libdv = {
110 "DV encoder using libdv",
111 "libdv",
112 "A'rpi",
113 "for internal use by mencoder",
114 vf_open
117 //===========================================================================//