summaryrefslogtreecommitdiff
path: root/include/kitchensink
diff options
context:
space:
mode:
Diffstat (limited to 'include/kitchensink')
-rw-r--r--include/kitchensink/internal/kitdecoder.h3
-rw-r--r--include/kitchensink/internal/libass.h40
-rw-r--r--include/kitchensink/internal/subtitle/kitatlas.h40
-rw-r--r--include/kitchensink/internal/subtitle/kitsubtitle.h2
-rw-r--r--include/kitchensink/internal/subtitle/kitsubtitlepacket.h14
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubass.h2
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubimage.h2
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h9
-rw-r--r--include/kitchensink/internal/video/kitvideo.h2
-rw-r--r--include/kitchensink/kitplayer.h4
10 files changed, 91 insertions, 27 deletions
diff --git a/include/kitchensink/internal/kitdecoder.h b/include/kitchensink/internal/kitdecoder.h
index 6ec209e..520d402 100644
--- a/include/kitchensink/internal/kitdecoder.h
+++ b/include/kitchensink/internal/kitdecoder.h
@@ -45,9 +45,12 @@ KIT_LOCAL int Kit_WriteDecoderInput(Kit_Decoder *dec, AVPacket *packet);
KIT_LOCAL AVPacket* Kit_ReadDecoderInput(Kit_Decoder *dec);
KIT_LOCAL int Kit_WriteDecoderOutput(Kit_Decoder *dec, void *packet);
KIT_LOCAL void* Kit_PeekDecoderOutput(Kit_Decoder *dec);
+KIT_LOCAL void* Kit_ReadDecoderOutput(Kit_Decoder *dec);
KIT_LOCAL void Kit_AdvanceDecoderOutput(Kit_Decoder *dec);
KIT_LOCAL void Kit_ForEachDecoderOutput(Kit_Decoder *dec, Kit_ForEachItemCallback foreach_cb, void *userdata);
KIT_LOCAL void Kit_ClearDecoderBuffers(Kit_Decoder *dec);
+KIT_LOCAL int Kit_LockDecoderOutput(Kit_Decoder *dec);
+KIT_LOCAL void Kit_UnlockDecoderOutput(Kit_Decoder *dec);
KIT_LOCAL int Kit_RunDecoder(Kit_Decoder *dec);
KIT_LOCAL void Kit_ClearDecoderInput(Kit_Decoder *dec);
KIT_LOCAL void Kit_ClearDecoderOutput(Kit_Decoder *dec);
diff --git a/include/kitchensink/internal/libass.h b/include/kitchensink/internal/libass.h
index 0c9730a..e615a0d 100644
--- a/include/kitchensink/internal/libass.h
+++ b/include/kitchensink/internal/libass.h
@@ -10,6 +10,8 @@
#include <stdint.h>
#include <stdarg.h>
+#include "kitchensink/kitconfig.h"
+
typedef struct ass_library ASS_Library;
typedef struct ass_renderer ASS_Renderer;
typedef struct ass_track ASS_Track;
@@ -35,23 +37,29 @@ typedef enum {
ASS_HINTING_NATIVE
} ASS_Hinting;
-ASS_Library* (*ass_library_init)(void);
-void (*ass_library_done)(ASS_Library *priv);
-void (*ass_process_codec_private)(ASS_Track *track, char *data, int size);
-void (*ass_set_message_cb)(ASS_Library *priv, void (*msg_cb)(int level, const char *fmt, va_list args, void *data), void *data);
-ASS_Renderer* (*ass_renderer_init)(ASS_Library *);
-void (*ass_renderer_done)(ASS_Renderer *priv);
-void (*ass_set_frame_size)(ASS_Renderer *priv, int w, int h);
-void (*ass_set_hinting)(ASS_Renderer *priv, ASS_Hinting ht);
-void (*ass_set_fonts)(ASS_Renderer *priv, const char *default_font, const char *default_family, int dfp, const char *config, int update);
-ASS_Image* (*ass_render_frame)(ASS_Renderer *priv, ASS_Track *track, long long now, int *detect_change);
-ASS_Track* (*ass_new_track)(ASS_Library *);
-void (*ass_free_track)(ASS_Track *track);
-void (*ass_process_data)(ASS_Track *track, char *data, int size);
-void (*ass_add_font)(ASS_Library *library, char *name, char *data, int data_size);
-
-int load_libass(void *handle);
+KIT_LOCAL ASS_Library* (*ass_library_init)(void);
+KIT_LOCAL void (*ass_library_done)(ASS_Library *priv);
+KIT_LOCAL void (*ass_process_codec_private)(ASS_Track *track, char *data, int size);
+KIT_LOCAL void (*ass_set_message_cb)(ASS_Library *priv, void (*msg_cb)(int level, const char *fmt, va_list args, void *data), void *data);
+KIT_LOCAL ASS_Renderer* (*ass_renderer_init)(ASS_Library *);
+KIT_LOCAL void (*ass_renderer_done)(ASS_Renderer *priv);
+KIT_LOCAL void (*ass_set_frame_size)(ASS_Renderer *priv, int w, int h);
+KIT_LOCAL void (*ass_set_hinting)(ASS_Renderer *priv, ASS_Hinting ht);
+KIT_LOCAL void (*ass_set_fonts)(ASS_Renderer *priv, const char *default_font, const char *default_family, int dfp, const char *config, int update);
+KIT_LOCAL ASS_Image* (*ass_render_frame)(ASS_Renderer *priv, ASS_Track *track, long long now, int *detect_change);
+KIT_LOCAL ASS_Track* (*ass_new_track)(ASS_Library *);
+KIT_LOCAL void (*ass_free_track)(ASS_Track *track);
+KIT_LOCAL void (*ass_process_data)(ASS_Track *track, char *data, int size);
+KIT_LOCAL void (*ass_process_chunk)(ASS_Track *track, char *data, int size, long long timecode, long long duration);
+KIT_LOCAL void (*ass_add_font)(ASS_Library *library, char *name, char *data, int data_size);
+
+KIT_LOCAL int load_libass(void *handle);
#endif // USE_DYNAMIC_LIBASS
+// For compatibility
+#ifndef ASS_FONTPROVIDER_AUTODETECT
+#define ASS_FONTPROVIDER_AUTODETECT 1
+#endif
+
#endif // KITLIBASS_H
diff --git a/include/kitchensink/internal/subtitle/kitatlas.h b/include/kitchensink/internal/subtitle/kitatlas.h
new file mode 100644
index 0000000..2058f65
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/kitatlas.h
@@ -0,0 +1,40 @@
+#ifndef KITATLAS_H
+#define KITATLAS_H
+
+#include <stdbool.h>
+#include <SDL2/SDL_rect.h>
+#include <SDL2/SDL_surface.h>
+#include <SDL2/SDL_render.h>
+
+#include "kitchensink/kitconfig.h"
+
+#define MAX_SHELVES 256
+
+typedef struct Kit_TextureAtlasItem {
+ int cur_shelf; //< Current shelf number in cache
+ int cur_slot; //< Current slot on shelf in cache
+ bool is_copied; //< Is copied to cache surface
+ SDL_Rect source; //< Source coordinates on cache surface
+ SDL_Rect target; //< Target coordinates on output surface
+ SDL_Surface *surface; //< Current item surface
+} Kit_TextureAtlasItem;
+
+typedef struct Kit_TextureAtlas {
+ int cur_items; //< Current items count
+ int max_items; //< Maximum items count
+ int w; //< Current atlas width
+ int h; //< Current atlas height
+ Kit_TextureAtlasItem *items; //< Cached items
+ uint16_t shelf[MAX_SHELVES][3]; //< Atlas current shelf width, height, item count
+} Kit_TextureAtlas;
+
+KIT_LOCAL Kit_TextureAtlas* Kit_CreateAtlas(int w, int h);
+KIT_LOCAL void Kit_FreeAtlas(Kit_TextureAtlas *atlas);
+KIT_LOCAL void Kit_RefreshAtlas(Kit_TextureAtlas *atlas, double current_pts);
+KIT_LOCAL void Kit_ClearAtlasContent(Kit_TextureAtlas *atlas);
+KIT_LOCAL int Kit_UpdateAtlasTexture(Kit_TextureAtlas *atlas, SDL_Texture *texture);
+KIT_LOCAL int Kit_GetAtlasItems(const Kit_TextureAtlas *atlas, SDL_Rect *sources, SDL_Rect *targets, int limit);
+KIT_LOCAL int Kit_AddAtlasItem(Kit_TextureAtlas *atlas, SDL_Surface *surface, SDL_Rect *target);
+KIT_LOCAL void Kit_FreeAtlasItem(Kit_TextureAtlas *atlas, int item_id);
+
+#endif // KITATLAS_H
diff --git a/include/kitchensink/internal/subtitle/kitsubtitle.h b/include/kitchensink/internal/subtitle/kitsubtitle.h
index a8b4cc0..25a6ecf 100644
--- a/include/kitchensink/internal/subtitle/kitsubtitle.h
+++ b/include/kitchensink/internal/subtitle/kitsubtitle.h
@@ -9,6 +9,6 @@
#include "kitchensink/internal/kitdecoder.h"
KIT_LOCAL Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat *format, int w, int h);
-KIT_LOCAL int Kit_GetSubtitleDecoderDataTexture(Kit_Decoder *dec, SDL_Texture *texture);
+KIT_LOCAL int Kit_GetSubtitleDecoderData(Kit_Decoder *dec, SDL_Texture *texture, SDL_Rect *sources, SDL_Rect *targets, int limit);
#endif // KITSUBTITLE_H
diff --git a/include/kitchensink/internal/subtitle/kitsubtitlepacket.h b/include/kitchensink/internal/subtitle/kitsubtitlepacket.h
index e3ae4e4..549c689 100644
--- a/include/kitchensink/internal/subtitle/kitsubtitlepacket.h
+++ b/include/kitchensink/internal/subtitle/kitsubtitlepacket.h
@@ -3,7 +3,15 @@
#include <SDL2/SDL_surface.h>
+#include "kitchensink/kitconfig.h"
+
+typedef enum {
+ KIT_SUBTITLE_PACKET_ADD,
+ KIT_SUBTITLE_PACKET_CLEAR
+} Kit_SubtitlePacketType;
+
typedef struct Kit_SubtitlePacket {
+ Kit_SubtitlePacketType type;
double pts_start;
double pts_end;
int x;
@@ -11,8 +19,8 @@ typedef struct Kit_SubtitlePacket {
SDL_Surface *surface;
} Kit_SubtitlePacket;
-Kit_SubtitlePacket* Kit_CreateSubtitlePacket(
- double pts_start, double pts_end, int pos_x, int pos_y, SDL_Surface *surface);
-void Kit_FreeSubtitlePacket(Kit_SubtitlePacket *packet);
+KIT_LOCAL Kit_SubtitlePacket* Kit_CreateSubtitlePacket(
+ Kit_SubtitlePacketType type, double pts_start, double pts_end, int pos_x, int pos_y, SDL_Surface *surface);
+KIT_LOCAL void Kit_FreeSubtitlePacket(Kit_SubtitlePacket *packet);
#endif // KITSUBTITLEPACKET_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubass.h b/include/kitchensink/internal/subtitle/renderers/kitsubass.h
index 39df3ac..e78e208 100644
--- a/include/kitchensink/internal/subtitle/renderers/kitsubass.h
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubass.h
@@ -5,6 +5,6 @@
#include "kitchensink/internal/kitdecoder.h"
#include "kitchensink/internal/subtitle/renderers/kitsubrenderer.h"
-KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateASSSubtitleRenderer(const Kit_Decoder *dec, int w, int h);
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateASSSubtitleRenderer(Kit_Decoder *dec, int w, int h);
#endif // KITSUBASS_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubimage.h b/include/kitchensink/internal/subtitle/renderers/kitsubimage.h
index 706f1f0..43e30bc 100644
--- a/include/kitchensink/internal/subtitle/renderers/kitsubimage.h
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubimage.h
@@ -5,6 +5,6 @@
#include "kitchensink/internal/kitdecoder.h"
#include "kitchensink/internal/subtitle/renderers/kitsubrenderer.h"
-KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateImageSubtitleRenderer(const Kit_Decoder *dec, int w, int h);
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateImageSubtitleRenderer(Kit_Decoder *dec, int w, int h);
#endif // KITSUBIMAGE_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h b/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h
index e237546..af63e1e 100644
--- a/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h
@@ -5,19 +5,24 @@
#include "kitchensink/kitformats.h"
typedef struct Kit_SubtitleRenderer Kit_SubtitleRenderer;
-//typedef struct Kit_SubtitlePacket Kit_SubtitlePacket;
+typedef struct Kit_TextureAtlas Kit_TextureAtlas;
+typedef struct Kit_Decoder Kit_Decoder;
typedef Kit_SubtitlePacket* (*ren_render_cb)(Kit_SubtitleRenderer *ren, void *src, double start_pts, double end_pts);
+typedef int (*ren_get_data_db)(Kit_SubtitleRenderer *ren, Kit_TextureAtlas *atlas, double current_pts);
typedef void (*ren_close_cb)(Kit_SubtitleRenderer *ren);
struct Kit_SubtitleRenderer {
+ Kit_Decoder *dec;
void *userdata;
ren_render_cb ren_render; ///< Subtitle rendering function callback
+ ren_get_data_db ren_get_data; ///< Subtitle data getter function callback
ren_close_cb ren_close; ///< Subtitle renderer close function callback
};
-KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateSubtitleRenderer();
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateSubtitleRenderer(Kit_Decoder *dec);
KIT_LOCAL Kit_SubtitlePacket* Kit_RunSubtitleRenderer(Kit_SubtitleRenderer *ren, void *src, double start_pts, double end_pts);
+KIT_LOCAL int Kit_GetSubtitleRendererData(Kit_SubtitleRenderer *ren, Kit_TextureAtlas *atlas, double current_pts);
KIT_LOCAL void Kit_CloseSubtitleRenderer(Kit_SubtitleRenderer *ren);
#endif // KITSUBRENDERER_H
diff --git a/include/kitchensink/internal/video/kitvideo.h b/include/kitchensink/internal/video/kitvideo.h
index 6978d9f..5a5624f 100644
--- a/include/kitchensink/internal/video/kitvideo.h
+++ b/include/kitchensink/internal/video/kitvideo.h
@@ -7,6 +7,6 @@
#include "kitchensink/internal/kitdecoder.h"
KIT_LOCAL Kit_Decoder* Kit_CreateVideoDecoder(const Kit_Source *src, Kit_VideoFormat *format);
-KIT_LOCAL int Kit_GetVideoDecoderDataTexture(Kit_Decoder *dec, SDL_Texture *texture);
+KIT_LOCAL int Kit_GetVideoDecoderData(Kit_Decoder *dec, SDL_Texture *texture);
#endif // KITVIDEO_H
diff --git a/include/kitchensink/kitplayer.h b/include/kitchensink/kitplayer.h
index 4c80e9a..e9f7dbf 100644
--- a/include/kitchensink/kitplayer.h
+++ b/include/kitchensink/kitplayer.h
@@ -56,8 +56,8 @@ KIT_API Kit_Player* Kit_CreatePlayer(const Kit_Source *src);
KIT_API void Kit_ClosePlayer(Kit_Player *player);
KIT_API int Kit_UpdatePlayer(Kit_Player *player);
-KIT_API int Kit_GetVideoDataTexture(Kit_Player *player, SDL_Texture *texture);
-KIT_API int Kit_GetSubtitleDataTexture(Kit_Player *player, SDL_Texture *texture);
+KIT_API int Kit_GetVideoData(Kit_Player *player, SDL_Texture *texture);
+KIT_API int Kit_GetSubtitleData(Kit_Player *player, SDL_Texture *texture, SDL_Rect *sources, SDL_Rect *targets, int limit);
KIT_API int Kit_GetAudioData(Kit_Player *player, unsigned char *buffer, int length);
KIT_API void Kit_GetPlayerInfo(const Kit_Player *player, Kit_PlayerInfo *info);