From patchwork Mon Feb 17 15:10:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alen_Vre=C4=8Dko?= X-Patchwork-Id: 17822 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 510AC44483E for ; Mon, 17 Feb 2020 17:10:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29557689247; Mon, 17 Feb 2020 17:10:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.fora.si (mail.fora.si [89.212.147.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 74976687F0B for ; Mon, 17 Feb 2020 17:10:29 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by mail.fora.si (Postfix) with ESMTP id 8BAFC80FE0F1 for ; Mon, 17 Feb 2020 16:10:28 +0100 (CET) Received: from mail.fora.si ([127.0.0.1]) by localhost (mail.fora.si [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 33rXHjWUtKiU for ; Mon, 17 Feb 2020 16:10:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.fora.si (Postfix) with ESMTP id 2015980FC4F1 for ; Mon, 17 Feb 2020 16:10:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.fora.si 2015980FC4F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fora.si; s=AEE0C26A-5E8C-11E8-8665-7BEB883373C3; t=1581952228; bh=yW/5rXPa9a1rJs/jJMcFqGLHWNQL9m+o/8P5snxVweg=; h=Date:From:To:Message-ID:MIME-Version; b=H11xqdL6Omchlz3Wvi9g1qY4POQ09eWeiEnArniJql8FbNs37rovGai/oghIR3zAz uaHZ+0XVLJ4fgHvMNqykrtiQugVF2uWxy2tbi2D+Bkr2eut3ITjKAxeTCq2BM7FG9M fKrYasC7Z9JMvcUAyLSp3R6w+eGC08BNQDNcR13atM6AZsGixl4sgj9J3ecAa4phFo YcFkM2+fBFO7eEXnwnwPFymveqChBQ+RNH9Q9pOOCt3BcuHiVmpWJM/n8mxRbdi5AY p5pVBJKfAD/QYy8zW4snXqJh7TRiLkX04zBs5VQAgOXCz8hZvyQmD4lMUKAJ6IC+H3 LdsGYq3kz/X3Q== X-Virus-Scanned: amavisd-new at mail.fora.si Received: from mail.fora.si ([127.0.0.1]) by localhost (mail.fora.si [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rE4Ou9zBz8fc for ; Mon, 17 Feb 2020 16:10:28 +0100 (CET) Received: from mail.fora.si (mail.fora.si [192.168.41.209]) by mail.fora.si (Postfix) with ESMTP id 0483F80FC4EF for ; Mon, 17 Feb 2020 16:10:28 +0100 (CET) Date: Mon, 17 Feb 2020 16:10:27 +0100 (CET) From: Alen =?utf-8?q?Vre=C4=8Dko?= To: ffmpeg-devel@ffmpeg.org Message-ID: <608846815.195543.1581952227982.JavaMail.zimbra@fora.si> MIME-Version: 1.0 X-Originating-IP: [192.168.41.209] X-Mailer: Zimbra 8.8.8_GA_2075 (ZimbraWebClient - FF72 (Linux)/8.8.8_GA_2031) Thread-Index: S8pUlDY0WdpJK9ymTDL2e/w59Sfi+g== Thread-Topic: dvbsub.c, change segment order to be in line with spec Subject: [FFmpeg-devel] dvbsub.c, change segment order to be in line with spec 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" Hello, everyone. I'd like to request a change in order of DVB segments to be in line with ETSI 300 743. Basically Region Composition Segment should come before CLUT segment. This caused problems on legacy STBs namely Amino A110. In the ETSI EN 300 743 V1.6.1 (2018-10) section 4.4 it is written: The order of their listing here matches their ordering, when present, in a display set: display definition segment ... page composition segment ... region composition segment ... disparity signalling segment ... CLUT definition segment ... alternative CLUT segment ... object data segment ... end of display set segment ... It makes sense for this order to be implemented by ffmpeg. I attached a patch, made using git format-patch. Best regards Alen From eaa9addf0bcab40e17d67c699919e5610b341eab Mon Sep 17 00:00:00 2001 From: Alen Vrecko Date: Mon, 17 Feb 2020 15:47:05 +0100 Subject: [PATCH] Change Dvb segment order to be the same as in ETSI EN 300 743 spec. Having CLUT before Region Composition Segment caused problems on legacy STBs i.e. Amino A110. In any case, the spec assumes an order. In section 4.4. It is written: "The order of their listing (referring to segment types) here matches their ordering, when present, in a display set". I think ffmpeg should match the order. --- libavcodec/dvbsub.c | 80 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index a8d43d81d6..e76d3044b8 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -296,6 +296,46 @@ static int encode_dvb_subtitles(AVCodecContext *avctx, bytestream_put_be16(&pseg_len, q - pseg_len - 2); + for (region_id = 0; region_id < h->num_rects; region_id++) { + + /* region composition segment */ + + if (h->rects[region_id]->nb_colors <= 4) { + /* 2 bpp, some decoders do not support it correctly */ + bpp_index = 0; + } else if (h->rects[region_id]->nb_colors <= 16) { + /* 4 bpp, standard encoding */ + bpp_index = 1; + } else if (h->rects[region_id]->nb_colors <= 256) { + /* 8 bpp, standard encoding */ + bpp_index = 2; + } else { + return -1; + } + + *q++ = 0x0f; /* sync_byte */ + *q++ = 0x11; /* segment_type */ + bytestream_put_be16(&q, page_id); + pseg_len = q; + q += 2; /* segment length */ + *q++ = region_id; + *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */ + bytestream_put_be16(&q, h->rects[region_id]->w); /* region width */ + bytestream_put_be16(&q, h->rects[region_id]->h); /* region height */ + *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03; + *q++ = region_id; /* clut_id == region_id */ + *q++ = 0; /* 8 bit fill colors */ + *q++ = 0x03; /* 4 bit and 2 bit fill colors */ + + bytestream_put_be16(&q, region_id); /* object_id == region_id */ + *q++ = (0 << 6) | (0 << 4); + *q++ = 0; + *q++ = 0xf0; + *q++ = 0; + + bytestream_put_be16(&pseg_len, q - pseg_len - 2); + } + if (h->num_rects) { for (clut_id = 0; clut_id < h->num_rects; clut_id++) { @@ -346,46 +386,6 @@ static int encode_dvb_subtitles(AVCodecContext *avctx, } } - for (region_id = 0; region_id < h->num_rects; region_id++) { - - /* region composition segment */ - - if (h->rects[region_id]->nb_colors <= 4) { - /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; - } else if (h->rects[region_id]->nb_colors <= 16) { - /* 4 bpp, standard encoding */ - bpp_index = 1; - } else if (h->rects[region_id]->nb_colors <= 256) { - /* 8 bpp, standard encoding */ - bpp_index = 2; - } else { - return -1; - } - - *q++ = 0x0f; /* sync_byte */ - *q++ = 0x11; /* segment_type */ - bytestream_put_be16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - *q++ = region_id; - *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */ - bytestream_put_be16(&q, h->rects[region_id]->w); /* region width */ - bytestream_put_be16(&q, h->rects[region_id]->h); /* region height */ - *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03; - *q++ = region_id; /* clut_id == region_id */ - *q++ = 0; /* 8 bit fill colors */ - *q++ = 0x03; /* 4 bit and 2 bit fill colors */ - - bytestream_put_be16(&q, region_id); /* object_id == region_id */ - *q++ = (0 << 6) | (0 << 4); - *q++ = 0; - *q++ = 0xf0; - *q++ = 0; - - bytestream_put_be16(&pseg_len, q - pseg_len - 2); - } - if (h->num_rects) { for (object_id = 0; object_id < h->num_rects; object_id++) { -- 2.21.1