diff mbox series

[FFmpeg-devel] lavc/mediacodecdec: set codec profile and level from extradata for H264+HEVC

Message ID DB9PR09MB521251A14DCD46826854BCC6EC749@DB9PR09MB5212.eurprd09.prod.outlook.com
State Accepted
Commit b32b32ba89b564e33c6ee0d7a17b80b5e56b6b73
Headers show
Series [FFmpeg-devel] lavc/mediacodecdec: set codec profile and level from extradata for H264+HEVC | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

sfan5 Dec. 13, 2021, 8:56 p.m. UTC
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).
Subject: [PATCH] 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).
---
 libavcodec/mediacodecdec.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Matthieu Bouron Dec. 14, 2021, 10:10 a.m. UTC | #1
On Mon, Dec 13, 2021 at 09:56:05PM +0100, sfan5 wrote:
> 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).

> From 304d1bbbbbd55e72212c1e907922547d40da240b Mon Sep 17 00:00:00 2001
> From: sfan5 <sfan5@live.de>
> Date: Mon, 13 Dec 2021 21:01:00 +0100
> Subject: [PATCH] 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).
> ---
>  libavcodec/mediacodecdec.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> index 1cebb3d76d..04d5026e68 100644
> --- a/libavcodec/mediacodecdec.c
> +++ b/libavcodec/mediacodecdec.c
> @@ -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) {
> -- 
> 2.34.1
> 

Tested locally without issues. LGTM, thanks.

Matthieu
Jan Ekström Dec. 30, 2021, 5:31 p.m. UTC | #2
On Mon, Dec 13, 2021 at 10:56 PM sfan5 <sfan5@live.de> wrote:
>
> 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).

Applied as b32b32ba89b564e33c6ee0d7a17b80b5e56b6b73 to master after
checking that libavcodec/{hevc_parser,hevcdec} utilize the same logic
for avctx->profile.

Jan
diff mbox series

Patch

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 1cebb3d76d..04d5026e68 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -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) {