lavc/mediacodecdec: set codec profile and level from extradata for H264+HEVC

This value is later passed to MediaCodec and checked at decoder init.
Notably decoding of 10-bit streams before this commit would "work" without
returning errors but only return garbage output (on most Android devices).
This commit is contained in:
sfan5 2021-12-13 21:56:05 +01:00 committed by Jan Ekström
parent 12f21849e5
commit b32b32ba89
1 changed files with 6 additions and 0 deletions

View File

@ -155,6 +155,9 @@ static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
uint8_t *data = NULL;
int data_size = 0;
avctx->profile = ff_h264_get_profile(sps);
avctx->level = sps->level_idc;
if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
goto done;
}
@ -236,6 +239,9 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
uint8_t *data;
int data_size;
avctx->profile = sps->ptl.general_ptl.profile_idc;
avctx->level = sps->ptl.general_ptl.level_idc;
if ((ret = h2645_ps_to_nalu(vps->data, vps->data_size, &vps_data, &vps_data_size)) < 0 ||
(ret = h2645_ps_to_nalu(sps->data, sps->data_size, &sps_data, &sps_data_size)) < 0 ||
(ret = h2645_ps_to_nalu(pps->data, pps->data_size, &pps_data, &pps_data_size)) < 0) {