12 // 100=best >=80 very good >=50 fast
15 #include "img_format.h"
19 //#include "libvo/fastmemcpy.h"
23 unsigned char* outbuf
;
25 fame_parameters_t params
;
30 //===========================================================================//
32 static int config(struct vf_instance_s
* vf
,
33 int width
, int height
, int d_width
, int d_height
,
34 unsigned int flags
, unsigned int outfmt
){
35 if(vf_next_query_format(vf
,IMGFMT_MPEGPES
)<=0) return 0;
37 vf
->priv
->params
.width
=width
;
38 vf
->priv
->params
.height
=height
;
40 vf
->priv
->outbuf_size
=10000+width
*height
; // must be enough!
41 if(vf
->priv
->outbuf
) free(vf
->priv
->outbuf
);
42 vf
->priv
->outbuf
= malloc(vf
->priv
->outbuf_size
);
44 fame_init(vf
->priv
->ctx
,&vf
->priv
->params
,vf
->priv
->outbuf
,vf
->priv
->outbuf_size
);
46 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,IMGFMT_MPEGPES
);
49 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
){
61 // out_size = fame_encode_frame(vf->priv->ctx, &yuv, NULL);
62 fame_start_frame(vf
->priv
->ctx
, &yuv
, NULL
);
63 out_size
= fame_encode_slice(vf
->priv
->ctx
);
64 fame_end_frame(vf
->priv
->ctx
, NULL
);
66 if(out_size
<=0) return 1;
68 dmpi
=vf_get_image(vf
->next
,IMGFMT_MPEGPES
,
72 vf
->priv
->pes
.data
=vf
->priv
->outbuf
;
73 vf
->priv
->pes
.size
=out_size
;
74 vf
->priv
->pes
.id
=0x1E0;
75 vf
->priv
->pes
.timestamp
=-1; // dunno
77 dmpi
->planes
[0]=(void*) &vf
->priv
->pes
;
79 return vf_next_put_image(vf
,dmpi
, MP_NOPTS_VALUE
);
82 //===========================================================================//
84 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
){
89 // return (vf_next_query_format(vf,IMGFMT_MPEGPES) & (~(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE)));
90 return (vf_next_query_format(vf
,IMGFMT_MPEGPES
) & (~(VFCAP_CSP_SUPPORTED_BY_HW
)));
95 static int open(vf_instance_t
*vf
, char* args
){
100 vf
->put_image
=put_image
;
101 vf
->query_format
=query_format
;
102 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
103 memset(vf
->priv
,0,sizeof(struct vf_priv_s
));
105 vf
->priv
->ctx
=fame_open();
107 mp_msg(MSGT_VFILTER
, MSGL_ERR
, MSGTR_MPCODECS_FatalCantOpenlibFAME
);
111 // TODO: parse args ->
112 if(args
) sscanf(args
, "%d:%f", &p_quality
, &p_fps
);
116 vf
->priv
->params
.quality
=p_quality
?p_quality
:QUALITY
;
117 vf
->priv
->params
.bitrate
=0;
119 // fixed bitrate (in kbits)
120 vf
->priv
->params
.quality
=QUALITY
;
121 vf
->priv
->params
.bitrate
=1000*p_quality
;
124 if(p_fps
<1) p_fps
=25.0;
125 if(p_fps
== ((int)p_fps
)){
126 vf
->priv
->params
.frame_rate_num
=p_fps
;
127 vf
->priv
->params
.frame_rate_den
=1;
129 vf
->priv
->params
.frame_rate_num
=p_fps
*1001;
130 vf
->priv
->params
.frame_rate_den
=1001;
133 vf
->priv
->params
.coding
="I";
134 vf
->priv
->params
.slices_per_frame
=1;
135 vf
->priv
->params
.frames_per_sequence
=(int)p_fps
;
136 vf
->priv
->params
.shape_quality
=100;
137 vf
->priv
->params
.search_range
=8; // for "IPPP" only
138 vf
->priv
->params
.verbose
=0;
139 vf
->priv
->params
.profile
="mpeg1"; // TODO
144 vf_info_t vf_info_fame
= {
145 "realtime mpeg1 encoding with libFAME",
153 //===========================================================================//