vlc_module_begin()
set_description(N_("Image demuxer"))
+ set_shortname(N_("Image"))
set_category(CAT_INPUT)
set_subcategory(SUBCAT_INPUT_DEMUX)
- add_integer("image-id", -1, NULL, ID_TEXT, ID_LONGTEXT, true)
+ add_integer("image-id", -1, ID_TEXT, ID_LONGTEXT, true)
change_safe()
- add_integer("image-group", 0, NULL, GROUP_TEXT, GROUP_LONGTEXT, true)
+ add_integer("image-group", 0, GROUP_TEXT, GROUP_LONGTEXT, true)
change_safe()
- add_bool("image-decode", true, NULL, DECODE_TEXT, DECODE_LONGTEXT, true)
+ add_bool("image-decode", true, DECODE_TEXT, DECODE_LONGTEXT, true)
change_safe()
- add_string("image-chroma", "", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true)
+ add_string("image-chroma", "", CHROMA_TEXT, CHROMA_LONGTEXT, true)
change_safe()
- add_float("image-duration", 10, NULL, DURATION_TEXT, DURATION_LONGTEXT, true)
+ add_float("image-duration", 10, DURATION_TEXT, DURATION_LONGTEXT, true)
change_safe()
- add_string("image-fps", "10/1", NULL, FPS_TEXT, FPS_LONGTEXT, true)
+ add_string("image-fps", "10/1", FPS_TEXT, FPS_LONGTEXT, true)
change_safe()
- add_bool("image-realtime", false, NULL, RT_TEXT, RT_LONGTEXT, true)
+ add_bool("image-realtime", false, RT_TEXT, RT_LONGTEXT, true)
change_safe()
set_capability("demux", 10)
set_callbacks(Open, Close)
bool is_realtime;
mtime_t pts_origin;
mtime_t pts_next;
- date_t pts;
+ date_t pts;
};
static block_t *Load(demux_t *demux)
{
demux_sys_t *sys = demux->p_sys;
- switch (query) {
+ switch (query) {
case DEMUX_GET_POSITION: {
double *position = va_arg(args, double *);
if (sys->duration > 0)
case DEMUX_GET_META:
case DEMUX_HAS_UNSUPPORTED_META:
case DEMUX_GET_ATTACHMENTS:
- default:
- return VLC_EGENERIC;
- }
+ default:
+ return VLC_EGENERIC;
+ }
}
static bool IsBmp(stream_t *s)
return true;
}
+static bool IsTarga(stream_t *s)
+{
+ /* The header is not enough to ensure proper detection, we need
+ * to have a look at the footer. But doing so can be slow. So
+ * try to avoid it when possible */
+ const uint8_t *header;
+ if (stream_Peek(s, &header, 18) < 18) /* Targa fixed header */
+ return false;
+ if (header[1] > 1) /* Color Map Type */
+ return false;
+ if ((header[1] != 0 || header[3 + 4] != 0) &&
+ header[3 + 4] != 8 &&
+ header[3 + 4] != 15 && header[3 + 4] != 16 &&
+ header[3 + 4] != 24 && header[3 + 4] != 32)
+ return false;
+ if ((header[2] > 3 && header[2] < 9) || header[2] > 11) /* Image Type */
+ return false;
+ if (GetWLE(&header[8 + 4]) <= 0 || /* Width */
+ GetWLE(&header[8 + 6]) <= 0) /* Height */
+ return false;
+ if (header[8 + 8] != 8 &&
+ header[8 + 8] != 15 && header[8 + 8] != 16 &&
+ header[8 + 8] != 24 && header[8 + 8] != 32)
+ return false;
+ if (header[8 + 9] & 0xc0) /* Reserved bits */
+ return false;
+
+ const int64_t size = stream_Size(s);
+ if (size <= 18 + 26)
+ return false;
+ bool can_seek;
+ if (stream_Control(s, STREAM_CAN_SEEK, &can_seek) || !can_seek)
+ return false;
+
+ const int64_t position = stream_Tell(s);
+ if (stream_Seek(s, size - 26))
+ return false;
+
+ const uint8_t *footer;
+ bool is_targa = stream_Peek(s, &footer, 26) >= 26 &&
+ !memcmp(&footer[8], "TRUEVISION-XFILE.\x00", 18);
+ stream_Seek(s, position);
+ return is_targa;
+}
+
typedef struct {
vlc_fourcc_t codec;
int marker_size;
{ .codec = VLC_CODEC_JPEG,
.detect = IsSpiff,
},
+ { .codec = VLC_CODEC_TARGA,
+ .detect = IsTarga,
+ },
{ .codec = 0 }
};