/*********************************************************************** ** ** Process one frame ** ***********************************************************************/ static int ffmpeg_vf_process(vf_wrapper_t *wrapper, dt_av_frame_t *frame) { vf_ffmpeg_ctx_t *vf_ctx = (vf_ffmpeg_ctx_t *)(wrapper->vf_priv); if (vf_ctx->need_process == 0) { dt_info(TAG, "[%s:%d] no need to process but called \n", __FUNCTION__, __LINE__); return 0; } int ret = convert_picture(wrapper, frame); if (ret < 0) { dt_info(TAG, "[%s:%d] vf process failed \n", __FUNCTION__, __LINE__); } return ret; }
MEDIACODEC_API MediaVideoFrame_t * DecodeVideoFrame(MediaCodecContext_t* ctx,MediaPacket_t* pkt){ MediaVideoFrame_t * frame; //printf("0x%x,0x%x\n",(unsigned int)ctx,(unsigned int)pkt); if(pkt->stream != ctx->stream){ printf("codeclib::stream not equal(%d!=%d)\n",pkt->stream,ctx->stream); //return NULL; } int frameFinished; AVCodecContext* codecCtx; codecCtx = (AVCodecContext*)ctx->codecCtx; //avcodec_decode_video(codecCtx, ctx->frame, &frameFinished,pkt->data, pkt->size); AVPacket avpkt; av_init_packet(&avpkt); avpkt.data = pkt->data; avpkt.size = pkt->size; avcodec_decode_video2(codecCtx, ctx->frame, &frameFinished,&avpkt); if( !frameFinished ){ return NULL; } int r; r = convert_picture(ctx->rgbframe24,ctx->frame,codecCtx->width,codecCtx->height,codecCtx->pix_fmt,PIX_FMT_RGB24); if(r){ return NULL; } // 复制一份 frame = new MediaVideoFrame_t(); frame->rgb24 = (StreamByte_t*)malloc(ctx->bufsize); frame->size =ctx->bufsize; memcpy(frame->rgb24,ctx->buffer,ctx->bufsize); frame->width = ctx->frame->width; frame->height = ctx->frame->height; frame->sequence = pkt->sequence; frame->duration = pkt->duration; //printf("after decode pts:%d\n",ctx->frame-); return frame; }