From patchwork Sat Jul 13 12:52:50 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: 13926 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 482CB4489FE for ; Sat, 13 Jul 2019 15:53:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1E77768ABB3; Sat, 13 Jul 2019 15:53:00 +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 257B168A7EB for ; Sat, 13 Jul 2019 15:52:53 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id s3so11148410wms.2 for ; Sat, 13 Jul 2019 05:52:53 -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; bh=EJieGJWNr0xCqe++dFBeTRB+lIT6Y5HfFVKfGlVpEhc=; b=eREco0jPl7euNs/sSAgZhq0zOXfFng9lz+k6OxU1Rf5Z+NZo6HaLVLRdo0UA8SHhlT OTSGHNMp2uWz7Vei/zR3f6k998IDxQDeN9M+YG2ji6fj6Mw3PlUxXLogCU6KRHnr7gVo kJa5tDEINUCD4OOtr0bpFxA1/5A8CkWgMqlRdXucBuExJfgqDyQCeqNtnxkFKTPzS4I2 2uW63ETp/96GT3fMgC7PhB8LWw2AeerQ7ODjF0JLZ6ATlyGpUWkw1fMV7k5sAqleINBG Q3jTyjh8xWPUrylV1jcPHzEWidl8PESPqW4DgGOufPSNSbZA527YJXjKsYVUTNcSL+hR fVsQ== 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; bh=EJieGJWNr0xCqe++dFBeTRB+lIT6Y5HfFVKfGlVpEhc=; b=MVl5TnxAy3Ze2IknDFiourGG1l1SqKkJ7UgnWuln1k2W8nNpH9h75uaZko1XjZM+rq zsZvNrA7wvFDm4IqiEUnuafTyIdkV6sCWovYqjjC54BPEZCfFnK7sX4U/DoH4jRZRCon K3cPBlbh43gGB3tGnNFJgm1Kb0xdl2NUfvhHSRTXU++Ls/9AXH1kp2QFPMUW3Cv8XHpm NXixXVIKE7kgATdib+kQ23k/7qvexAsG8v9Cw9mBR3sEmo2kjvU+zcF4tGBMzsfS7R4j mPxu19h+/GcEiEejCEV/4LpFP1AK1CIwvebiultHo0BqYaLhNYOZjO3lLNgRVm/Q4mSN q0mw== X-Gm-Message-State: APjAAAXRQ1GLZiLI4CFW5q7SSwtMmbx4k0F/+08X7vqHDtefkqXUUTfp nS/Qu9aFdS1DIAKCdTfJab0Eo4U= X-Google-Smtp-Source: APXvYqxQqjOP/GH8oNrPGNmm4pE/KrGQuHzl4maRO6vc4WjjzaWR3LC5cPX1wAU/O3vYfCqI7bEDrQ== X-Received: by 2002:a7b:ce01:: with SMTP id m1mr14731651wmc.1.1563022372386; Sat, 13 Jul 2019 05:52:52 -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 r12sm14962930wrt.95.2019.07.13.05.52.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2019 05:52:51 -0700 (PDT) From: mikrohard@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Jul 2019 14:52:50 +0200 Message-Id: <20190713125250.60298-1-mikrohard@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20190711190653.56289-1-mikrohard@gmail.com> References: <20190711190653.56289-1-mikrohard@gmail.com> 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" From: Jernej Fijacko 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 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index 8cce702..a8d43d8 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -247,9 +247,10 @@ static void dvb_encode_rle8(uint8_t **pq, *pq = q; } -static int encode_dvb_subtitles(DVBSubtitleContext *s, +static int encode_dvb_subtitles(AVCodecContext *avctx, uint8_t *outbuf, const AVSubtitle *h) { + DVBSubtitleContext *s = avctx->priv_data; uint8_t *q, *pseg_len; int page_id, region_id, clut_id, object_id, i, bpp_index, page_state; @@ -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++ = 0x00; /* 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 */ @@ -446,10 +460,9 @@ static int dvbsub_encode(AVCodecContext *avctx, unsigned char *buf, int buf_size, const AVSubtitle *sub) { - DVBSubtitleContext *s = avctx->priv_data; int ret; - ret = encode_dvb_subtitles(s, buf, sub); + ret = encode_dvb_subtitles(avctx, buf, sub); return ret; }