aboutsummaryrefslogtreecommitdiff
path: root/lib/ffmpeg/libavcodec
diff options
context:
space:
mode:
authorMemphiz <memphis@machzwo.de>2012-09-16 14:55:54 +0200
committerMemphiz <memphis@machzwo.de>2012-09-30 22:19:35 +0200
commite3b35ff1f7aac89e72e32224d2e08191d8015532 (patch)
tree2e01826fa41cfca5f95c52f8a8d4c9b9087fa5c9 /lib/ffmpeg/libavcodec
parentacdd442f73adef6ac2af0a89f3ea970b67e5fbbb (diff)
[ffmpeg] - backport PGS subtitle fixes from ffmpeg (git revisions 37bbc9eb8bdae43d38a6fb7cc1356d1ce7d41e1c and 9dd82724315d651891f2a1ed733c4de06e9cb07a)
Diffstat (limited to 'lib/ffmpeg/libavcodec')
-rw-r--r--lib/ffmpeg/libavcodec/pgssubdec.c8
-rw-r--r--lib/ffmpeg/libavcodec/utils.c3
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/ffmpeg/libavcodec/pgssubdec.c b/lib/ffmpeg/libavcodec/pgssubdec.c
index 2785d25914..02e650acbc 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 99bf27ce16..c1cde2cc7f 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++;