summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-07-11 01:59:21 +0200
committerNiklas Haas <git@haasn.xyz>2017-07-27 23:51:05 +0200
commit345bb193fe75ddbf2f21bd295869276b6fa87189 (patch)
tree319f31b8bb33be3532846916da32f93dd4b8152a /stream
parentf1af6e53f0b043cac2d3f1024d7d91785072f237 (diff)
downloadmpv-345bb193fe75ddbf2f21bd295869276b6fa87189.tar.bz2
mpv-345bb193fe75ddbf2f21bd295869276b6fa87189.tar.xz
vo_opengl: support loading custom user textures
Parsing the texture data as raw strings makes the textures the most portable and self-contained. In order to facilitate different types of shaders, the parse_user_shader interaction has been changed to instead have it loop through blocks and call the passed functions for each valid block parsed. This is more modular and also cleaner, with better code separation. Closes #4586.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_memory.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/stream/stream_memory.c b/stream/stream_memory.c
index b23ad82c16..e0d01ff2d8 100644
--- a/stream/stream_memory.c
+++ b/stream/stream_memory.c
@@ -55,32 +55,6 @@ static int control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int h_to_i(unsigned char c)
-{
- if (c >= '0' && c <= '9')
- return c - '0';
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- return -1;
-}
-
-static bool bstr_to_hex_inplace(bstr *h)
-{
- if (h->len % 2)
- return false;
- for (int n = 0; n < h->len / 2; n++) {
- int hi = h_to_i(h->start[n * 2 + 0]);
- int lo = h_to_i(h->start[n * 2 + 1]);
- if (hi < 0 || lo < 0)
- return false;
- h->start[n] = (hi << 4) | lo;
- }
- h->len /= 2;
- return true;
-}
-
static int open_f(stream_t *stream)
{
stream->fill_buffer = fill_buffer;
@@ -100,7 +74,7 @@ static int open_f(stream_t *stream)
bstr_eatstart0(&data, "memory://");
stream_control(stream, STREAM_CTRL_SET_CONTENTS, &data);
- if (use_hex && !bstr_to_hex_inplace(&p->data)) {
+ if (use_hex && !bstr_decode_hex(stream, p->data, &p->data)) {
MP_FATAL(stream, "Invalid data.\n");
return STREAM_ERROR;
}