diff mbox

[FFmpeg-devel,v4,07/14] avcodec/h264: implement new decode_params callback for PPS/SPS

Message ID 20171110214059.84891-7-ffmpeg@tmm1.net
State Accepted
Commit 872add08540fb36b2d2ca75df86da7d8ac9579a1
Headers show

Commit Message

Aman Gupta Nov. 10, 2017, 9:40 p.m. UTC
From: Aman Gupta <aman@tmm1.net>

This callback will be used by the VideoToolbox H264 hwaccel so that it
can receive SPS and PPS NALUs. VideoToolbox requires PPS changes to be
fed into the decoder session, and for the session to be recreated when
the SPS changes.
---
 libavcodec/h264dec.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Michael Niedermayer Nov. 11, 2017, 11:49 a.m. UTC | #1
On Fri, Nov 10, 2017 at 01:40:52PM -0800, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> This callback will be used by the VideoToolbox H264 hwaccel so that it
> can receive SPS and PPS NALUs. VideoToolbox requires PPS changes to be
> fed into the decoder session, and for the session to be recreated when
> the SPS changes.
> ---
>  libavcodec/h264dec.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

LGTM

[...]
diff mbox

Patch

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 517f6acc13..be187eb5f4 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -713,6 +713,14 @@  static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
             break;
         case H264_NAL_SPS: {
             GetBitContext tmp_gb = nal->gb;
+            if (avctx->hwaccel && avctx->hwaccel->decode_params) {
+                ret = avctx->hwaccel->decode_params(avctx,
+                                                    nal->type,
+                                                    nal->raw_data,
+                                                    nal->raw_size);
+                if (ret < 0)
+                    goto end;
+            }
             if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
                 break;
             av_log(h->avctx, AV_LOG_DEBUG,
@@ -724,6 +732,14 @@  static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
             break;
         }
         case H264_NAL_PPS:
+            if (avctx->hwaccel && avctx->hwaccel->decode_params) {
+                ret = avctx->hwaccel->decode_params(avctx,
+                                                    nal->type,
+                                                    nal->raw_data,
+                                                    nal->raw_size);
+                if (ret < 0)
+                    goto end;
+            }
             ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
                                                        nal->size_bits);
             if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))