Mercurial > mplayer.hg
annotate libmpcodecs/vf_fame.c @ 14504:e394a9cfaf3f
Transition of suboption parser to subopt-helper parser.
Removal of stupid malloc_failed function.
author | ivo |
---|---|
date | Sat, 15 Jan 2005 20:06:49 +0000 |
parents | 27706a9c2015 |
children | 6ff3379a0862 |
rev | line source |
---|---|
5536 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
6 #include "../config.h" | |
7 #include "../mp_msg.h" | |
8 | |
9 //#ifdef USE_LIBFAME | |
10 | |
11 // 100=best >=80 very good >=50 fast | |
12 #define QUALITY 90 | |
13 | |
5607 | 14 #include "img_format.h" |
15 #include "mp_image.h" | |
5536 | 16 #include "vf.h" |
17 | |
18 //#include "../libvo/fastmemcpy.h" | |
12605
27706a9c2015
libfame has been removed from MPlayer long ago. Compilation fix pointed
diego
parents:
9593
diff
changeset
|
19 #include <fame.h> |
5536 | 20 |
21 struct vf_priv_s { | |
22 unsigned char* outbuf; | |
23 int outbuf_size; | |
24 fame_parameters_t params; | |
25 fame_context_t *ctx; | |
26 vo_mpegpes_t pes; | |
27 }; | |
28 | |
29 //===========================================================================// | |
30 | |
31 static int config(struct vf_instance_s* vf, | |
32 int width, int height, int d_width, int d_height, | |
33 unsigned int flags, unsigned int outfmt){ | |
34 if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0; | |
35 | |
36 vf->priv->params.width=width; | |
37 vf->priv->params.height=height; | |
38 | |
39 vf->priv->outbuf_size=10000+width*height; // must be enough! | |
40 if(vf->priv->outbuf) free(vf->priv->outbuf); | |
41 vf->priv->outbuf = malloc(vf->priv->outbuf_size); | |
42 | |
43 fame_init(vf->priv->ctx,&vf->priv->params,vf->priv->outbuf,vf->priv->outbuf_size); | |
44 | |
45 return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES); | |
46 } | |
47 | |
7368 | 48 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
5536 | 49 fame_yuv_t yuv; |
50 mp_image_t *dmpi; | |
51 int out_size; | |
52 | |
53 yuv.w=mpi->width; | |
54 yuv.h=mpi->height; | |
6260 | 55 yuv.p=mpi->stride[0]; |
5536 | 56 yuv.y=mpi->planes[0]; |
57 yuv.u=mpi->planes[1]; | |
58 yuv.v=mpi->planes[2]; | |
59 | |
6260 | 60 // out_size = fame_encode_frame(vf->priv->ctx, &yuv, NULL); |
61 fame_start_frame(vf->priv->ctx, &yuv, NULL); | |
62 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
|
63 fame_end_frame(vf->priv->ctx, NULL); |
5536 | 64 |
7368 | 65 if(out_size<=0) return 1; |
5536 | 66 |
67 dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES, | |
68 MP_IMGTYPE_EXPORT, 0, | |
69 mpi->w, mpi->h); | |
70 | |
71 vf->priv->pes.data=vf->priv->outbuf; | |
72 vf->priv->pes.size=out_size; | |
73 vf->priv->pes.id=0x1E0; | |
74 vf->priv->pes.timestamp=-1; // dunno | |
75 | |
7557 | 76 dmpi->planes[0]=(void*) &vf->priv->pes; |
5536 | 77 |
7368 | 78 return vf_next_put_image(vf,dmpi); |
5536 | 79 } |
80 | |
81 //===========================================================================// | |
82 | |
83 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
84 switch(fmt){ | |
85 case IMGFMT_YV12: | |
86 case IMGFMT_I420: | |
87 case IMGFMT_IYUV: | |
6260 | 88 // return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE))); |
89 return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW))); | |
5536 | 90 } |
91 return 0; | |
92 } | |
93 | |
94 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
|
95 int p_quality=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
96 float p_fps=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
97 |
5536 | 98 vf->config=config; |
99 vf->put_image=put_image; | |
100 vf->query_format=query_format; | |
101 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
102 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
103 | |
104 vf->priv->ctx=fame_open(); | |
105 if(!vf->priv->ctx){ | |
106 printf("FATAL: cannot open libFAME!\n"); | |
107 return 0; | |
108 } | |
109 | |
110 // TODO: parse args -> | |
6261
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
111 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
|
112 |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
113 if(p_quality<=100){ |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
114 // fixed quality |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
115 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
|
116 vf->priv->params.bitrate=0; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
117 } else { |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
118 // fixed bitrate (in kbits) |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
119 vf->priv->params.quality=QUALITY; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
120 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
|
121 } |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
122 |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
123 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
|
124 if(p_fps == ((int)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_num=p_fps; |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
126 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
|
127 } else { |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
128 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
|
129 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
|
130 } |
5b76ba46fc72
fame=quality:fps args support, small fixes for 0.9.0 api
arpi
parents:
6260
diff
changeset
|
131 |
5536 | 132 vf->priv->params.coding="I"; |
133 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
|
134 vf->priv->params.frames_per_sequence=(int)p_fps; |
5536 | 135 vf->priv->params.shape_quality=100; |
136 vf->priv->params.search_range=8; // for "IPPP" only | |
137 vf->priv->params.verbose=0; | |
6260 | 138 vf->priv->params.profile="mpeg1"; // TODO |
5536 | 139 |
140 return 1; | |
141 } | |
142 | |
143 vf_info_t vf_info_fame = { | |
144 "realtime mpeg1 encoding with libFAME", | |
145 "fame", | |
146 "A'rpi", | |
147 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7557
diff
changeset
|
148 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7557
diff
changeset
|
149 NULL |
5536 | 150 }; |
151 | |
152 //===========================================================================// | |
153 //#endif |