On Thu, Jan 28, 2016 at 9:49 PM, Luca Barbato <[email protected]> wrote: > On 29/07/15 22:51, Luca Barbato wrote: >> And restrict the string to ascii text. >> >> CC: [email protected] >> >> Signed-off-by: Luca Barbato <[email protected]> >> --- >> libavcodec/h264_sei.c | 57 >> ++++++++++++++++++++++++++++++++++++++++++--------- >> 1 file changed, 47 insertions(+), 10 deletions(-) >> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c >> index 1f3844b..7361941 100644 >> --- a/libavcodec/h264_sei.c >> +++ b/libavcodec/h264_sei.c >> @@ -191,24 +191,61 @@ static int decode_registered_user_data(H264Context *h, >> int size) >> return 0; >> } >> >> +static const uint8_t x264_version_uuid[] = { >> + 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, >> + 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef >> +}; >> + >> +static int decode_x264_version(H264Context *h, int size) >> +{ >> + int build = 0, i = 0; >> + uint8_t x264_string[256]; >> + >> + if (size < 13) >> + goto skip; >> + >> + for (i = 0; i < size && i < sizeof(x264_string) - 1; i++) >> + x264_string[i] = get_bits(&h->gb, 8) & 0x7f; >> + >> + x264_string[i] = 0; >> + >> + if (!memcmp(x264_string, "x264 - core ", 12)) >> + build = atoi(x264_string + 12); >> + >> + if (build > 0) >> + h->x264_build = build; >> + >> + if (h->avctx->debug & FF_DEBUG_BUGS) >> + av_log(h->avctx, AV_LOG_DEBUG, "x264 version string:\"%s\"\n", >> x264_string); >> +skip: >> + for (; i < size; i++) >> + skip_bits(&h->gb, 8); >> + >> + return 0; >> +} >> + >> static int decode_unregistered_user_data(H264Context *h, int size) >> { >> - uint8_t user_data[16 + 256]; >> - int e, build, i; >> + int i; >> + uint8_t uuid[16]; >> >> if (size < 16) >> return AVERROR_INVALIDDATA; >> >> - for (i = 0; i < sizeof(user_data) - 1 && i < size; i++) >> - user_data[i] = get_bits(&h->gb, 8); >> + for (i = 0; i < 16; i++) >> + uuid[i] = get_bits(&h->gb, 8); >> >> - user_data[i] = 0; >> - e = sscanf(user_data + 16, "x264 - core %d", &build); >> - if (e == 1 && build > 0) >> - h->x264_build = build; >> + av_log(h->avctx, AV_LOG_DEBUG, "uuid 0x%02x 0x%02x 0x%02x 0x%02x " >> + "0x%02x 0x%02x 0x%02x 0x%02x " >> + "0x%02x 0x%02x 0x%02x 0x%02x " >> + "0x%02x 0x%02x 0x%02x 0x%02x\n", >> + uuid[0], uuid[1], uuid[2], uuid[3], >> + uuid[4], uuid[5], uuid[6], uuid[7], >> + uuid[8], uuid[9], uuid[10], uuid[11], >> + uuid[12], uuid[13], uuid[14], uuid[15]); >> >> - if (h->avctx->debug & FF_DEBUG_BUGS) >> - av_log(h->avctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data + >> 16); >> + if (!memcmp(uuid, x264_version_uuid, 16)) >> + return decode_x264_version(h, size - 16); >> >> for (; i < size; i++) >> skip_bits(&h->gb, 8); >> > > I did not have time to update this but probably this would had worked > better all in all =P
Kieran, would this fix your usecase? -- Vittorio _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
