[FFmpeg-devel] [PATCH 7/9] avcodec/h264: add decode_params callback to AVHWAccel
Hendrik Leppkes
h.leppkes at gmail.com
Tue Sep 26 11:16:01 EEST 2017
On Tue, Sep 26, 2017 at 2:36 AM, Aman Gupta <ffmpeg at tmm1.net> wrote:
> From: Aman Gupta <aman at 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/avcodec.h | 12 ++++++++++++
> libavcodec/h264dec.c | 14 ++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 5c84974e03..14bb509f66 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3921,6 +3921,18 @@ typedef struct AVHWAccel {
> int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
>
> /**
> + * Callback for parameter data.
> + *
> + * Used for SPS/PPS in H264 streams.
> + *
> + * @param avctx the codec context
> + * @param buf the slice data buffer base
> + * @param buf_size the size of the slice in bytes
> + * @return zero if successful, a negative value otherwise
> + */
> + int (*decode_params)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
> +
> + /**
> * Callback for each slice.
> *
> * Meaningful slice information (codec specific) is guaranteed to
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index a8263f2e19..ab95beb020 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -738,6 +738,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
> break;
> case H264_NAL_SPS: {
> GetBitContext tmp_gb = nal->gb;
> + if (avctx->hwaccel && avctx->hwaccel->decode_params) {
> + ret = avctx->hwaccel->decode_params(avctx,
> + nal->data,
> + nal->size);
You probably want nal->raw_data and raw_size here (and below),
hardware typically works on raw (escaped) data.
More information about the ffmpeg-devel
mailing list