From patchwork Wed Oct 2 23:04:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 15484 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 83A5B44A2A3 for ; Thu, 3 Oct 2019 02:12:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70CA16881B6; Thu, 3 Oct 2019 02:12:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76F52680413 for ; Thu, 3 Oct 2019 02:12:27 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id z9so759745wrl.11 for ; Wed, 02 Oct 2019 16:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QqycKy+B1bDxUV6hnL+OmUzLBjzHNEzYoua1Tn+7ZNc=; b=Kg9bEC6dx2SGuSN9fgr+MnCCCb+bHUlMRNNXf5N/6sW+tntqitDNvFwCcMr082LHNv dUP35WZvmUMFw1CY+pW6Ew1GPtx6xwWOO7WPnptchxQmYZcEwKE1iocy7RoJfOf9M9WV ya0Vea4r+WWu7WTEyO+5EgECyOtYMJOdIkiALP4L0s16Kzoap5iqGqGSKULYQ1nb91n7 ZjUSh83xzL3yUUfAraPDVKKS2OM8g49PMlbnOSFSz/LMNnOFf0puvvwB2hTYLw9StDdj 0lLcmQgkvYyvzKD3sVPtsEtcpA76oIcFhJk5eLvCqtdiH+R6gB5uMGIULwk30ldH8jQm 05Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QqycKy+B1bDxUV6hnL+OmUzLBjzHNEzYoua1Tn+7ZNc=; b=AlU8ZznnbsRqqLqJ0VB29Qe6n9gsOb3HzfmmLrXViHvfxVd+atL39cN/0Od0oSQ+l4 IdCBsTehBuYIW3xZIySMTO04aMzUZ3O0O1PVdhLLiN4yyB39Z+dYH2GAiIHZCWp2rYoa pdBR50WnDeCnW+HmBZZU0UCdoaDKT6KyLvre348WAfjecL7Wfhpi+WZfVvlkdPwU2ced jNACg5H2jT+MicEuLdDHk1EbegUbKE1iMkDOIR+c+ABXNZmEYEx/XYyCqtNtPEoOM+Fk 2NHs3H7knAn7yE9k1fF/rW3RH9rpapyJ22AzJjYTl7ECP4TGJdjFGBWDZUPsUAPNbR8o P4tQ== X-Gm-Message-State: APjAAAVuthJJ8f00xV2jUhmH4FFzS+zCEORZga81tSb7LQn0uXIscKUM 5Kw2kQUN2Dq53pHBzPXD12dfWep4dMg= X-Google-Smtp-Source: APXvYqxduPV0oIhJLKhGxBK7wyBag5yGbFttvlFuGkIO0eiYPBpDd6JvcLtbPjgQvxq78JpBXXzHjw== X-Received: by 2002:adf:f60b:: with SMTP id t11mr4146114wrp.179.1570057509505; Wed, 02 Oct 2019 16:05:09 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id o9sm1489808wrh.46.2019.10.02.16.05.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 16:05:08 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Oct 2019 00:04:49 +0100 Message-Id: <20191002230453.6462-14-sw@jkqxz.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191002230453.6462-1-sw@jkqxz.net> References: <20191002230453.6462-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/18] cbs_h264: Add support for frame packing arrangement SEI messages 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/cbs_h264.h | 24 ++++++++++++++++ libavcodec/cbs_h2645.c | 1 + libavcodec/cbs_h264_syntax_template.c | 40 +++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index abc0c1b732..512674ec07 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -296,6 +296,29 @@ typedef struct H264RawSEIRecoveryPoint { uint8_t changing_slice_group_idc; } H264RawSEIRecoveryPoint; +typedef struct H264RawSEIFramePackingArrangement { + uint32_t frame_packing_arrangement_id; + uint8_t frame_packing_arrangement_cancel_flag; + + uint8_t frame_packing_arrangement_type; + uint8_t quincunx_sampling_flag; + uint8_t content_interpretation_type; + uint8_t spatial_flipping_flag; + uint8_t frame0_flipped_flag; + uint8_t field_views_flag; + uint8_t current_frame_is_frame0_flag; + uint8_t frame0_self_contained_flag; + uint8_t frame1_self_contained_flag; + uint8_t frame0_grid_position_x; + uint8_t frame0_grid_position_y; + uint8_t frame1_grid_position_x; + uint8_t frame1_grid_position_y; + uint8_t frame_packing_arrangement_reserved_byte; + uint16_t frame_packing_arrangement_repetition_period; + + uint8_t frame_packing_arrangement_extension_flag; +} H264RawSEIFramePackingArrangement; + typedef struct H264RawSEIDisplayOrientation { uint8_t display_orientation_cancel_flag; uint8_t hor_flip; @@ -329,6 +352,7 @@ typedef struct H264RawSEIPayload { H264RawSEIUserDataRegistered user_data_registered; H264RawSEIUserDataUnregistered user_data_unregistered; H264RawSEIRecoveryPoint recovery_point; + H264RawSEIFramePackingArrangement frame_packing_arrangement; H264RawSEIDisplayOrientation display_orientation; H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume; H264RawSEIAlternativeTransferCharacteristics diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 16e685174f..51deac3851 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1385,6 +1385,7 @@ void ff_cbs_h264_free_sei_payload(H264RawSEIPayload *payload) case H264_SEI_TYPE_PIC_TIMING: case H264_SEI_TYPE_PAN_SCAN_RECT: case H264_SEI_TYPE_RECOVERY_POINT: + case H264_SEI_TYPE_FRAME_PACKING: case H264_SEI_TYPE_DISPLAY_ORIENTATION: case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 1671a15d33..123752882f 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -779,6 +779,42 @@ static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +static int FUNC(sei_frame_packing_arrangement)(CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIFramePackingArrangement *current) +{ + int err; + + HEADER("Frame Packing Arrangement"); + + ue(frame_packing_arrangement_id, 0, UINT32_MAX - 1); + flag(frame_packing_arrangement_cancel_flag); + + if (!current->frame_packing_arrangement_cancel_flag) { + u(7, frame_packing_arrangement_type, 0, 7); + flag(quincunx_sampling_flag); + u(6, content_interpretation_type, 0, 2); + flag(spatial_flipping_flag); + flag(frame0_flipped_flag); + flag(field_views_flag); + flag(current_frame_is_frame0_flag); + flag(frame0_self_contained_flag); + flag(frame1_self_contained_flag); + if (!current->quincunx_sampling_flag && + current->frame_packing_arrangement_type != 5) { + ub(4, frame0_grid_position_x); + ub(4, frame0_grid_position_y); + ub(4, frame1_grid_position_x); + ub(4, frame1_grid_position_y); + } + u(8, frame_packing_arrangement_reserved_byte, 0, 0); + ue(frame_packing_arrangement_repetition_period, 0, 16384); + } + + flag(frame_packing_arrangement_extension_flag); + + return 0; +} + static int FUNC(sei_display_orientation)(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIDisplayOrientation *current) { @@ -879,6 +915,10 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, CHECK(FUNC(sei_display_orientation) (ctx, rw, ¤t->payload.display_orientation)); break; + case H264_SEI_TYPE_FRAME_PACKING: + CHECK(FUNC(sei_frame_packing_arrangement) + (ctx, rw, ¤t->payload.frame_packing_arrangement)); + break; case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME: CHECK(FUNC(sei_mastering_display_colour_volume) (ctx, rw, ¤t->payload.mastering_display_colour_volume));