forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ffmpeg] - patch file for PGS subtitle fixes
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
lib/ffmpeg/patches/0032-PGS-use-the-PTS-from-the-presentation-segment.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
diff --git a/lib/ffmpeg/libavcodec/pgssubdec.c b/lib/ffmpeg/libavcodec/pgssubdec.c | ||
index 2785d25..02e650a 100644 | ||
--- a/lib/ffmpeg/libavcodec/pgssubdec.c | ||
+++ b/lib/ffmpeg/libavcodec/pgssubdec.c | ||
@@ -64,6 +64,7 @@ typedef struct PGSSubContext { | ||
PGSSubPresentation presentation; | ||
uint32_t clut[256]; | ||
PGSSubPicture pictures[UINT16_MAX]; | ||
+ int64_t pts; | ||
} PGSSubContext; | ||
|
||
static av_cold int init_decoder(AVCodecContext *avctx) | ||
@@ -377,6 +378,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data, | ||
{ | ||
AVSubtitle *sub = data; | ||
PGSSubContext *ctx = avctx->priv_data; | ||
+ int64_t pts; | ||
|
||
uint16_t rect; | ||
|
||
@@ -386,7 +388,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, | ||
* not been cleared by a subsequent empty display command. | ||
*/ | ||
|
||
+ pts = ctx->pts != AV_NOPTS_VALUE ? ctx->pts : sub->pts; | ||
memset(sub, 0, sizeof(*sub)); | ||
+ sub->pts = pts; | ||
+ ctx->pts = AV_NOPTS_VALUE; | ||
|
||
// Blank if last object_count was 0. | ||
if (!ctx->presentation.object_count) | ||
@@ -431,8 +436,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data, | ||
static int decode(AVCodecContext *avctx, void *data, int *data_size, | ||
AVPacket *avpkt) | ||
{ | ||
+ PGSSubContext *ctx = avctx->priv_data; | ||
const uint8_t *buf = avpkt->data; | ||
int buf_size = avpkt->size; | ||
+ AVSubtitle *sub = data; | ||
|
||
const uint8_t *buf_end; | ||
uint8_t segment_type; | ||
@@ -477,6 +484,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, | ||
break; | ||
case PRESENTATION_SEGMENT: | ||
parse_presentation_segment(avctx, buf, segment_length); | ||
+ ctx->pts = sub->pts; | ||
break; | ||
case WINDOW_SEGMENT: | ||
/* | ||
diff --git a/lib/ffmpeg/libavcodec/utils.c b/lib/ffmpeg/libavcodec/utils.c | ||
index 99bf27c..c1cde2c 100644 | ||
--- a/lib/ffmpeg/libavcodec/utils.c | ||
+++ b/lib/ffmpeg/libavcodec/utils.c | ||
@@ -1396,6 +1396,9 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, | ||
avctx->pkt = avpkt; | ||
*got_sub_ptr = 0; | ||
avcodec_get_subtitle_defaults(sub); | ||
+ if (avctx->time_base.den && avpkt->pts != AV_NOPTS_VALUE) | ||
+ sub->pts = av_rescale_q(avpkt->pts, | ||
+ avctx->time_base, AV_TIME_BASE_Q); | ||
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt); | ||
if (*got_sub_ptr) | ||
avctx->frame_number++; |