| 500 | } |
| 501 | |
| 502 | int copy_simple_frame(AVFrame *frame) { |
| 503 | |
| 504 | AVFrame tmp; |
| 505 | int ret; |
| 506 | |
| 507 | if (!frame->buf[0]) |
| 508 | return AVERROR(EINVAL); |
| 509 | |
| 510 | memset(&tmp, 0, sizeof(tmp)); |
| 511 | tmp.format = frame->format; |
| 512 | tmp.width = frame->width; |
| 513 | tmp.height = frame->height; |
| 514 | tmp.channels = frame->channels; |
| 515 | tmp.channel_layout = frame->channel_layout; |
| 516 | tmp.nb_samples = frame->nb_samples; |
| 517 | |
| 518 | if (frame->hw_frames_ctx) |
| 519 | ret = av_hwframe_get_buffer(frame->hw_frames_ctx, &tmp, 0); |
| 520 | else |
| 521 | ret = av_frame_get_buffer(&tmp, 0); |
| 522 | if (ret < 0) |
| 523 | return ret; |
| 524 | // need to reset frame info for which the av_hwframe_get_buffer may change |
| 525 | // the width or height according to the hw_frames_ctx. |
| 526 | tmp.format = frame->format; |
| 527 | tmp.width = frame->width; |
| 528 | tmp.height = frame->height; |
| 529 | tmp.channels = frame->channels; |
| 530 | tmp.channel_layout = frame->channel_layout; |
| 531 | tmp.nb_samples = frame->nb_samples; |
| 532 | |
| 533 | ret = av_frame_copy(&tmp, frame); |
| 534 | if (ret < 0) { |
| 535 | av_frame_unref(&tmp); |
| 536 | return ret; |
| 537 | } |
| 538 | |
| 539 | ret = av_frame_copy_props(&tmp, frame); |
| 540 | if (ret < 0) { |
| 541 | av_frame_unref(&tmp); |
| 542 | return ret; |
| 543 | } |
| 544 | |
| 545 | av_frame_unref(frame); |
| 546 | |
| 547 | *frame = tmp; |
| 548 | if (tmp.data == tmp.extended_data) |
| 549 | frame->extended_data = frame->data; |
| 550 | return 0; |
| 551 | } |
| 552 | |
| 553 | #ifdef BMF_USE_MEDIACODEC |
| 554 | int CFFDecoder::init_android_vm() { |