From patchwork Fri Jul 12 08:21:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jernej X-Patchwork-Id: 13908 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 823F6447DEA for ; Fri, 12 Jul 2019 11:21:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 57D6368AC46; Fri, 12 Jul 2019 11:21:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C22D468ABC1 for ; Fri, 12 Jul 2019 11:21:50 +0300 (EEST) Received: by mail-lj1-f194.google.com with SMTP id 16so8470003ljv.10 for ; Fri, 12 Jul 2019 01:21:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kZ+TULTDXMir/Y9Uqby4zHn4S9nSmixRmS6vDATSmI8=; b=d8zaanR0rcNoUvX9S0F8NSTLY4REvzdsVrQJQXVLi9j28T+LP4LOXgFun/Zi1Wv11E 4OMiasC+q0jIMxT/LBSw0EcpI5hDH1cxwuz0d4YzT2QVAClA51HzkeNnfKmp18vxWYgb LTLkpmS2NDGpzPj0KssAmho5IUatBWmr4fStPJ9T99fQqNx/ijeO9aXH1v0lBLpRk3Em WC5tMtBeu270/bTjCSxpEloTthhl2xTHOgagYXVv9uVD0SKBK8mVKEFQdA5JUWLIzmwp TmdyIUFMg+7FK0qcL+jjSSiJJJvJfexBW9kwWcGmlHSaDrfFnSoIO1obsTvRzsTa5iPK Qi/A== X-Gm-Message-State: APjAAAWXhYkmuv0Lhp61fyfpTLjn9qbFHtGSzCpoTznPTQMWGuJmifA/ c0kAjNIeFy05Rp30nBGEYOCsZJCMvqqMxkLvqAl8KT0= X-Google-Smtp-Source: APXvYqxNABaCXv4O9YsBntIJS2nmkB7Dy0U32QGZ2wN72+R+8gm6owmZNWuRSfjLlfdR/t8oCFUJ8WvigVDaegDR+w4= X-Received: by 2002:a2e:9045:: with SMTP id n5mr4842884ljg.66.1562919709907; Fri, 12 Jul 2019 01:21:49 -0700 (PDT) MIME-Version: 1.0 References: <20190711190653.56289-1-mikrohard@gmail.com> In-Reply-To: From: Jernej Date: Fri, 12 Jul 2019 10:21:38 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Here's the fixed patch. I'm not familiar with providing patches via a mailing list. If replying doesn't work, I'll just use a new git send-mail. 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 8cce702a9e..a8d43d81d6 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; }