From patchwork Tue Dec 17 10:22:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 16855 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CED1F44A003 for ; Tue, 17 Dec 2019 12:22:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BB21E68A0AE; Tue, 17 Dec 2019 12:22:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C9295689D3B for ; Tue, 17 Dec 2019 12:22:34 +0200 (EET) Received: by mail-pg1-f194.google.com with SMTP id q127so5424250pga.4 for ; Tue, 17 Dec 2019 02:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gsmv81ZwXAQBbDPitSqrGDyWeL6mQlRUHLtkfyuHh+I=; b=oisDwTGYXmVWp/sWy5QqtBqfQkOXC11B7h4pdlDOAXJvszc2E6jg3STOoE3nSzBOOx 416OxskgU1Sy2lXOWsGaaGNy9e3R/APtCJvUI6wlYMaBL6dFsuxJ+DWzrZeNwxRs7asF WLbisC6JxLhpkbtUwEVwWs30H5D0EG4Q5zRomQBwto16a7VaeIfiBhIDl2GWRdUhV+ii 6JVWIJ9RiEacotC1LAQkise6boJcjCqqlifmUFNZbjmhcLAUqMn4I2HDyM+FqKyMS9VL UuuEC/tJFcp6AdD1/9Hg5xfk9cKqdRv/ziuEGI5swUf/vu67t6HtN/kvgLX389KtKExR xUuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gsmv81ZwXAQBbDPitSqrGDyWeL6mQlRUHLtkfyuHh+I=; b=AX4vl3+eWQlWjHs5yXgK17LAofyOqvmXOjLeq5uO/6lMGJlYsZll+6QGtLqMQMEWvy 3105Fz024TByKq4uNzDL7PUUZraN8IbeSKCzf4iSqYJE1tjoioCCfdlw57wVEQiU1w++ ZelYA2VmF2fFx7e/eX6MlFNpiecIbx1MOw8siDPtkCOvnKe8zwWTEck4xmwSIHxD/mIs 1iSAs3+ozKhpg7EQ3H1kZoVqOTrEjOWbrAvrrC6kRoFV4h8Jgy029BWzMcQtFYBzzkFZ LCfcac0OXR6TvkHarl3p2PkpWGJjdWo982ylROdwpdQU4z7hMS6jSzqDKSOT/6oJwxJL XygA== X-Gm-Message-State: APjAAAV3NnRzsrH2R6CFdt3HJwbHPbXgOI/r61uKXqv9la2tyv+oB1XO HKeKOdaN0BZBT4yQxdogRvIMryTQ X-Google-Smtp-Source: APXvYqyWvBTcoxVq9DtnUENeVoPwBI+OTI7J75M+e8BXbSfI/U72lQ0cAnrrYGbugBaMUIrykY8LOw== X-Received: by 2002:a62:2bca:: with SMTP id r193mr21233543pfr.251.1576578153080; Tue, 17 Dec 2019 02:22:33 -0800 (PST) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id j7sm29027254pgn.0.2019.12.17.02.22.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 02:22:32 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 17 Dec 2019 18:22:17 +0800 Message-Id: <20191217102217.4811-5-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191217102217.4811-1-lance.lmwang@gmail.com> References: <20191217102217.4811-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 5/5] avcodec/h264: create user data unregistered side data for H.264 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Below is the sample message for -vf showinfo(need to apply the patchset): [Parsed_showinfo_0 @ 0x7fac7b702080] side data - User data unregistered: [Parsed_showinfo_0 @ 0x7fac7b702080] UUID=186f369370304f2c603021492feee5b8 [Parsed_showinfo_0 @ 0x7fac7b702080] User Data=hello Signed-off-by: Limin Wang --- libavcodec/h264_sei.c | 5 ++++- libavcodec/h264_sei.h | 3 +++ libavcodec/h264_slice.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 46fe8692dd..c70a5122ec 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -50,6 +50,7 @@ void ff_h264_sei_uninit(H264SEIContext *h) h->frame_packing.present = 0; h->display_orientation.present = 0; h->afd.present = 0; + h->unregistered.present = 0; av_buffer_unref(&h->a53_caption.buf_ref); } @@ -258,6 +259,8 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * user_data[i] = get_bits(gb, 8); memset(user_data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); + h->user_data = user_data; + h->user_data_size = size; e = sscanf(user_data + 16, "x264 - core %d", &build); if (e == 1 && build > 0) @@ -265,7 +268,7 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16)) h->x264_build = 67; - av_free(user_data); + h->present = 1; return 0; } diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index a75c3aa175..4bded8e579 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -121,6 +121,9 @@ typedef struct H264SEIA53Caption { typedef struct H264SEIUnregistered { int x264_build; + int present; + int user_data_size; + uint8_t *user_data; } H264SEIUnregistered; typedef struct H264SEIRecoveryPoint { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index e24d41ca50..4fb99c9263 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1285,6 +1285,17 @@ static int h264_export_frame_props(H264Context *h) h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } + if (h->sei.unregistered.present) { + AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_USER_DATA_UNREGISTERED, + h->sei.unregistered.user_data_size); + if (sd) + memcpy(sd->data, h->sei.unregistered.user_data, + h->sei.unregistered.user_data_size); + av_freep(&h->sei.unregistered.user_data); + h->sei.unregistered.user_data_size = 0; + h->sei.unregistered.present = 0; + } + if (h->sei.picture_timing.timecode_cnt > 0) { uint32_t tc = 0; uint32_t *tc_sd;