static mblk_t * pixconv_alloc_mblk(PixConvState *s){ if (s->yuv_msg!=NULL){ int ref=s->yuv_msg->b_datap->db_ref; if (ref==1){ return dupmsg(s->yuv_msg); }else{ /*the last msg is still referenced by somebody else*/ ms_message("Somebody still retaining yuv buffer (ref=%i)",ref); freemsg(s->yuv_msg); s->yuv_msg=NULL; } } s->yuv_msg=yuv_buf_alloc(&s->outbuf,s->size.width,s->size.height); return dupmsg(s->yuv_msg); }
static mblk_t *size_conv_alloc_mblk(SizeConvState *s){ if (s->om!=NULL){ int ref=s->om->b_datap->db_ref; if (ref==1){ return dupmsg(s->om); }else{ /*the last msg is still referenced by somebody else*/ ms_message("size_conv_alloc_mblk: Somebody still retaining yuv buffer (ref=%i)",ref); freemsg(s->om); s->om=NULL; } } s->om=yuv_buf_alloc(&s->outbuf,s->target_vsize.width,s->target_vsize.height); return dupmsg(s->om); }
static mblk_t *get_as_yuvmsg(MSFilter *f, DecData *s, AVFrame *orig){ AVCodecContext *ctx=&s->av_context; if (s->outbuf.w!=ctx->width || s->outbuf.h!=ctx->height){ if (s->sws_ctx!=NULL){ ms_sws_freeContext(s->sws_ctx); s->sws_ctx=NULL; freemsg(s->yuv_msg); s->yuv_msg=NULL; } ms_message("Getting yuv picture of %ix%i",ctx->width,ctx->height); s->yuv_msg=yuv_buf_alloc(&s->outbuf,ctx->width,ctx->height); s->outbuf.w=ctx->width; s->outbuf.h=ctx->height; s->sws_ctx=ms_sws_getContext(ctx->width,ctx->height,ctx->pix_fmt, ctx->width,ctx->height,PIX_FMT_YUV420P,SWS_FAST_BILINEAR, NULL, NULL, NULL); } if (ms_sws_scale(s->sws_ctx,orig->data,orig->linesize, 0, ctx->height, s->outbuf.planes, s->outbuf.strides)<0){ ms_error("%s: error in sws_scale().",f->desc->name); } return dupmsg(s->yuv_msg); }