av_free(buf1); av_free(buf2);
if ( !err ) { avpicture_fill(&picture2, ci->buf2, PIX_FMT_RGB24, out_width, out_height); ptr = picture2.data[ 0 ]; for ( i = 0; !err && i < out_height; i ++ ) { err = !fread( ptr, out_width * 3, 1, in ); ptr += picture2.linesize[ 0 ]; } } }   if ( !err ) {  if (img_convert(picture, pix_fmt, &picture2, PIX_FMT_RGB24, width, height) < 0) { } }
void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts){	int err = 0;    ContextInfo *ci = (ContextInfo *) ctx;    char *buf1 = 0;    char *buf2 = 0;    AVPicture picture1;    AVPicture picture2;    AVPicture *pict = picture;	int out_width;	int out_height;	int i;	uint8_t *ptr = NULL;	FILE *in = rwpipe_reader( ci->rw );	FILE *out = rwpipe_writer( ci->rw );	/* Convert to RGB24 if necessary */    if (pix_fmt != PIX_FMT_RGB24) {        int size;        size = avpicture_get_size(PIX_FMT_RGB24, width, height);        buf1 = av_malloc(size);        avpicture_fill(&picture1, buf1, PIX_FMT_RGB24, width, height);        if (img_convert(&picture1, PIX_FMT_RGB24,                         picture, pix_fmt, width, height) < 0) {			err = 1;        }        pict = &picture1;    }	/* Write out the PPM */	if ( !err )	{		ptr = pict->data[ 0 ];		fprintf( out, "P6\n%d %d\n255\n", width, height );		for ( i = 0; !err && i < height; i ++ )		{			err = !fwrite( ptr, width * 3, 1, out );			ptr += pict->linesize[ 0 ];		}		if ( !err )			err = fflush( out );	}	/* Read the PPM returned. */	if ( !err && !rwpipe_read_ppm_header( ci->rw, &out_width, &out_height ) )	{        int size = avpicture_get_size(PIX_FMT_RGB24, out_width, out_height);        buf2 = av_malloc(size);        avpicture_fill(&picture2, buf2, PIX_FMT_RGB24, out_width, out_height);		ptr = picture2.data[ 0 ];		for ( i = 0; !err && i < out_height; i ++ )		{			err = !fread( ptr, out_width * 3, 1, in );			ptr += picture2.linesize[ 0 ];		}	}	/* Convert the returned PPM back to the input format */	if ( !err )	{        if (img_convert(picture, pix_fmt, &picture2, PIX_FMT_RGB24, width, height) < 0) {        }	}    av_free(buf1);    av_free(buf2);}