Skip to content

Commit 5099f1a

Browse files
committed
libavcodec: add support for detecting forced subtitle segments.
This adds forced subtitle segment detection to the PGS subtitle decoder and copies the result to AVSubtitle.
1 parent ec38d98 commit 5099f1a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

mythtv/external/FFmpeg/libavcodec/avcodec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,6 +3183,7 @@ typedef struct AVSubtitle {
31833183
unsigned num_rects;
31843184
AVSubtitleRect **rects;
31853185
int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3186+
int forced;
31863187
} AVSubtitle;
31873188

31883189
/* packet functions */

mythtv/external/FFmpeg/libavcodec/pgssubdec.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct PGSSubPresentation {
4747
int y;
4848
int id_number;
4949
int object_number;
50+
int object_forced;
5051
} PGSSubPresentation;
5152

5253
typedef struct PGSSubPicture {
@@ -305,12 +306,16 @@ static void parse_presentation_segment(AVCodecContext *avctx,
305306
return;
306307

307308
/*
308-
* Skip 4 bytes of unknown:
309+
* Skip 3 bytes of unknown:
309310
* object_id_ref (2 bytes),
310311
* window_id_ref,
312+
*/
313+
buf += 3;
314+
315+
/*
311316
* composition_flag (0x80 - object cropped, 0x40 - object forced)
312317
*/
313-
buf += 4;
318+
ctx->presentation.object_forced = (bytestream_get_byte(&buf) & 0x40) >> 6;
314319

315320
x = bytestream_get_be16(&buf);
316321
y = bytestream_get_be16(&buf);
@@ -362,6 +367,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
362367
// Note that this may be wrong for more complex subtitles.
363368
if (!ctx->presentation.object_number)
364369
return 1;
370+
sub->forced = ctx->presentation.object_forced;
365371
sub->start_display_time = 0;
366372
sub->end_display_time = 20000;
367373
sub->format = 0;

0 commit comments

Comments
 (0)