summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2019-12-13 14:07:01 -0800
committerJohn Stebbins <[email protected]>2020-03-29 08:23:20 -0600
commite720e746d75ff711d14fd832ca993bb460d8437d (patch)
tree120e6b27b49c953b1e1c02c773013ae42ae2c166 /libhb
parent93ac83aca7220403b84fb88d4b0326f383e862b9 (diff)
decavsub: remove dvb subtitle post-stuffing during demux
This seems to be what ffmpeg expects. This way we also mux it correctly into mkv, i.e. without the trailing 0xff stuffing byte.
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavsub.c10
-rw-r--r--libhb/stream.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/libhb/decavsub.c b/libhb/decavsub.c
index 27e94099c..442a857b3 100644
--- a/libhb/decavsub.c
+++ b/libhb/decavsub.c
@@ -348,15 +348,7 @@ int decavsubWork( hb_avsub_context_t * ctx,
}
// <UGLY_HACKS>
- // Ugly hack, but ffmpeg doesn't consume a trailing 0xff in
- // DVB subtitle buffers :(
- if (ctx->subtitle->source == DVBSUB &&
- avp.size > usedBytes &&
- avp.data[usedBytes] == 0xff)
- {
- usedBytes++;
- }
- // Another ugly hack, ffmpeg always returns 0 for CC decoder :(
+ // ffmpeg always returns 0 for CC decoder :(
//
// Also returns 0 for DVD subtitles, until it emits an AVSubtitle,
// then it returns the total number of bytes used to construct
diff --git a/libhb/stream.c b/libhb/stream.c
index bb99688e0..77fa1811f 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -122,6 +122,7 @@ typedef struct
int64_t scr;
int header_len;
int packet_len;
+ int stuffing_len;
} hb_pes_info_t;
typedef struct {
@@ -2948,7 +2949,8 @@ static int parse_pes_header(
}
bits_skip(bb, 8 * 4);
- pes_info->packet_len = bits_get(bb, 16);
+ pes_info->packet_len = bits_get(bb, 16);
+ pes_info->stuffing_len = 0;
/*
* This would normally be an error. But the decoders can generally
@@ -3178,6 +3180,7 @@ static int parse_pes_header(
bits_skip(bb, 8);
pes_info->bd_substream_id = bits_get(bb, 8);
pes_info->header_len += 2;
+ pes_info->stuffing_len = 1;
}
}
return 1;
@@ -4644,6 +4647,11 @@ static hb_buffer_t * generate_output_data(hb_stream_t *stream, int curstream)
uint8_t *tdat = b->data + ts_stream->packet_offset;
int es_size = b->size - ts_stream->packet_offset;
+ if (ts_stream->packet_len >= ts_stream->pes_info.packet_len + 6)
+ {
+ // Remove trailing stuffing bytes (DVB subtitles)
+ es_size -= ts_stream->pes_info.stuffing_len;
+ }
if (es_size <= 0)
{
if (ts_stream->pes_info.packet_len > 0 &&