static int amc_fill_frame( IJKFF_Pipenode *node, AVFrame *frame, int *got_frame, int output_buffer_index, int acodec_serial, SDL_AMediaCodecBufferInfo *buffer_info) { IJKFF_Pipenode_Opaque *opaque = node->opaque; FFPlayer *ffp = opaque->ffp; VideoState *is = ffp->is; frame->opaque = SDL_VoutAndroid_obtainBufferProxy(opaque->weak_vout, acodec_serial, output_buffer_index, buffer_info); if (!frame->opaque) goto fail; frame->width = opaque->frame_width; frame->height = opaque->frame_height; frame->format = IJK_AV_PIX_FMT__ANDROID_MEDIACODEC; frame->sample_aspect_ratio = opaque->avctx->sample_aspect_ratio; frame->pts = av_rescale_q(buffer_info->presentationTimeUs, AV_TIME_BASE_Q, is->video_st->time_base); if (frame->pts < 0) frame->pts = AV_NOPTS_VALUE; // ALOGE("%s: %f", __func__, (float)frame->pts); *got_frame = 1; return 0; fail: *got_frame = 0; return -1; }
static int amc_queue_picture_buffer( IJKFF_Pipenode *node, int output_buffer_index, int acodec_serial, SDL_AMediaCodecBufferInfo *buffer_info) { IJKFF_Pipenode_Opaque *opaque = node->opaque; FFPlayer *ffp = opaque->ffp; VideoState *is = ffp->is; AVFrame picture; AVRational tb = is->video_st->time_base; AVRational frame_rate = av_guess_frame_rate(is->ic, is->video_st, NULL); double duration = (frame_rate.num && frame_rate.den ? av_q2d((AVRational){frame_rate.den, frame_rate.num}) : 0); int64_t amc_pts = av_rescale_q(buffer_info->presentationTimeUs, AV_TIME_BASE_Q, is->video_st->time_base); double pts = amc_pts < 0 ? NAN : amc_pts * av_q2d(tb); memset(&picture, 0, sizeof(AVFrame)); picture.opaque = SDL_VoutAndroid_obtainBufferProxy(opaque->weak_vout, acodec_serial, output_buffer_index); picture.width = opaque->frame_width; picture.height = opaque->frame_height; picture.format = SDL_FCC__AMC; picture.sample_aspect_ratio = opaque->avctx->sample_aspect_ratio; int ret = ffp_queue_picture(opaque->ffp, &picture, pts, duration, 0, is->viddec.pkt_serial); if (ret) { if (picture.opaque && buffer_info >= 0) SDL_VoutAndroid_releaseBufferProxyP(opaque->weak_vout, (SDL_AMediaCodecBufferProxy **)&picture.opaque, false); } return ret; }