From patchwork Wed May 22 01:04:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13228 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 0A0DE448570 for ; Wed, 22 May 2019 04:13:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0D4C68A8FA; Wed, 22 May 2019 04:13:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76C1F68A807 for ; Wed, 22 May 2019 04:13:32 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id c66so3519207wme.0 for ; Tue, 21 May 2019 18:13:32 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=HthUV3Lhx8f4bwnyANhIGvWnVa+UTZjxUoyS0O+fm5k=; b=kEITzgM9Han+OmnIX2DD54U1hLmKKz073bUaTH2mMbIsJM9XTLHXYmB9OR99sfZTv1 TH2ziPGxITdzwbI26WgONCTArD0MGpXUh+QH3Bjqzl5aBbuPJR9Sn/6MTRgFPtN119RC PiFbCWV4cHoNg2dU0w9fCe6dsI7A2X3PLZztGueNir7UQUfuSrEVoUHiEStyKVy0sS8j 8V56UZthjnylQN+/qPNekd1vyx9Uowm+V1sbRRMYwmdTWnOo87cHe8Qo5UC5MRvU8lTV 6n+EOu27sXAi5DP5HIh9ZqdjUyghyVf8vyb2Fhx18Xjgg7wXbL65Z8Ep9x4nfuyTriJ3 KyEg== 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:mime-version:content-transfer-encoding; bh=HthUV3Lhx8f4bwnyANhIGvWnVa+UTZjxUoyS0O+fm5k=; b=ScNVd4zcdfUhdlufPIEocUDeGNkmHjaCI5ATrvQ7NuFxWc5bggxoed/fgPo6mVaS7R wW/6AxL2wohr6C6gp8ZBfmLJA6shQLK746Vno1ULvLhi2oZraLRabn40wKF7yD/meX4X 7xVFOo21Rf/6pEdj+KLUO9BfpYO3vDbfgieRQps/f+enuVNLoa4q0d0VkemEXJ6x0XGC 7WfGaIbyPOq3Nz5a6pms98Esari3hV0GHm09w04ZW8mup78nzQiFlIT+gWqQum6ccSZz sNcgiJ5tpcou26CKIlpNTjGMoKkP9mAtbjGPMAnDsElwtbTnm8tCfm/98x7j6pNKnEvh 7i0w== X-Gm-Message-State: APjAAAUfsm7zqBuu8fvcCDJPAHp/znyI7mb80VVQzGvv5w/VR9IMIv7i B1nr2IMqudK95oqfQX0qJk1Kr0Tg X-Google-Smtp-Source: APXvYqy2gLTOpUGXpvyxuyc+fJ2SeaLDjQk+Q+QtJJkUc/tH/X15mIIY5sXhhm4s3rnBf1zvjh0gow== X-Received: by 2002:a7b:c397:: with SMTP id s23mr5346121wmj.85.1558487611870; Tue, 21 May 2019 18:13:31 -0700 (PDT) Received: from localhost.localdomain (ipbcc18715.dynamic.kabel-deutschland.de. [188.193.135.21]) by smtp.gmail.com with ESMTPSA id z1sm8614486wrl.91.2019.05.21.18.13.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 18:13:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 May 2019 03:04:34 +0200 Message-Id: <20190522010441.44257-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522010441.44257-1-andreas.rheinhardt@gmail.com> References: <20190522010441.44257-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/11] cbs_mpeg2: Fix storage type for frame_centre_*_offset 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The frame_centre_horizontal/vertical_offset values contained in picture display extensions are actually signed values (i.e. it is possible to indicate that the display device should add black bars/pillars). The files sony-ct3.bs and tcela-6.bits (which are both used in fate tests for mpeg2_metadata) contain picture display extensions; the former even contains a negative frame_centre_vertical_offset. Fortunately, the old code did not damage the picture display extensions when one did a cycle of reading and writing. For the same reason the fate tests needn't be updated either. Furthermore these fields now use the trace output for matrices. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs_mpeg2.c | 20 ++++++++++++++++++++ libavcodec/cbs_mpeg2.h | 4 ++-- libavcodec/cbs_mpeg2_syntax_template.c | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 437eac88a3..de0ad8a043 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -48,6 +48,8 @@ xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__) #define uirs(width, name, subs, ...) \ xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__) +#define sis(width, name, subs, ...) \ + xsi(width, name, current->name, subs, __VA_ARGS__) #define READ @@ -62,6 +64,15 @@ var = value; \ } while (0) +#define xsi(width, name, var, subs, ...) do { \ + int32_t value; \ + CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), &value, \ + MIN_INT_BITS(width), \ + MAX_INT_BITS(width))); \ + var = value; \ + } while (0) + #define marker_bit() do { \ av_unused uint32_t one; \ CHECK(ff_cbs_read_unsigned(ctx, rw, 1, "marker_bit", NULL, &one, 1, 1)); \ @@ -81,6 +92,7 @@ #undef READWRITE #undef RWContext #undef xui +#undef xsi #undef marker_bit #undef nextbits #undef infer @@ -96,6 +108,13 @@ var, range_min, range_max)); \ } while (0) +#define xsi(width, name, var, subs, ...) do { \ + CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), var, \ + MIN_INT_BITS(width), \ + MAX_INT_BITS(width))); \ + } while (0) + #define marker_bit() do { \ CHECK(ff_cbs_write_unsigned(ctx, rw, 1, "marker_bit", NULL, 1, 1, 1)); \ } while (0) @@ -117,6 +136,7 @@ #undef READWRITE #undef RWContext #undef xui +#undef xsi #undef marker_bit #undef nextbits #undef infer diff --git a/libavcodec/cbs_mpeg2.h b/libavcodec/cbs_mpeg2.h index 7565695acb..11f93b9df8 100644 --- a/libavcodec/cbs_mpeg2.h +++ b/libavcodec/cbs_mpeg2.h @@ -164,8 +164,8 @@ typedef struct MPEG2RawQuantMatrixExtension { } MPEG2RawQuantMatrixExtension; typedef struct MPEG2RawPictureDisplayExtension { - uint16_t frame_centre_horizontal_offset[3]; - uint16_t frame_centre_vertical_offset[3]; + int16_t frame_centre_horizontal_offset[3]; + int16_t frame_centre_vertical_offset[3]; } MPEG2RawPictureDisplayExtension; typedef struct MPEG2RawExtensionData { diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c index 87db0ad039..e34fa9495f 100644 --- a/libavcodec/cbs_mpeg2_syntax_template.c +++ b/libavcodec/cbs_mpeg2_syntax_template.c @@ -303,9 +303,9 @@ static int FUNC(picture_display_extension)(CodedBitstreamContext *ctx, RWContext HEADER("Picture Display Extension"); for (i = 0; i < mpeg2->number_of_frame_centre_offsets; i++) { - ui(16, frame_centre_horizontal_offset[i]); + sis(16, frame_centre_horizontal_offset[i], 1, i); marker_bit(); - ui(16, frame_centre_vertical_offset[i]); + sis(16, frame_centre_vertical_offset[i], 1, i); marker_bit(); }