[MPlayer-dev-eng] [PATCH] Interlaced vo_png support
tracy at amphibious.org
tracy at amphibious.org
Tue May 2 01:12:15 CEST 2006
Here's a short patch to libvo/vo_png.c to add writing out interlaced fields as
individual PNGs instead of merged progressive frames.
Usage:
mplayer -vo png:interlaced foo.mpg
This is my first contribution to mplayer so please let me know if this
is not the correct procedure. This patch is against current CVS.
-------------- next part --------------
Index: libvo/vo_png.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_png.c,v
retrieving revision 1.29
diff -u -p -r1.29 vo_png.c
--- libvo/vo_png.c 24 Apr 2006 04:23:53 -0000 1.29
+++ libvo/vo_png.c 1 May 2006 22:57:59 -0000
@@ -32,7 +32,10 @@ static vo_info_t info =
LIBVO_EXTERN (png)
+static uint32_t write_field(mp_image_t* mpi, uint32_t starting_line, uint32_t line_increment);
+
int z_compression = Z_NO_COMPRESSION;
+int interlaced = 0;
static int framenum = 0;
struct pngdata {
@@ -149,8 +152,17 @@ static uint8_t destroy_png(struct pngdat
}
static uint32_t draw_image(mp_image_t* mpi){
+ if(interlaced == 0){
+ write_field(mpi, 0, 1);
+ } else {
+ write_field(mpi, 0, 2);
+ write_field(mpi, 1, 2);
+ }
+}
+
+static uint32_t write_field(mp_image_t* mpi, uint32_t starting_line, uint32_t line_increment){
char buf[100];
- int k;
+ int j, k;
struct pngdata png;
png_byte *row_pointers[mpi->h];
@@ -159,7 +171,7 @@ static uint32_t draw_image(mp_image_t* m
snprintf (buf, 100, "%08d.png", ++framenum);
- png = create_png(buf, mpi->w, mpi->h, mpi->flags&MP_IMGFLAG_SWAPPED);
+ png = create_png(buf, mpi->w, mpi->h/line_increment, mpi->flags&MP_IMGFLAG_SWAPPED);
if(png.status){
mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng);
@@ -168,8 +180,9 @@ static uint32_t draw_image(mp_image_t* m
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "PNG Creating Row Pointers\n"); }
- for ( k = 0; k < mpi->h; k++ )
- row_pointers[k] = mpi->planes[0]+mpi->stride[0]*k;
+
+ for ( j = 0, k = starting_line; k < mpi->h; k += line_increment, j++ )
+ row_pointers[j] = mpi->planes[0]+mpi->stride[0]*k;
//png_write_flush(png.png_ptr);
//png_set_flush(png.png_ptr, nrows);
@@ -220,13 +233,15 @@ static int int_zero_to_nine(int *sh)
}
static opt_t subopts[] = {
- {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine},
+ {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine},
+ {"interlaced", OPT_ARG_BOOL, &interlaced, NULL},
{NULL}
};
static int preinit(const char *arg)
{
z_compression = 0;
+ interlaced = 0;
if (subopt_parse(arg, subopts) != 0) {
return -1;
}
More information about the MPlayer-dev-eng
mailing list