| 591 | }; |
| 592 | |
| 593 | static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx) |
| 594 | { |
| 595 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 596 | VAAPIEncodeMPEG2Context *priv = avctx->priv_data; |
| 597 | |
| 598 | ctx->codec = &vaapi_encode_type_mpeg2; |
| 599 | |
| 600 | if (avctx->profile == AV_PROFILE_UNKNOWN) |
| 601 | avctx->profile = priv->profile; |
| 602 | if (avctx->level == AV_LEVEL_UNKNOWN) |
| 603 | avctx->level = priv->level; |
| 604 | |
| 605 | // Reject unknown levels (these are required to set f_code for |
| 606 | // motion vector encoding). |
| 607 | switch (avctx->level) { |
| 608 | case 4: // High |
| 609 | case 6: // High 1440 |
| 610 | case 8: // Main |
| 611 | case 10: // Low |
| 612 | break; |
| 613 | default: |
| 614 | av_log(avctx, AV_LOG_ERROR, "Unknown MPEG-2 level %d.\n", |
| 615 | avctx->level); |
| 616 | return AVERROR(EINVAL); |
| 617 | } |
| 618 | |
| 619 | if (avctx->height % 4096 == 0 || avctx->width % 4096 == 0) { |
| 620 | av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support picture " |
| 621 | "height or width divisible by 4096.\n"); |
| 622 | return AVERROR(EINVAL); |
| 623 | } |
| 624 | |
| 625 | ctx->desired_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE | |
| 626 | VA_ENC_PACKED_HEADER_PICTURE; |
| 627 | |
| 628 | return ff_vaapi_encode_init(avctx); |
| 629 | } |
| 630 | |
| 631 | static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx) |
| 632 | { |
nothing calls this directly
no test coverage detected