x265 added support for alpha starting with build 210. While doing so, x265_encoder_encode() changed its fifth arg to an array of pointers to x265_picture. This broke building lavc/libx265.c This patch simply unbreaks the build and maintains existing single-layer non-alpha encoding support. Fixes #11130
Unified · Split
| @@ -661,7 +661,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 660 unmodified lines | ||
| 661 | 661 | { |
| 662 | 662 | libx265Context *ctx = avctx->priv_data; |
| 663 | 663 | x265_picture x265pic; |
| 664 | − x265_picture x265pic_out = { 0 }; | |
| 664 | +#if X265_BUILD >= 210 | |
| 665 | + x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS]; | |
| 666 | + x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS]; | |
| 667 | +#else | |
| 668 | + x265_picture x265pic_solo_out = { 0 }; | |
| 669 | +#endif | |
| 670 | + x265_picture* x265pic_out; | |
| 665 | 671 | x265_nal *nal; |
| 666 | 672 | x265_sei *sei; |
| 667 | 673 | uint8_t *dst; |
| @@ -798,8 +804,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 130 unmodified lines | ||
| 798 | 804 | #endif |
| 799 | 805 | } |
| 800 | 806 | |
| 807 | +#if X265_BUILD >= 210 | |
| 808 | + for (i = 0; i < MAX_SCALABLE_LAYERS; i++) | |
| 809 | + x265pic_lyrptr_out[i] = &x265pic_layers_out[i]; | |
| 810 | + | |
| 811 | + ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, | |
| 812 | + pic ? &x265pic : NULL, x265pic_lyrptr_out); | |
| 813 | +#else | |
| 801 | 814 | ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, |
| 802 | − pic ? &x265pic : NULL, &x265pic_out); | |
| 815 | + pic ? &x265pic : NULL, &x265pic_solo_out); | |
| 816 | +#endif | |
| 803 | 817 | |
| 804 | 818 | for (i = 0; i < sei->numPayloads; i++) |
| 805 | 819 | av_free(sei->payloads[i].payload); |
| @@ -829,10 +843,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 23 unmodified lines | ||
| 829 | 843 | pkt->flags |= AV_PKT_FLAG_KEY; |
| 830 | 844 | } |
| 831 | 845 | |
| 832 | − pkt->pts = x265pic_out.pts; | |
| 833 | − pkt->dts = x265pic_out.dts; | |
| 846 | +#if X265_BUILD >= 210 | |
| 847 | + x265pic_out = x265pic_lyrptr_out[0]; | |
| 848 | +#else | |
| 849 | + x265pic_out = &x265pic_solo_out; | |
| 850 | +#endif | |
| 851 | + | |
| 852 | + pkt->pts = x265pic_out->pts; | |
| 853 | + pkt->dts = x265pic_out->dts; | |
| 834 | 854 | |
| 835 | − switch (x265pic_out.sliceType) { | |
| 855 | + switch (x265pic_out->sliceType) { | |
| 836 | 856 | case X265_TYPE_IDR: |
| 837 | 857 | case X265_TYPE_I: |
| 838 | 858 | pict_type = AV_PICTURE_TYPE_I; |
| @@ -850,16 +870,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 11 unmodified lines | ||
| 850 | 870 | } |
| 851 | 871 | |
| 852 | 872 | #if X265_BUILD >= 130 |
| 853 | − if (x265pic_out.sliceType == X265_TYPE_B) | |
| 873 | + if (x265pic_out->sliceType == X265_TYPE_B) | |
| 854 | 874 | #else |
| 855 | − if (x265pic_out.frameData.sliceType == 'b') | |
| 875 | + if (x265pic_out->frameData.sliceType == 'b') | |
| 856 | 876 | #endif |
| 857 | 877 | pkt->flags |= AV_PKT_FLAG_DISPOSABLE; |
| 858 | 878 | |
| 859 | − ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type); | |
| 879 | + ff_side_data_set_encoder_stats(pkt, x265pic_out->frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type); | |
| 860 | 880 | |
| 861 | − if (x265pic_out.userData) { | |
| 862 | − int idx = (int)(intptr_t)x265pic_out.userData - 1; | |
| 881 | + if (x265pic_out->userData) { | |
| 882 | + int idx = (int)(intptr_t)x265pic_out->userData - 1; | |
| 863 | 883 | ReorderedData *rd = &ctx->rd[idx]; |
| 864 | 884 | |
| 865 | 885 | pkt->duration = rd->duration; |