From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0077442846 for ; Mon, 2 Jan 2023 19:32:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0164468BC8B; Mon, 2 Jan 2023 21:32:49 +0200 (EET) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2322168BC6A for ; Mon, 2 Jan 2023 21:32:43 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id v3so18820472pgh.4 for ; Mon, 02 Jan 2023 11:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=TzlZsctaEhO4ame7+5Wq+Gs4XmH6WSIWnIiWopAB4fA=; b=A0ztzkTe0uobVASP/y6kUWYmD90fzGAdzLFPRUS+o7VZbu/qyOJnv6KsXTZJ0k/NC+ 3boIVsHHoJ6KB+Y4nutjmW165nkeK+VbBf2M8BChuhJShjoux71OoGuZ8b4r0PuNMaTv hKD+R+jlf65Bx706P0ubQXoJNQgsghmNSUkrd+q9gKF+mVvhbKSti0JC890lc+OhCGCG AeCGgUKuim1mNm1rwgTuvC6TB51tDon1pCHDMNHKNWeGAThZQi5GGDZKdDiursI1xceO VZFbLzmSldwkBRnrvTTM1uDeKIaS6fXr6qFehKHyMiGCqOOhA/8raKPUUXd7rLBgGqHe 19PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TzlZsctaEhO4ame7+5Wq+Gs4XmH6WSIWnIiWopAB4fA=; b=rtwrJSZTYaniTOfWL/RWq07CRZzP9BcWfxtyG7U9yx3eCTG+9/wVhineaH1eRZFHCP rLFho42vJcPhfQH31+sbbO0FD9AGbmKWbfTRL2o+OyfmFkpizuXiaiyngVk25CdkbQ4O W+FL0GV9uXwLtl2tKpu/I0wKev5VT0sW41nirz559jA0nPxZ9KIYlgygBWWx0ErJKqF/ rfuRVUU8Exx930eKiiugEwHkf2lRuOLykw8Yn7h/oxNr8QPxkBV65zvKTGAtKvKEAVfX nw/Io+TOIkIG+qaF/Mg4R/ohwpebzePuO8nlm5uVpfM6QHJR4desDLkP0S9b+TVUccCF 8KdQ== X-Gm-Message-State: AFqh2korpMWiMfOXSXCnrmosTXnEQjrq+XBL9gxaip7o2I1gN/TwbfcU iZkp6m5pCEu4E8qZPRqDGWnP6wKzYqY= X-Google-Smtp-Source: AMrXdXsXa9ni+CbGiK7gIsmI6PqT3WKBsr6dEcm8F7GOtF4ZOanAqgw8a47uxhbfy8mbrIBKeUO1qg== X-Received: by 2002:a62:31c3:0:b0:574:c62c:2f55 with SMTP id x186-20020a6231c3000000b00574c62c2f55mr51884451pfx.3.1672687961369; Mon, 02 Jan 2023 11:32:41 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id y188-20020a6264c5000000b00580e3917af7sm15803304pfb.117.2023.01.02.11.32.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2023 11:32:40 -0800 (PST) From: Aman Karmani X-Google-Original-From: Aman Karmani Message-Id: Date: Mon, 02 Jan 2023 19:32:40 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Aman Karmani Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Aman Karmani Signed-off-by: Aman Karmani --- avcodec/vaapi_encode_h26x: passthrough A53 CC data as H264/HEVC SEI Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-46%2Ftmm1%2Fvaapi-a53cc-v1 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-46/tmm1/vaapi-a53cc-v1 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/46 libavcodec/vaapi_encode_h264.c | 27 ++++++++++++++++++++++++++- libavcodec/vaapi_encode_h265.c | 27 ++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index b1b503b2a6..d22b38ab38 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -26,6 +26,7 @@ #include "libavutil/internal.h" #include "libavutil/opt.h" +#include "atsc_a53.h" #include "avcodec.h" #include "cbs.h" #include "cbs_h264.h" @@ -40,6 +41,7 @@ enum { SEI_TIMING = 0x01, SEI_IDENTIFIER = 0x02, SEI_RECOVERY_POINT = 0x04, + SEI_A53_CC = 0x08, }; // Random (version 4) ISO 11578 UUID. @@ -98,6 +100,8 @@ typedef struct VAAPIEncodeH264Context { H264RawSEIRecoveryPoint sei_recovery_point; SEIRawUserDataUnregistered sei_identifier; char *sei_identifier_string; + SEIRawUserDataRegistered sei_a53cc; + void *sei_a53cc_data; int aud_needed; int sei_needed; @@ -248,6 +252,13 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx, if (err < 0) goto fail; } + if (priv->sei_needed & SEI_A53_CC) { + err = ff_cbs_sei_add_message(priv->cbc, au, 1, + SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35, + &priv->sei_a53cc, NULL); + if (err < 0) + goto fail; + } priv->sei_needed = 0; @@ -607,7 +618,8 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *prev = pic->prev; VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : NULL; VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params; - int i; + int i, err; + size_t sei_a53cc_len; if (pic->type == PICTURE_TYPE_IDR) { av_assert0(pic->display_order == pic->encode_order); @@ -681,6 +693,18 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, priv->sei_needed |= SEI_RECOVERY_POINT; } + av_freep(&priv->sei_a53cc_data); + err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, &sei_a53cc_len); + if (err < 0) + return err; + if (priv->sei_a53cc_data != NULL) { + priv->sei_a53cc.itu_t_t35_country_code = 181; + priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1; + priv->sei_a53cc.data_length = sei_a53cc_len - 1; + + priv->sei_needed |= SEI_A53_CC; + } + vpic->CurrPic = (VAPictureH264) { .picture_id = pic->recon_surface, .frame_idx = hpic->frame_num, @@ -1226,6 +1250,7 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext *avctx) ff_cbs_fragment_free(&priv->current_access_unit); ff_cbs_close(&priv->cbc); av_freep(&priv->sei_identifier_string); + av_freep(&priv->sei_a53cc_data); return ff_vaapi_encode_close(avctx); } diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 94b56c6578..3611bd6147 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -27,6 +27,7 @@ #include "libavutil/opt.h" #include "libavutil/mastering_display_metadata.h" +#include "atsc_a53.h" #include "avcodec.h" #include "cbs.h" #include "cbs_h265.h" @@ -40,6 +41,7 @@ enum { SEI_MASTERING_DISPLAY = 0x08, SEI_CONTENT_LIGHT_LEVEL = 0x10, + SEI_A53_CC = 0x20, }; typedef struct VAAPIEncodeH265Picture { @@ -84,6 +86,8 @@ typedef struct VAAPIEncodeH265Context { SEIRawMasteringDisplayColourVolume sei_mastering_display; SEIRawContentLightLevelInfo sei_content_light_level; + SEIRawUserDataRegistered sei_a53cc; + void *sei_a53cc_data; CodedBitstreamContext *cbc; CodedBitstreamFragment current_access_unit; @@ -226,6 +230,13 @@ static int vaapi_encode_h265_write_extra_header(AVCodecContext *avctx, if (err < 0) goto fail; } + if (priv->sei_needed & SEI_A53_CC) { + err = ff_cbs_sei_add_message(priv->cbc, au, 1, + SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35, + &priv->sei_a53cc, NULL); + if (err < 0) + goto fail; + } priv->sei_needed = 0; @@ -759,7 +770,8 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *prev = pic->prev; VAAPIEncodeH265Picture *hprev = prev ? prev->priv_data : NULL; VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params; - int i; + int i, err; + size_t sei_a53cc_len; if (pic->type == PICTURE_TYPE_IDR) { av_assert0(pic->display_order == pic->encode_order); @@ -888,6 +900,18 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, } } + av_freep(&priv->sei_a53cc_data); + err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, &sei_a53cc_len); + if (err < 0) + return err; + if (priv->sei_a53cc_data != NULL) { + priv->sei_a53cc.itu_t_t35_country_code = 181; + priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1; + priv->sei_a53cc.data_length = sei_a53cc_len - 1; + + priv->sei_needed |= SEI_A53_CC; + } + vpic->decoded_curr_pic = (VAPictureHEVC) { .picture_id = pic->recon_surface, .pic_order_cnt = hpic->pic_order_cnt, @@ -1355,6 +1379,7 @@ static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx) ff_cbs_fragment_free(&priv->current_access_unit); ff_cbs_close(&priv->cbc); + av_freep(&priv->sei_a53cc_data); return ff_vaapi_encode_close(avctx); } base-commit: 3bcec58535d395945a390bdc7af4048a7abc60eb -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".