📄 fame.c
字号:
/* None. */void fame_init(fame_context_t * context, fame_parameters_t *p, unsigned char *buffer, unsigned int size){ unsigned long arch_flags; /* Print information message */ if(p->verbose) { FAME_INFO("libfame %s Copyright (C) 2000-2002 Vivien Chappelier\n", LIBFAME_VERSION); FAME_INFO("This library is provided under the terms of the LGPL. " "See COPYING for details\n"); } /* Choose profile */ context->profile = fame_get_object(context, "profile"); if(context->profile == NULL) FAME_FATAL("could not find 'profile'\n"); if(p->verbose) { FAME_INFO("%s %dx%d @ %.2f fps %d%% quality ", context->profile->name, p->width, p->height, (float)p->frame_rate_num/(float)p->frame_rate_den, p->quality); if(p->search_range) FAME_INFO("%d pixel search range\n", p->search_range); else FAME_INFO("adaptive search range\n"); FAME_INFO("%s coding sequence\n", p->coding); } FAME_PROFILE(context->profile)->init(FAME_PROFILE(context->profile), context, p, buffer, size); arch_flags = cpuflags();#if defined(HAS_MMX) if(arch_flags & X86_HAS_MMX) { if(p->verbose) FAME_INFO("Using MMX arithmetic\n"); } else { FAME_FATAL("MMX not detected!\n" "Consider recompiling without --enable-mmx in configure\n"); }#else if(p->verbose) FAME_INFO("Using floating point arithmetic\n");#endif /* for DEPRECATED fame_encode_frame */ context->priv->fame_encode_frame_first_call = 1; context->priv->slices_per_frame = p->slices_per_frame;}/* fame_start_frame *//* *//* Description: *//* Start encoding a frame. *//* *//* Arguments: *//* fame_context_t * context: the context handle returned by fame_open *//* fame_yuv_t * yuv: the input frame in raw YUV format (YV12 planar) *//* unsigned char * mask: the input mask (0 = transparent, 255 = opaque) *//* *//* Return value: *//* None. */void fame_start_frame(fame_context_t *context, fame_yuv_t *yuv, unsigned char *mask){ FAME_PROFILE(context->profile)->enter(FAME_PROFILE(context->profile), yuv, mask);}/* fame_encode_slice *//* *//* Description: *//* Encode a slice of a frame. *//* *//* Arguments: *//* fame_context_t * context: the context handle returned by fame_open *//* *//* Return value: *//* int : the number of bytes written to buffer */int fame_encode_slice(fame_context_t *context){ return(FAME_PROFILE(context->profile)->encode(FAME_PROFILE(context->profile)));}/* fame_end_frame *//* *//* Description: *//* Finish encoding of a frame. *//* *//* Arguments: *//* fame_context_t * context: the context handle returned by fame_open *//* fame_frame_statistics_t * stats: information about the encoding *//* *//* Return value: *//* None. */void fame_end_frame(fame_context_t *context, fame_frame_statistics_t *stats){ FAME_PROFILE(context->profile)->leave(FAME_PROFILE(context->profile), stats);}/* fame_close *//* *//* Description: *//* Flush remaining encoded data and cleanup everything. *//* *//* Arguments: *//* fame_context_t * context: the context handle returned by fame_open *//* *//* Return value: *//* int : the number of bytes written to buffer */int fame_close(fame_context_t *context){ int bytes_written = 0; fame_list_t *l, *p; if(context->profile && FAME_PROFILE(context->profile)->close) bytes_written = FAME_PROFILE(context->profile)->close(FAME_PROFILE(context->profile)); if(context->type_list != NULL) { l = context->type_list; while(l->next != NULL) { p = l; l = l->next; fame_free(p); } fame_free(l); } FAME_DELETE(context->priv->profile_mpeg1); FAME_DELETE(context->priv->profile_mpeg4_simple); FAME_DELETE(context->priv->profile_mpeg4_shape); FAME_DELETE(context->priv->profile_stats); FAME_DELETE(context->priv->encoder_mpeg); FAME_DELETE(context->priv->decoder_mpeg); FAME_DELETE(context->priv->motion_none); FAME_DELETE(context->priv->motion_pmvfast); FAME_DELETE(context->priv->motion_fourstep); FAME_DELETE(context->priv->syntax_mpeg1); FAME_DELETE(context->priv->syntax_mpeg4); FAME_DELETE(context->priv->shape); FAME_DELETE(context->priv->rate); FAME_DELETE(context->priv->rate_simple); FAME_DELETE(context->priv->rate_1param); FAME_DELETE(context->priv->monitor); fame_free(context->priv); fame_free(context); return(bytes_written);}/* DEPRECATED */int fame_encode_frame(fame_context_t *context, fame_yuv_t *yuv, unsigned char *mask){ if(context->priv->fame_encode_frame_first_call) { context->priv->fame_encode_frame_first_call = 0; fprintf(stderr, "usage of fame_encode_frame is deprecated\n" "please use fame_start_frame, fame_encode_slice\n" "and fame_end_frame functions instead\n"); } if(context->priv->slices_per_frame != 1) { fprintf(stderr, "fame_encode_frame doesn't work when slices_per_frame != 1\n"); memset(&context->priv->stats, 0, sizeof(context->priv->stats)); return(context->priv->stats.actual_bits/8); } fame_start_frame(context, yuv, mask); fame_encode_slice(context); fame_end_frame(context, &context->priv->stats); return(context->priv->stats.actual_bits/8);}#if !defined(__GNUC__)#include <stdarg.h>/* va_* based error management by Petter Reinholdtsen */intFAME_INFO(const char *format, ...){ va_list va; va_start(va, format); vfprintf(stderr, format, va); va_end(va);}int FAME_WARNING(const char *format, ...){ va_list va; fprintf(stderr, "Warning: "); va_start(va, format); vfprintf(stderr, format, va); va_end(va);}int FAME_ERROR(const char *format, ...){ va_list va; fprintf(stderr, "Error: "); va_start(va, format); vfprintf(stderr, format, va); va_end(va);}int FAME_FATAL(const char *format, ...){ va_list va; fprintf(stderr, "Fatal: "); va_start(va, format); vfprintf(stderr, format, va); va_end(va); exit(-1);}#endif /* not __GNUC__ */#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <= 95 && __GNUC_PATCHLEVEL__ <= 3)/* gcc bug?? workaround */void __fame_dummy_call(int q){}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -