[MPlayer-dev-eng] patch for PNG output
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Oct 3 13:41:22 CEST 2007
Hello,
On Tue, Oct 02, 2007 at 11:32:34AM -0400, Vincent Chapdelaine-Couture wrote:
> We propose a simple change to the PNG output module to create
> concatenated PNG data in a single file instead of multiple files.
>
> Currently, there is no way to extract a stream of "lossless high
> quality" images from mplayer without saving the images to disk. All the
> output modules generating images are either lossy (jpeg, gif89a) or saved
> in single files (png, pnm, tga). Having a stream of PNG is ideal for
> automatic processing of the images.
Why not mencoder -ovc lavc -lavcopts vcodec=png -of rawvideo ?
> @@ -34,6 +34,8 @@
>
> int z_compression = Z_NO_COMPRESSION;
> static int framenum = 0;
> +char *single_file_name=NULL; // if not null, then output there
> +FILE *single_file=NULL; // NULL -> regulier. Not null: send all images there
Must be static, and comments should be doxygen-compatible. And regulier
may be French but certainly not English.
> @@ -97,12 +99,16 @@
> return png;
> }
>
> - png.fp = fopen (fname, "wb");
> - if (png.fp == NULL) {
> - mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));
> - png.status = ERROR;
> - return png;
> - }
> + if( single_file ) {
> + png.fp = single_file;
> + }else{
> + png.fp = fopen (fname, "wb");
> + if (png.fp == NULL) {
> + mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));
> + png.status = ERROR;
> + return png;
> + }
> + }
Cosmetics. Indentation must be changed in a separate patch.
And I don't think it would hurt just to do
png.fp = single_file ? single_file : fopen (fname, "wb");
> @@ -219,8 +232,19 @@
> return 1;
> }
>
> +static int test_single_file_name(const char **name) {
> + single_file=fopen(*name,"wb");
> + if( single_file==NULL ) {
> + fprintf(stderr,"UNABLE TO OPEN %s for writing\n",*name);
> + return 0; // not supported
> + }
> + return 1;
> +}
> +
> +
> static opt_t subopts[] = {
> {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine},
> + {"single", OPT_ARG_MSTRZ, &single_file_name, (opt_test_f)test_single_file_name},
Wrong, test functions must be idempotent, they may be called more than
once (esp. since -vo png:single=a:single=b:single=c is valid even though
it is rather pointless to specify it more than once).
Greetings,
Reimar Döffinger
More information about the MPlayer-dev-eng
mailing list