summaryrefslogtreecommitdiff
path: root/src/internal/subtitle/kitsubtitle.c
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2018-06-23 17:53:11 +0300
committerTuomas Virtanen <katajakasa@gmail.com>2018-06-23 17:53:11 +0300
commit60dd75397f1ce9c4a56e74ee0bb94cebd4ab831c (patch)
tree03b39dc8f6f1b2167971dd6b3a7fa89a3ee29bda /src/internal/subtitle/kitsubtitle.c
parent329de67ea44552c1d08e23203daee7e878ffd759 (diff)
Implement new API for subtitle screen size and stream indexes
Diffstat (limited to 'src/internal/subtitle/kitsubtitle.c')
-rw-r--r--src/internal/subtitle/kitsubtitle.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/internal/subtitle/kitsubtitle.c b/src/internal/subtitle/kitsubtitle.c
index 8935efc..d6641fc 100644
--- a/src/internal/subtitle/kitsubtitle.c
+++ b/src/internal/subtitle/kitsubtitle.c
@@ -83,10 +83,10 @@ static void dec_close_subtitle_cb(Kit_Decoder *dec) {
free(subtitle_dec);
}
-Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat *format, int w, int h) {
+Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, int stream_index, Kit_SubtitleFormat *format, int w, int h) {
assert(src != NULL);
assert(format != NULL);
- if(src->subtitle_stream_index < 0) {
+ if(stream_index < 0) {
return NULL;
}
@@ -94,7 +94,8 @@ Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat
// First the generic decoder component
Kit_Decoder *dec = Kit_CreateDecoder(
- src, src->subtitle_stream_index,
+ src,
+ stream_index,
KIT_SUBTITLE_OUT_SIZE,
free_out_subtitle_packet_cb);
if(dec == NULL) {
@@ -103,7 +104,7 @@ Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat
// Set format. Note that is_enabled may be changed below ...
format->is_enabled = true;
- format->stream_index = src->subtitle_stream_index;
+ format->stream_index = stream_index;
format->format = SDL_PIXELFORMAT_RGBA32; // Always this
// ... then allocate the subtitle decoder
@@ -143,7 +144,7 @@ Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat
}
// Allocate texture atlas for subtitle rectangles
- Kit_TextureAtlas *atlas = Kit_CreateAtlas(1024, 1024);
+ Kit_TextureAtlas *atlas = Kit_CreateAtlas();
if(atlas == NULL) {
Kit_SetError("Unable to allocate subtitle texture atlas");
goto exit_3;
@@ -170,6 +171,14 @@ exit_0:
return NULL;
}
+void Kit_SetSubtitleDecoderSize(Kit_Decoder *dec, int w, int h) {
+ assert(dec != NULL);
+ Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
+ subtitle_dec->w = w;
+ subtitle_dec->h = h;
+ Kit_SetSubtitleRendererSize(subtitle_dec->renderer, w, h);
+}
+
int Kit_GetSubtitleDecoderData(Kit_Decoder *dec, SDL_Texture *texture, SDL_Rect *sources, SDL_Rect *targets, int limit) {
assert(dec != NULL);
assert(texture != NULL);