diff mbox

[FFmpeg-devel] hevc_sei: add support for User Data Unregistered SEI messages

Message ID 20170505210923.9488-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer May 5, 2017, 9:09 p.m. UTC
Based on h264_sei code.

Only print the user data for now.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/hevc_sei.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Kieran Kunhya May 5, 2017, 9:23 p.m. UTC | #1
>
>
> +    if (strlen(user_data + 16) > 0)
> +        av_log(logctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data +
> 16);
>

Eugh, no, no, no.
Some encoders put random junk in here and my terminal goes crazy.
The h264 stuff is bad as well but libav people were so insistent this stuff
was printed.

Kieran
James Almer May 5, 2017, 9:59 p.m. UTC | #2
On 5/5/2017 6:23 PM, Kieran Kunhya wrote:
>>
>>
>> +    if (strlen(user_data + 16) > 0)
>> +        av_log(logctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data +
>> 16);
>>
> 
> Eugh, no, no, no.
> Some encoders put random junk in here and my terminal goes crazy.
> The h264 stuff is bad as well but libav people were so insistent this stuff
> was printed.

Alright, patch dropped.

I may look into printing only data from know UUIDs after checking it's a
printable string, but not now.

> Kieran
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
wm4 May 6, 2017, 1:15 a.m. UTC | #3
On Fri, 5 May 2017 18:59:00 -0300
James Almer <jamrial@gmail.com> wrote:

> On 5/5/2017 6:23 PM, Kieran Kunhya wrote:
> >>
> >>
> >> +    if (strlen(user_data + 16) > 0)
> >> +        av_log(logctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data +
> >> 16);
> >>  
> > 
> > Eugh, no, no, no.
> > Some encoders put random junk in here and my terminal goes crazy.
> > The h264 stuff is bad as well but libav people were so insistent this stuff
> > was printed.  
> 
> Alright, patch dropped.
> 
> I may look into printing only data from know UUIDs after checking it's a
> printable string, but not now.

Why can't it just be exported as side data, and leave the mess to tools
like ffprobe?
diff mbox

Patch

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index c5054bfaab..1d40ed9371 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -232,6 +232,30 @@  static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEIContext *s, GetB
     return 0;
 }
 
+static int decode_nal_unregistered_user_data(HEVCSEIContext *h, GetBitContext *gb,
+                                             void *logctx, int size)
+{
+    uint8_t *user_data;
+    int i;
+
+    if (size < 16 || size >= INT_MAX - 16)
+        return AVERROR_INVALIDDATA;
+
+    user_data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!user_data)
+        return AVERROR(ENOMEM);
+
+    for (i = 0; i < size; i++)
+        user_data[i] = get_bits(gb, 8);
+
+    if (strlen(user_data + 16) > 0)
+        av_log(logctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data + 16);
+
+    av_free(user_data);
+
+    return 0;
+}
+
 static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb, void *logctx)
 {
     int num_sps_ids_minus1;
@@ -288,6 +312,8 @@  static int decode_nal_sei_prefix(GetBitContext *gb, HEVCSEIContext *s, const HEV
         return 0;
     case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
         return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size);
+    case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
+        return decode_nal_unregistered_user_data(s, gb, logctx, size);
     default:
         av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
         skip_bits_long(gb, 8 * size);