From patchwork Thu Jul 11 19:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mikrohard@gmail.com X-Patchwork-Id: 13900 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 7F46544A17D for ; Thu, 11 Jul 2019 22:13:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 60ED668A7E6; Thu, 11 Jul 2019 22:13:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 54FB368A7D5 for ; Thu, 11 Jul 2019 22:13:19 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id l2so6730497wmg.0 for ; Thu, 11 Jul 2019 12:13:19 -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; bh=/YZEGOVK5GiY218esvwp/5Ff5j4ormSajbP4id21kgY=; b=ixDlzAVf4o3AUc6oasxQ/2QYd75gdb9x4mdGzsCFQz7t6I2cLPdIbvmioowwvRE/l6 F2MFhd7iUk8Y9arv+4+qsVgpNUZu0rEUWPHGKwCkUv5G33d+5NSzud3Ihk3gnplgHa22 P8Qk4izqeaw+gXQ5jPtBC14oce54xdS0IlsqRsZte41/vyHaLnYEKf1wQXESZE04gK2e N1QktnHRvbuPPBR2odosdje96XSJX1DNQhkfLzlK7x4zGMPiWLze9BD+X4VMowYchLqf QXDrzoaiMgrrV3b7QHGDgqiZ53u+mavWPThNbh0hq70gcAsMs6Rg8aUdeB/8Il2YFJ/Q Qs5A== 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; bh=/YZEGOVK5GiY218esvwp/5Ff5j4ormSajbP4id21kgY=; b=Svp3O11AF24q6EU8hYreOFhTd/sbZuW8VYrC6ELHOwsgoth78nDb8n7SpJF5GsB4Ue cWV/El9+8QbFfpTkW9LKCE7LvLo+qJ44/e2wSNgmfiU5d11PElyeRtpa3KsZtfzEY4XG gD6zI0DV19lmF/PvH+d/GuTPttwgEeNUfW06xzhWr/F92k/4tglOfxUZHEqnuRmfWa9I Gyfg5XL99NUT0T2saZQJFCd5QRMmArB+n36ZC2idOkYBwViscphK2l/saTbBPOabM4yT z5mb50zU6ms4NjQQFQwbObVZuHHstnyGfQ2CSr6AKdEAzTlSpGP9kOL/DJLg2TWBMF46 BHHg== X-Gm-Message-State: APjAAAXDlwUaQfEvKttpHcNGTkQrL7/oS6W27yObNJYCtY7PoSHc4qrW hYYjEs/de8IJbKeetPuE41WADQ62Fg== X-Google-Smtp-Source: APXvYqzfLcWmPP5Ukkxy47AdiYd4zNtqWAC0KM4fvbxBDAAuRgb7S2aunYLLWw5RlR3qL7Ds11DrlA== X-Received: by 2002:a1c:4d6:: with SMTP id 205mr4998984wme.148.1562872016903; Thu, 11 Jul 2019 12:06:56 -0700 (PDT) Received: from localhost.localdomain (89-212-97-97.dynamic.t-2.net. [89.212.97.97]) by smtp.gmail.com with ESMTPSA id w25sm5718007wmk.18.2019.07.11.12.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 12:06:56 -0700 (PDT) From: mikrohard@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Jul 2019 21:06:53 +0200 Message-Id: <20190711190653.56289-1-mikrohard@gmail.com> X-Mailer: git-send-email 2.10.2 Subject: [FFmpeg-devel] [PATCH] Add support for Display Definition Segment to DVB Subtitle encoder 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: Jernej Fijacko MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Current version of dvbsub encoder doesn't support HD DVB subtitles. The high resolution bitmaps are muxed into the stream but without the DDS (display definition segment) the players asume that the DVB subtitles are in SD (720x576) resolution which causes them to either render the subtitles too large and misplaced or don't render them at all. By including the DDS as defined in section 7.7.1 of ETSI EN 300 743 (V1.3.1) this problem is fixed. 7.2.1 Display definition segment The display definition for a subtitle service may be defined by the display definition segment if present in the stream. Absence of a DDS implies that the stream is coded in accordance with EN 300 743 (V1.2.1) [5] and that a display width of 720 pixels and a display height of 576 lines may be assumed. https://www.etsi.org/deliver/etsi_en/300700_300799/300743/01.03.01_60/en_300743v010301p.pdf Signed-off-by: Jernej Fijacko --- libavcodec/dvbsub.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index 8cce702..c838567 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -247,7 +247,8 @@ static void dvb_encode_rle8(uint8_t **pq, *pq = q; } -static int encode_dvb_subtitles(DVBSubtitleContext *s, +static int encode_dvb_subtitles(AVCodecContext *avctx, + DVBSubtitleContext *s, uint8_t *outbuf, const AVSubtitle *h) { uint8_t *q, *pseg_len; @@ -261,6 +262,19 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s, if (h->num_rects && !h->rects) return -1; + if (avctx->width > 0 && avctx->height > 0) { + /* display definition segment */ + *q++ = 0x0f; /* sync_byte */ + *q++ = 0x14; /* segment_type */ + bytestream_put_be16(&q, page_id); + pseg_len = q; + q += 2; /* segment length */ + *q++ = 0x20; /* dds version number & display window flag */ + bytestream_put_be16(&q, avctx->width - 1); /* display width */ + bytestream_put_be16(&q, avctx->height - 1); /* display height */ + bytestream_put_be16(&pseg_len, q - pseg_len - 2); + } + /* page composition segment */ *q++ = 0x0f; /* sync_byte */ @@ -449,7 +463,7 @@ static int dvbsub_encode(AVCodecContext *avctx, DVBSubtitleContext *s = avctx->priv_data; int ret; - ret = encode_dvb_subtitles(s, buf, sub); + ret = encode_dvb_subtitles(avctx, s, buf, sub); return ret; }