[x264-devel] Re: allow y4m input through stdin

Måns Rullgård mans at mansr.com
Tue Mar 13 12:45:29 CET 2007


Limin Wang said:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> * Sam Mortimer <sam.mortimer at gmail.com> [2007-03-13 09:43:08 +0000]:
>
>> >> I don't like magic names, however unlikely they are.
>>
>> Nor do I.  I wrote the attached patch a few weeks ago.  Key points:
>>
>> *) allows input and output file formats to be set using --input-format
>> and --output-format.
>> *) preserves existing filename based format selection. ie is backwards
>> compatible.
>> *) the input and output driver functions must be set after all option
>> parsing is complete so all code (in Parse()) which relates to this has
>> been moved to immediately below the option parsing block.
>>
>> Is this of any use?   I'm happy to make changes if it needs a few
>> pokes and prods.
>>
>> Regards,
>> -Sam.
>
>> --- x264.c.orig	2007-02-19 21:49:55.000000000 +0000
>> +++ x264.c	2007-03-13 09:21:22.000000000 +0000
>> @@ -142,7 +142,8 @@
>> -    /* Get the file name */
>> +    /* Determine output format and filename and then open */
>> +    if( !out_fname )
>> +    {
>> +        fprintf( stderr, "x264 [error]: No output file. Run x264 --help for a
>> list of options.\n");
>> +        return -1;
>> +    }
>> +    out_ext=out_fname + strlen(out_fname) - 4;
>> +    if( out_ext < out_fname )
>> +        out_ext = out_fname; /* filename is < 4 chars long */
>
> You're assuming the file extension is 4 chars. General way to get file
> extension:
>        out_ext = strchr(out_fname, '.');
>        if(out_ext) {
>           fprintf( stderr, "no output file extension, use default output \n");
>        }

You probably want strrchr(), in case the filename contains several dots.

BTW, I dislike the use of the word "extension" to denote what is properly
called "suffix".

-- 
Måns Rullgård
mans at mansr.com

-- 
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html



More information about the x264-devel mailing list