[FFmpeg-devel] [PATCH 13/18] h264_sei: parse the picture timing SEIs correctly
James Almer
jamrial at gmail.com
Fri Mar 13 17:56:12 EET 2020
On 3/13/2020 7:28 AM, Anton Khirnov wrote:
> Those SEIs refer to the currently active SPS. However, since the SEI
> NALUs precede the coded picture data in the bitstream, the active SPS is
> in general not known when we are decoding the SEI.
>
> Therefore, store the content of the picture timing SEIs and actually
> parse it when the active SPS is known.
> ---
> libavcodec/h264_parser.c | 9 +++++
> libavcodec/h264_sei.c | 86 ++++++++++++++++++++++++----------------
> libavcodec/h264_sei.h | 11 +++++
> libavcodec/h264_slice.c | 10 +++++
> 4 files changed, 82 insertions(+), 34 deletions(-)
>
[...]
> +static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
> + void *logctx)
> +{
> + PutBitContext pb;
> + int n;
> +
> + if (get_bits_left(gb) > sizeof(h->payload) * 8) {
> + av_log(logctx, AV_LOG_ERROR, "Picture timing SEI payload too large\n");
> + return AVERROR_INVALIDDATA;
> + }
> +
> + init_put_bits(&pb, h->payload, sizeof(h->payload));
> +
> + while (get_bits_left(gb) >= 32)
> + put_bits(&pb, 32, get_bits_long(gb, 32));
> +
> + n = get_bits_left(gb);
> + if (n)
> + put_bits(&pb, n, get_bits_long(gb, n));
I think you can do something like avpriv_copy_bits(&pb, gb->buffer,
get_bits_left(gb)) instead.
No need to skip the bits in gb afterwards since the GetBitContext struct
is exclusive for this SEI starting with the previous patch.
> +
> + h->payload_size_bits = put_bits_count(&pb);
> + flush_put_bits(&pb);
> +
> h->present = 1;
> return 0;
> }
More information about the ffmpeg-devel
mailing list