@@ -43,23 +43,6 @@ int64_t secondsToClosestPts(double seconds, const AVRational& timeBase) {
4343 return static_cast <int64_t >(std::round (seconds * timeBase.den ));
4444}
4545
46- std::vector<std::string> splitStringWithDelimiters (
47- const std::string& str,
48- const std::string& delims) {
49- std::vector<std::string> result;
50- if (str.empty ()) {
51- return result;
52- }
53-
54- std::string::size_type start = 0 , end = 0 ;
55- while ((end = str.find_first_of (delims, start)) != std::string::npos) {
56- result.push_back (str.substr (start, end - start));
57- start = end + 1 ;
58- }
59- result.push_back (str.substr (start));
60- return result;
61- }
62-
6346} // namespace
6447
6548// --------------------------------------------------------------------------
@@ -395,57 +378,6 @@ torch::Tensor VideoDecoder::getKeyFrameIndices() {
395378// ADDING STREAMS API
396379// --------------------------------------------------------------------------
397380
398- VideoDecoder::VideoStreamOptions::VideoStreamOptions (
399- const std::string& optionsString) {
400- std::vector<std::string> tokens =
401- splitStringWithDelimiters (optionsString, " ," );
402- for (auto token : tokens) {
403- std::vector<std::string> pairs = splitStringWithDelimiters (token, " =" );
404- if (pairs.size () != 2 ) {
405- throw std::runtime_error (
406- " Invalid option: " + token +
407- " . Options must be in the form 'option=value'." );
408- }
409- std::string key = pairs[0 ];
410- std::string value = pairs[1 ];
411- if (key == " ffmpeg_thread_count" ) {
412- ffmpegThreadCount = std::stoi (value);
413- if (ffmpegThreadCount < 0 ) {
414- throw std::runtime_error (
415- " Invalid ffmpeg_thread_count=" + value +
416- " . ffmpeg_thread_count must be >= 0." );
417- }
418- } else if (key == " dimension_order" ) {
419- if (value != " NHWC" && value != " NCHW" ) {
420- throw std::runtime_error (
421- " Invalid dimension_order=" + value +
422- " . dimensionOrder must be either NHWC or NCHW." );
423- }
424- dimensionOrder = value;
425- } else if (key == " width" ) {
426- width = std::stoi (value);
427- } else if (key == " height" ) {
428- height = std::stoi (value);
429- } else if (key == " color_conversion_library" ) {
430- if (value == " filtergraph" ) {
431- colorConversionLibrary = ColorConversionLibrary::FILTERGRAPH;
432- } else if (value == " swscale" ) {
433- colorConversionLibrary = ColorConversionLibrary::SWSCALE;
434- } else {
435- throw std::runtime_error (
436- " Invalid color_conversion_library=" + value +
437- " . color_conversion_library must be either "
438- " filtergraph or swscale." );
439- }
440- } else {
441- throw std::runtime_error (
442- " Invalid option: " + key +
443- " . Valid options are: "
444- " ffmpeg_thread_count=<int>,dimension_order=<string>" );
445- }
446- }
447- }
448-
449381void VideoDecoder::addStream (
450382 int streamIndex,
451383 AVMediaType mediaType,
0 commit comments