Mercurial > mplayer.hg
annotate libmpcodecs/vf_fame.c @ 20069:609c0cd1a85b
Add ASS subtitles to the subtitles file chooser dialog.
patch by Piotr Kaczuba, pepe attika_ath_cx
author | diego |
---|---|
date | Thu, 05 Oct 2006 18:39:06 +0000 |
parents | a1807995e2ab |
children |
rev | line source |
---|---|
5536 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
8 #include "help_mp.h" |
5536 | 9 |
10 // 100=best >=80 very good >=50 fast | |
11 #define QUALITY 90 | |
12 | |
5607 | 13 #include "img_format.h" |
14 #include "mp_image.h" | |
5536 | 15 #include "vf.h" |
16 | |
17012 | 17 //#include "libvo/fastmemcpy.h" |
12605
27706a9c2015
libfame has been removed from MPlayer long ago. Compilation fix pointed
diego
parents:
9593
diff
changeset
|
18 #include <fame.h> |
5536 | 19 |
20 struct vf_priv_s { | |
21 unsigned char* outbuf; | |
22 int outbuf_size; | |
23 fame_parameters_t params; | |
24 fame_context_t *ctx; | |
25 vo_mpegpes_t pes; | |
26 }; | |
27 | |
28 //===========================================================================// | |
29 | |
30 static int config(struct vf_instance_s* vf, | |
31 int width, int height, int d_width, int d_height, | |
32 unsigned int flags, unsigned int outfmt){ | |
33 if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0; | |
34 | |
35 vf->priv->params.width=width; | |
36 vf->priv->params.height=height; | |
37 | |
38 vf->priv->outbuf_size=10000+width*height; // must be enough! | |
39 if(vf->priv->outbuf) free(vf->priv->outbuf); | |
40 vf->priv->outbuf = malloc(vf->priv->outbuf_size); | |
41 | |
42 fame_init(vf->priv->ctx,&vf->priv->params,vf->priv->outbuf,vf->priv->outbuf_size); | |
43 | |
44 return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES); | |
45 } | |
46 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
47 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5536 | 48 fame_yuv_t yuv; |
49 mp_image_t *dmpi; | |
50 int out_size; | |
51 | |
52 yuv.w=mpi->width; | |
53 yuv.h=mpi->height; | |
6260 | 54 yuv.p=mpi->stride[0]; |
5536 | 55 yuv.y=mpi->planes[0]; |
56 yuv.u=mpi->planes[1]; | |
57 yuv.v=mpi->planes[2]; | |
58 | |
6260 | 59 // out_size = fame_encode_frame(vf->priv->ctx, &yuv, NULL); |
60 fame_start_frame(vf->priv->ctx, &yuv, NULL); | |
61 out_size = fame_encode_slice(vf->priv->ctx); | |
6261
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
62 fame_end_frame(vf->priv->ctx, NULL); |
5536 | 63 |
7368 | 64 if(out_size<=0) return 1; |
5536 | 65 |
66 dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES, | |
67 MP_IMGTYPE_EXPORT, 0, | |
68 mpi->w, mpi->h); | |
69 | |
70 vf->priv->pes.data=vf->priv->outbuf; | |
71 vf->priv->pes.size=out_size; | |
72 vf->priv->pes.id=0x1E0; | |
73 vf->priv->pes.timestamp=-1; // dunno | |
74 | |
7557 | 75 dmpi->planes[0]=(void*) &vf->priv->pes; |
5536 | 76 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
77 return vf_next_put_image(vf,dmpi, MP_NOPTS_VALUE); |
5536 | 78 } |
79 | |
80 //===========================================================================// | |
81 | |
82 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
83 switch(fmt){ | |
84 case IMGFMT_YV12: | |
85 case IMGFMT_I420: | |
86 case IMGFMT_IYUV: | |
6260 | 87 // return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE))); |
88 return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW))); | |
5536 | 89 } |
90 return 0; | |
91 } | |
92 | |
93 static int open(vf_instance_t *vf, char* args){ | |
6261
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
94 int p_quality=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
95 float p_fps=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
96 |
5536 | 97 vf->config=config; |
98 vf->put_image=put_image; | |
99 vf->query_format=query_format; | |
100 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
101 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
102 | |
103 vf->priv->ctx=fame_open(); | |
104 if(!vf->priv->ctx){ | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
105 mp_msg(MSGT_VFILTER, MSGL_ERR, MSGTR_MPCODECS_FatalCantOpenlibFAME); |
5536 | 106 return 0; |
107 } | |
108 | |
109 // TODO: parse args -> | |
6261
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
110 if(args) sscanf(args, "%d:%f", &p_quality, &p_fps); |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
111 |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
112 if(p_quality<=100){ |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
113 // fixed quality |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
114 vf->priv->params.quality=p_quality?p_quality:QUALITY; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
115 vf->priv->params.bitrate=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
116 } else { |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
117 // fixed bitrate (in kbits) |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
118 vf->priv->params.quality=QUALITY; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
119 vf->priv->params.bitrate=1000*p_quality; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
120 } |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
121 |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
122 if(p_fps<1) p_fps=25.0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
123 if(p_fps == ((int)p_fps)){ |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
124 vf->priv->params.frame_rate_num=p_fps; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
125 vf->priv->params.frame_rate_den=1; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
126 } else { |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
127 vf->priv->params.frame_rate_num=p_fps*1001; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
128 vf->priv->params.frame_rate_den=1001; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
129 } |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
130 |
5536 | 131 vf->priv->params.coding="I"; |
132 vf->priv->params.slices_per_frame=1; | |
6261
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
133 vf->priv->params.frames_per_sequence=(int)p_fps; |
5536 | 134 vf->priv->params.shape_quality=100; |
135 vf->priv->params.search_range=8; // for "IPPP" only | |
136 vf->priv->params.verbose=0; | |
6260 | 137 vf->priv->params.profile="mpeg1"; // TODO |
5536 | 138 |
139 return 1; | |
140 } | |
141 | |
142 vf_info_t vf_info_fame = { | |
143 "realtime mpeg1 encoding with libFAME", | |
144 "fame", | |
145 "A'rpi", | |
146 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7557
diff
changeset
|
147 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7557
diff
changeset
|
148 NULL |
5536 | 149 }; |
150 | |
151 //===========================================================================// |