bitwriter: Fix a nal conversion bug when input is not byte aligned.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3193>
This commit is contained in:
He Junyan 2022-10-27 14:40:49 +08:00 committed by GStreamer Marge Bot
parent 13be7cbe86
commit 9dc76185fc
2 changed files with 8 additions and 4 deletions

View file

@ -1600,8 +1600,10 @@ gst_h264_bit_writer_convert_to_nal (guint nal_prefix_size, gboolean packetized,
goto error;
if (raw_size % 8) {
if (!nal_writer_put_bits_uint8 (&nw, *(raw_data + raw_size / 8),
raw_size % 8))
guint8 data = *(raw_data + raw_size / 8);
if (!nal_writer_put_bits_uint8 (&nw,
data >> (8 - raw_size % 8), raw_size % 8))
goto error;
}

View file

@ -2267,8 +2267,10 @@ gst_h265_bit_writer_convert_to_nal (guint nal_prefix_size,
goto error;
if (raw_size % 8) {
if (!nal_writer_put_bits_uint8 (&nw, *(raw_data + raw_size / 8),
raw_size % 8))
guint8 data = *(raw_data + raw_size / 8);
if (!nal_writer_put_bits_uint8 (&nw,
data >> (8 - raw_size % 8), raw_size % 8))
goto error;
}