File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -794,9 +794,30 @@ int main(int argc, char **argv)
794794 usage ();
795795 exit (1 );
796796 }
797- inFile = argv_utf8 [optind ];
798- outFile = argv_utf8 [optind + 1 ];
799-
797+ inFile = argv_utf8 [optind ];
798+ /*Assumes filename if output is not provided*/
799+ if (argc_utf8 - optind == 1 ) {
800+ outFile = realloc (NULL , strlen (inFile ) * sizeof (char ));
801+ strcpy (outFile , inFile );
802+ int foundExt = 0 ;
803+ for (size_t i = strlen (inFile ); i != 0 ; i -- ) {
804+ outFile [i ] = '\0' ;
805+ if (inFile [i ] == '\\' || inFile [i ] == '/' ) {
806+ break ;
807+ }
808+ else if (inFile [i ] == '.' ) {
809+ foundExt = 1 ;
810+ break ;
811+ }
812+ }
813+ if (!foundExt ) {
814+ strcpy (outFile , inFile );
815+ }
816+ strcat (outFile , ".opus" );
817+ }
818+ else {
819+ outFile = argv_utf8 [optind + 1 ];
820+ }
800821 if (cline_size > 0 ) {
801822 ret = ope_comments_add (inopt .comments , "ENCODER_OPTIONS" , ENCODER_string );
802823 if (ret != OPE_OK ) {
You can’t perform that action at this time.
0 commit comments