1515 * License along with mpv. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
18+ #include <limits.h>
1819#include <math.h>
1920
2021#include <subrandr/subrandr.h>
2122
2223#include "common/common.h"
2324#include "demux/packet.h"
2425#include "misc/bstr.h"
26+ #include "options/m_config.h"
27+ #include "options/m_option.h"
2528#include "stream/stream.h"
2629#include "demux.h"
2730
31+ #define OPT_BASE_STRUCT struct demux_textsub_opts
32+ struct demux_textsub_opts {
33+ int probesize ;
34+ };
35+
36+ const struct m_sub_options demux_textsub_conf = {
37+ .opts = (const m_option_t []) {
38+ {"demuxer-textsub-probesize" , OPT_INT (probesize ), M_RANGE (32 , INT_MAX )},
39+ {0 }
40+ },
41+ .size = sizeof (struct demux_textsub_opts ),
42+ .defaults = & (const struct demux_textsub_opts ){
43+ .probesize = 128 ,
44+ },
45+ .change_flags = UPDATE_DEMUXER ,
46+ };
47+
2848struct format_codec_info {
2949 const char * codec ;
3050 const char * codec_desc ;
@@ -48,8 +68,6 @@ static const struct textsub_ext TEXT_FORMAT_EXTS[] = {
4868 {NULL }
4969};
5070
51- static const int SUBRANDR_PROBE_SIZE = 128 ;
52-
5371struct demux_textsub_priv {
5472 bstr content ;
5573 bool exhausted ;
@@ -60,13 +78,15 @@ static int demux_open_textsub(struct demuxer *demuxer, enum demux_check check)
6078 bstr filename = bstr0 (demuxer -> filename );
6179 struct format_codec_info codec_info = {NULL , NULL };
6280
81+ struct demux_textsub_opts * opts = mp_get_config_group (demuxer , demuxer -> global , & demux_textsub_conf );
82+
6383 for (const struct textsub_ext * ext = TEXT_FORMAT_EXTS ; ext -> ext ; ++ ext ) {
6484 if (bstr_endswith0 (filename , ext -> ext ))
6585 codec_info = ext -> codec_info ;
6686 }
6787
6888 if (!codec_info .codec ) {
69- int probe_size = stream_peek (demuxer -> stream , SUBRANDR_PROBE_SIZE );
89+ int probe_size = stream_peek (demuxer -> stream , opts -> probesize );
7090 uint8_t * probe_buffer = demuxer -> stream -> buffer ;
7191
7292 sbr_subtitle_format fmt = sbr_probe_text ((const char * )probe_buffer , (size_t )probe_size );
0 commit comments