Mercurial > mplayer.hg
changeset 5536:3cd118559307
vf_fame added - yv12->mpes converter
author | arpi |
---|---|
date | Mon, 08 Apr 2002 23:12:22 +0000 |
parents | db6de8e38f7d |
children | 6debecc64f2b |
files | libmpcodecs/Makefile libmpcodecs/vf.c libmpcodecs/vf_fame.c |
diffstat | 3 files changed, 130 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/Makefile Mon Apr 08 21:25:58 2002 +0000 +++ b/libmpcodecs/Makefile Mon Apr 08 23:12:22 2002 +0000 @@ -5,7 +5,7 @@ AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dk4adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c ad_faad.c ad_vorbis.c ad_libmad.c VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c -VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c +VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_fame.c ifeq ($(PNG),yes) VIDEO_SRCS += vd_mpng.c
--- a/libmpcodecs/vf.c Mon Apr 08 21:25:58 2002 +0000 +++ b/libmpcodecs/vf.c Mon Apr 08 23:12:22 2002 +0000 @@ -14,6 +14,7 @@ extern vf_info_t vf_info_expand; extern vf_info_t vf_info_pp; extern vf_info_t vf_info_scale; +extern vf_info_t vf_info_fame; char** vo_plugin_args=(char**) NULL; @@ -25,6 +26,7 @@ &vf_info_scale, // &vf_info_osd, &vf_info_vo, + &vf_info_fame, NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmpcodecs/vf_fame.c Mon Apr 08 23:12:22 2002 +0000 @@ -0,0 +1,127 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> + +#include "../config.h" +#include "../mp_msg.h" + +//#ifdef USE_LIBFAME + +// 100=best >=80 very good >=50 fast +#define QUALITY 90 + +#include "../libvo/img_format.h" +#include "../mp_image.h" +#include "vf.h" + +//#include "../libvo/fastmemcpy.h" +#include "../libfame/fame.h" + +struct vf_priv_s { + unsigned char* outbuf; + int outbuf_size; + fame_parameters_t params; + fame_context_t *ctx; + vo_mpegpes_t pes; +}; + +//===========================================================================// + +static int config(struct vf_instance_s* vf, + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt){ + if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0; + + vf->priv->params.width=width; + vf->priv->params.height=height; + + vf->priv->outbuf_size=10000+width*height; // must be enough! + if(vf->priv->outbuf) free(vf->priv->outbuf); + vf->priv->outbuf = malloc(vf->priv->outbuf_size); + + fame_init(vf->priv->ctx,&vf->priv->params,vf->priv->outbuf,vf->priv->outbuf_size); + + return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES); +} + +static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){ + fame_yuv_t yuv; + mp_image_t *dmpi; + int out_size; + + yuv.w=mpi->width; + yuv.h=mpi->height; + yuv.y=mpi->planes[0]; + yuv.u=mpi->planes[1]; + yuv.v=mpi->planes[2]; + + out_size = fame_encode_frame(vf->priv->ctx, &yuv, NULL); + + if(out_size<=0) return; + + dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES, + MP_IMGTYPE_EXPORT, 0, + mpi->w, mpi->h); + + vf->priv->pes.data=vf->priv->outbuf; + vf->priv->pes.size=out_size; + vf->priv->pes.id=0x1E0; + vf->priv->pes.timestamp=-1; // dunno + + dmpi->planes[0]=&vf->priv->pes; + + vf_next_put_image(vf,dmpi); +} + +//===========================================================================// + +static int query_format(struct vf_instance_s* vf, unsigned int fmt){ + switch(fmt){ + case IMGFMT_YV12: + case IMGFMT_I420: + case IMGFMT_IYUV: + return 3; //vf_next_query_format(vf,fmt); + } + return 0; +} + +static int open(vf_instance_t *vf, char* args){ + vf->config=config; + vf->put_image=put_image; + vf->query_format=query_format; + vf->priv=malloc(sizeof(struct vf_priv_s)); + memset(vf->priv,0,sizeof(struct vf_priv_s)); + + vf->priv->ctx=fame_open(); + if(!vf->priv->ctx){ + printf("FATAL: cannot open libFAME!\n"); + return 0; + } + + // TODO: parse args -> + vf->priv->params.coding="I"; + vf->priv->params.quality=QUALITY; + vf->priv->params.bitrate=0; + vf->priv->params.slices_per_frame=1; + vf->priv->params.frames_per_sequence=25; //0xffffffff; + vf->priv->params.frame_rate_num=25; + vf->priv->params.frame_rate_den=1; + vf->priv->params.shape_quality=100; + vf->priv->params.search_range=8; // for "IPPP" only + vf->priv->params.verbose=0; + vf->priv->params.profile=NULL; // TODO + + return 1; +} + +vf_info_t vf_info_fame = { + "realtime mpeg1 encoding with libFAME", + "fame", + "A'rpi", + "", + open +}; + +//===========================================================================// +//#endif