From patchwork Tue May 2 21:55:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 3552 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp2089420vsd; Tue, 2 May 2017 14:57:02 -0700 (PDT) X-Received: by 10.223.152.175 with SMTP id w44mr19923231wrb.122.1493762222674; Tue, 02 May 2017 14:57:02 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w52si21004383wrc.60.2017.05.02.14.57.02; Tue, 02 May 2017 14:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 88E5268981B; Wed, 3 May 2017 00:56:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9CE8B6891FD for ; Wed, 3 May 2017 00:56:29 +0300 (EEST) Received: by mail-qk0-f194.google.com with SMTP id o4so124335qkb.3 for ; Tue, 02 May 2017 14:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=0SWhbuS/4GdYj90+GYHkEfJT8ROacU8Yg7p1nmnED2Q=; b=I7ORyRUo87tVpxFr38Ta27c2Lu6rlWmPmN+b0sqqVopJCA3sX81S3V+28e1qKRLqrh cHFsoloO9XBKsbDU1x0Ip5+oCj7QuRkFMNLYYfR49+j0UCGp7TruaWCXx++tnLb01hVw qPUYv9LG4n5Mm19rX90LH1K+49K5EGJuoiOOY2c2JvuvYRbj87Ocf6agw+JpPw+ewUqr Ub0J0exMkeirmXXaRCo7Nq+aKuh87FNsX/uylDKZuzr1N0rMUA6Gua05vS1UXZfPUcuS W++ArBfJydOsyk/cka5tWg6tndVEh8W932VjFIooKOvs58M00qDt+QzUnjsA53BPN5M8 2cBQ== 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; bh=0SWhbuS/4GdYj90+GYHkEfJT8ROacU8Yg7p1nmnED2Q=; b=eHJGVns3j9mgHYFbJ3Z5S5LMy/X0zXltScywoBQXhpjbF4QXf/jMT51hgS2HIhWHCM Yx2DNlOBv6d6+pe1jIEozAkRqsFKEYrCGmvUlYjXFS5XtoPCqjWTU6op9R2zndRHnREv FS+oQ2Zg26kXsdEvyBfZLWNCJypCgbGB5hnSX1LfCZHePTynWzjVaFdS738n5PyAZRfA 9E+/xBrAKJvFVLqba94HHutsnvdbMFnCy1QxjpAeyPsvMMQtrGLmHelk05Og/yHipXvM mdtD7UpIVEbvxPTiO8SdX4l726M2R1ZTbQ3CTH+bDUtO78gUzUd+XP8m43EIaz6JlRoV Z6pw== X-Gm-Message-State: AODbwcCZspAT0LTJ/wewAIjtDa5AfK6Rm8LtW9RdPqN/YHiic0FnbOev cnOy5es8pRjc1dbp X-Received: by 10.55.106.199 with SMTP id f190mr79410qkc.151.1493762192528; Tue, 02 May 2017 14:56:32 -0700 (PDT) Received: from localhost.localdomain ([181.231.62.139]) by smtp.gmail.com with ESMTPSA id t45sm14992046qtt.9.2017.05.02.14.56.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 May 2017 14:56:32 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 May 2017 18:55:23 -0300 Message-Id: <20170502215530.8672-3-jamrial@gmail.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170502215530.8672-1-jamrial@gmail.com> References: <20170502215530.8672-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 2/9] hevcdec: move SEI message parsing into a separate header 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It doesn't depend on hevcdec anymore. Signed-off-by: James Almer --- libavcodec/hevc_sei.c | 47 ++++--------------- libavcodec/hevc_sei.h | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++ libavcodec/hevcdec.h | 67 +-------------------------- 3 files changed, 136 insertions(+), 103 deletions(-) create mode 100644 libavcodec/hevc_sei.h diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 679a18b3d8..c5054bfaab 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -23,35 +23,8 @@ */ #include "golomb.h" -#include "hevcdec.h" - -enum HEVC_SEI_TYPE { - SEI_TYPE_BUFFERING_PERIOD = 0, - SEI_TYPE_PICTURE_TIMING = 1, - SEI_TYPE_PAN_SCAN_RECT = 2, - SEI_TYPE_FILLER_PAYLOAD = 3, - SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35 = 4, - SEI_TYPE_USER_DATA_UNREGISTERED = 5, - SEI_TYPE_RECOVERY_POINT = 6, - SEI_TYPE_SCENE_INFO = 9, - SEI_TYPE_FULL_FRAME_SNAPSHOT = 15, - SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16, - SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, - SEI_TYPE_FILM_GRAIN_CHARACTERISTICS = 19, - SEI_TYPE_POST_FILTER_HINT = 22, - SEI_TYPE_TONE_MAPPING_INFO = 23, - SEI_TYPE_FRAME_PACKING = 45, - SEI_TYPE_DISPLAY_ORIENTATION = 47, - SEI_TYPE_SOP_DESCRIPTION = 128, - SEI_TYPE_ACTIVE_PARAMETER_SETS = 129, - SEI_TYPE_DECODING_UNIT_INFO = 130, - SEI_TYPE_TEMPORAL_LEVEL0_INDEX = 131, - SEI_TYPE_DECODED_PICTURE_HASH = 132, - SEI_TYPE_SCALABLE_NESTING = 133, - SEI_TYPE_REGION_REFRESH_INFO = 134, - SEI_TYPE_MASTERING_DISPLAY_INFO = 137, - SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144, -}; +#include "hevc_ps.h" +#include "hevc_sei.h" static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, GetBitContext *gb) { @@ -294,26 +267,26 @@ static int decode_nal_sei_prefix(GetBitContext *gb, HEVCSEIContext *s, const HEV switch (type) { case 256: // Mismatched value from HM 8.1 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb); - case SEI_TYPE_FRAME_PACKING: + case HEVC_SEI_TYPE_FRAME_PACKING: return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb); - case SEI_TYPE_DISPLAY_ORIENTATION: + case HEVC_SEI_TYPE_DISPLAY_ORIENTATION: return decode_nal_sei_display_orientation(&s->display_orientation, gb); - case SEI_TYPE_PICTURE_TIMING: + case HEVC_SEI_TYPE_PICTURE_TIMING: { int ret = decode_pic_timing(s, gb, ps, logctx); av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); skip_bits(gb, 8 * size); return ret; } - case SEI_TYPE_MASTERING_DISPLAY_INFO: + case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: return decode_nal_sei_mastering_display_info(&s->mastering_display, gb); - case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: + case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: return decode_nal_sei_content_light_info(&s->content_light, gb); - case SEI_TYPE_ACTIVE_PARAMETER_SETS: + case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS: active_parameter_sets(s, gb, logctx); av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); return 0; - case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: + case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size); default: av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); @@ -326,7 +299,7 @@ static int decode_nal_sei_suffix(GetBitContext *gb, HEVCSEIContext *s, int type, int size, void *logctx) { switch (type) { - case SEI_TYPE_DECODED_PICTURE_HASH: + case HEVC_SEI_TYPE_DECODED_PICTURE_HASH: return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb); default: av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type); diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h new file mode 100644 index 0000000000..2687f449bf --- /dev/null +++ b/libavcodec/hevc_sei.h @@ -0,0 +1,125 @@ +/* + * HEVC Supplementary Enhancement Information messages + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_HEVC_SEI_H +#define AVCODEC_HEVC_SEI_H + +#include "libavutil/md5.h" +#include "get_bits.h" + +/** + * SEI message types + */ +typedef enum { + HEVC_SEI_TYPE_BUFFERING_PERIOD = 0, + HEVC_SEI_TYPE_PICTURE_TIMING = 1, + HEVC_SEI_TYPE_PAN_SCAN_RECT = 2, + HEVC_SEI_TYPE_FILLER_PAYLOAD = 3, + HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35 = 4, + HEVC_SEI_TYPE_USER_DATA_UNREGISTERED = 5, + HEVC_SEI_TYPE_RECOVERY_POINT = 6, + HEVC_SEI_TYPE_SCENE_INFO = 9, + HEVC_SEI_TYPE_FULL_FRAME_SNAPSHOT = 15, + HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16, + HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, + HEVC_SEI_TYPE_FILM_GRAIN_CHARACTERISTICS = 19, + HEVC_SEI_TYPE_POST_FILTER_HINT = 22, + HEVC_SEI_TYPE_TONE_MAPPING_INFO = 23, + HEVC_SEI_TYPE_FRAME_PACKING = 45, + HEVC_SEI_TYPE_DISPLAY_ORIENTATION = 47, + HEVC_SEI_TYPE_SOP_DESCRIPTION = 128, + HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS = 129, + HEVC_SEI_TYPE_DECODING_UNIT_INFO = 130, + HEVC_SEI_TYPE_TEMPORAL_LEVEL0_INDEX = 131, + HEVC_SEI_TYPE_DECODED_PICTURE_HASH = 132, + HEVC_SEI_TYPE_SCALABLE_NESTING = 133, + HEVC_SEI_TYPE_REGION_REFRESH_INFO = 134, + HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO = 137, + HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144, +} HEVC_SEI_Type; + +typedef struct HEVCSEIPictureHash { + struct AVMD5 *md5_ctx; + uint8_t md5[3][16]; + uint8_t is_md5; +} HEVCSEIPictureHash; + +typedef struct HEVCSEIFramePacking { + int present; + int arrangement_type; + int content_interpretation_type; + int quincunx_subsampling; +} HEVCSEIFramePacking; + +typedef struct HEVCSEIDisplayOrientation { + int present; + int anticlockwise_rotation; + int hflip, vflip; +} HEVCSEIDisplayOrientation; + +typedef struct HEVCSEIPictureTiming { + int picture_struct; +} HEVCSEIPictureTiming; + +typedef struct HEVCSEIA53Caption { + int a53_caption_size; + uint8_t *a53_caption; +} HEVCSEIA53Caption; + +typedef struct HEVCSEIMasteringDisplay { + int present; + uint16_t display_primaries[3][2]; + uint16_t white_point[2]; + uint32_t max_luminance; + uint32_t min_luminance; +} HEVCSEIMasteringDisplay; + +typedef struct HEVCSEIContentLight { + int present; + uint16_t max_content_light_level; + uint16_t max_pic_average_light_level; +} HEVCSEIContentLight; + +typedef struct HEVCSEIContext { + HEVCSEIPictureHash picture_hash; + HEVCSEIFramePacking frame_packing; + HEVCSEIDisplayOrientation display_orientation; + HEVCSEIPictureTiming picture_timing; + HEVCSEIA53Caption a53_caption; + HEVCSEIMasteringDisplay mastering_display; + HEVCSEIContentLight content_light; + int active_seq_parameter_set_id; +} HEVCSEIContext; + +struct HEVCParamSets; + +int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEIContext *s, + const struct HEVCParamSets *ps, int type); + +/** + * Reset SEI values that are stored on the Context. + * e.g. Caption data that was extracted during NAL + * parsing. + * + * @param s HEVCContext. + */ +void ff_hevc_reset_sei(HEVCSEIContext *s); + +#endif /* AVCODEC_HEVC_SEI_H */ diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 4f863a7f6e..cc7fc7e35f 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -26,7 +26,6 @@ #include #include "libavutil/buffer.h" -#include "libavutil/md5.h" #include "avcodec.h" #include "bswapdsp.h" @@ -36,6 +35,7 @@ #include "h2645_parse.h" #include "hevc.h" #include "hevc_ps.h" +#include "hevc_sei.h" #include "hevcdsp.h" #include "internal.h" #include "thread.h" @@ -464,59 +464,6 @@ typedef struct HEVCLocalContext { int boundary_flags; } HEVCLocalContext; -typedef struct HEVCSEIPictureHash { - struct AVMD5 *md5_ctx; - uint8_t md5[3][16]; - uint8_t is_md5; -} HEVCSEIPictureHash; - -typedef struct HEVCSEIFramePacking { - int present; - int arrangement_type; - int content_interpretation_type; - int quincunx_subsampling; -} HEVCSEIFramePacking; - -typedef struct HEVCSEIDisplayOrientation { - int present; - int anticlockwise_rotation; - int hflip, vflip; -} HEVCSEIDisplayOrientation; - -typedef struct HEVCSEIPictureTiming { - int picture_struct; -} HEVCSEIPictureTiming; - -typedef struct HEVCSEIA53Caption { - int a53_caption_size; - uint8_t *a53_caption; -} HEVCSEIA53Caption; - -typedef struct HEVCSEIMasteringDisplay { - int present; - uint16_t display_primaries[3][2]; - uint16_t white_point[2]; - uint32_t max_luminance; - uint32_t min_luminance; -} HEVCSEIMasteringDisplay; - -typedef struct HEVCSEIContentLight { - int present; - uint16_t max_content_light_level; - uint16_t max_pic_average_light_level; -} HEVCSEIContentLight; - -typedef struct HEVCSEIContext { - HEVCSEIPictureHash picture_hash; - HEVCSEIFramePacking frame_packing; - HEVCSEIDisplayOrientation display_orientation; - HEVCSEIPictureTiming picture_timing; - HEVCSEIA53Caption a53_caption; - HEVCSEIMasteringDisplay mastering_display; - HEVCSEIContentLight content_light; - int active_seq_parameter_set_id; -} HEVCSEIContext; - typedef struct HEVCContext { const AVClass *c; // needed by private avoptions AVCodecContext *avctx; @@ -622,9 +569,6 @@ typedef struct HEVCContext { HEVCSEIContext sei; } HEVCContext; -int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEIContext *s, - const HEVCParamSets *ps, int type); - /** * Mark all frames in DPB as unused for reference. */ @@ -728,15 +672,6 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size); -/** - * Reset SEI values that are stored on the Context. - * e.g. Caption data that was extracted during NAL - * parsing. - * - * @param s HEVCContext. - */ -void ff_hevc_reset_sei(HEVCSEIContext *s); - extern const uint8_t ff_hevc_qpel_extra_before[4]; extern const uint8_t ff_hevc_qpel_extra_after[4]; extern const uint8_t ff_hevc_qpel_extra[4];