[FFmpeg-devel] Add support for Display Definition Segment to DVB Subtitle

Submitted by mikrohard@gmail.com on July 12, 2019, 10:24 p.m.

Details

Message ID 20190712222429.58912-1-mikrohard@gmail.com
State Accepted
Commit f86f213a6d3dd749152a105df839172fe4c772d1
Headers show

Commit Message

mikrohard@gmail.com July 12, 2019, 10:24 p.m.
From: Jernej <mikrohard@gmail.com>

Patch with requested changes.

---
 libavcodec/dvbsub.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Moritz Barsnick July 12, 2019, 10:45 p.m.
On Sat, Jul 13, 2019 at 00:24:29 +0200, mikrohard@gmail.com wrote:
> From: Jernej <mikrohard@gmail.com>

I think you had your full name in here originally. Note that whatever
you provide here will be in the repo forever.

>
> Patch with requested changes.

Your original commit text should be in here, not your message to the
mailing list. Is this really the commit message you provided when
committing locally? Your original text "Current version of dvbsub
encoder doesn't support HD DVB subtitles. ..." was fine, except that it
was missing some line breaks.

>
> ---
[...]

Moritz
Jernej July 13, 2019, 12:57 p.m.
Thanks for the explanation. I sent a new patch with the original commit
message (and additional line break). I hope that everything is fine now.

Regards,
Jernej

On Sat, Jul 13, 2019 at 12:45 AM Moritz Barsnick <barsnick@gmx.net> wrote:

> On Sat, Jul 13, 2019 at 00:24:29 +0200, mikrohard@gmail.com wrote:
> > From: Jernej <mikrohard@gmail.com>
>
> I think you had your full name in here originally. Note that whatever
> you provide here will be in the repo forever.
>
> >
> > Patch with requested changes.
>
> Your original commit text should be in here, not your message to the
> mailing list. Is this really the commit message you provided when
> committing locally? Your original text "Current version of dvbsub
> encoder doesn't support HD DVB subtitles. ..." was fine, except that it
> was missing some line breaks.
>
> >
> > ---
> [...]
>
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

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;
 }