Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-20 Thread Dan Dennedy
2012/2/17 Maksym Veremeyenko ve...@m1stereo.tv:
 16.02.12 18:56, Dan Dennedy написав(ла):

 2012/2/16 Maksym Veremeyenkove...@m1stereo.tv:

 02.02.12 19:03, Maksym Veremeyenko написав(ла):


 Hi,


 i am trying to decrease cpu usage, so i would like to use
 PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
 alpha channel) but has no luck..

 video with such pixel format in *nut* container has detected by ffmpeg
 properly, but mlt did not use it alpha channel.

 i can provide a sample if required...


 alpha been ignored for PIX_FMT_YUVA420P and PIX_FMT_YUVA444P pixel
 format.
 moreover current implementation of libswscale drop alpha channel if
 destination format has no alpha and not planar (even if buffer specified)

 attached patch extract alpha plane during image decoding. it works almost
 fine except moments when image fetched from cache (even if *noimagecache*
 specified). another problem is artifact that appear if last frame in
 movie
 is not transparent but producer specifies *out* out of animation.

 another attempt to fix this was to fix mlt_frame_clone (patch attached)
 but
 it has no luck too...


 OK, thank you for the start of this effort. I will look at it this
 weekend.


 attached updated version that works with cache.

 second patch is optional but could be usefull if frame with alpha been
 cloned.

These look great, but I had to fix some minor formatting problems. We
tend to prefer C++ style comments in .c files (but not headers). Also,
some spacing around parenthesis. Sometimes I am OK to make these fixes
myself, which I have done here in my local repo. Now I just need to
figure out why this does not work:

melt -profile atsc_1080i_50 noise: -track
~/Videos/tests/now-main_aut_2011_fullHD.nut -transition composite

-- 
+-DRD-+

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel


Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-20 Thread Dan Dennedy
On Mon, Feb 20, 2012 at 12:11 PM, Dan Dennedy d...@dennedy.org wrote:
 2012/2/17 Maksym Veremeyenko ve...@m1stereo.tv:
 16.02.12 18:56, Dan Dennedy написав(ла):

 2012/2/16 Maksym Veremeyenkove...@m1stereo.tv:

 02.02.12 19:03, Maksym Veremeyenko написав(ла):


 Hi,


 i am trying to decrease cpu usage, so i would like to use
 PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
 alpha channel) but has no luck..

 video with such pixel format in *nut* container has detected by ffmpeg
 properly, but mlt did not use it alpha channel.

 i can provide a sample if required...


 alpha been ignored for PIX_FMT_YUVA420P and PIX_FMT_YUVA444P pixel
 format.
 moreover current implementation of libswscale drop alpha channel if
 destination format has no alpha and not planar (even if buffer specified)

 attached patch extract alpha plane during image decoding. it works almost
 fine except moments when image fetched from cache (even if *noimagecache*
 specified). another problem is artifact that appear if last frame in
 movie
 is not transparent but producer specifies *out* out of animation.

 another attempt to fix this was to fix mlt_frame_clone (patch attached)
 but
 it has no luck too...


 OK, thank you for the start of this effort. I will look at it this
 weekend.


 attached updated version that works with cache.

 second patch is optional but could be usefull if frame with alpha been
 cloned.

 These look great, but I had to fix some minor formatting problems. We
 tend to prefer C++ style comments in .c files (but not headers). Also,
 some spacing around parenthesis. Sometimes I am OK to make these fixes
 myself, which I have done here in my local repo. Now I just need to
 figure out why this does not work:

 melt -profile atsc_1080i_50 noise: -track
 ~/Videos/tests/now-main_aut_2011_fullHD.nut -transition composite

Your nut file had an opaque alpha channel. I recreated it from the
rgba avi file, and it works, so I pushed it.

+-DRD-+

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel


Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-17 Thread Maksym Veremeyenko

16.02.12 18:56, Dan Dennedy написав(ла):

2012/2/16 Maksym Veremeyenkove...@m1stereo.tv:

02.02.12 19:03, Maksym Veremeyenko написав(ла):


Hi,


i am trying to decrease cpu usage, so i would like to use
PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
alpha channel) but has no luck..

video with such pixel format in *nut* container has detected by ffmpeg
properly, but mlt did not use it alpha channel.

i can provide a sample if required...



alpha been ignored for PIX_FMT_YUVA420P and PIX_FMT_YUVA444P pixel format.
moreover current implementation of libswscale drop alpha channel if
destination format has no alpha and not planar (even if buffer specified)

attached patch extract alpha plane during image decoding. it works almost
fine except moments when image fetched from cache (even if *noimagecache*
specified). another problem is artifact that appear if last frame in movie
is not transparent but producer specifies *out* out of animation.

another attempt to fix this was to fix mlt_frame_clone (patch attached) but
it has no luck too...


OK, thank you for the start of this effort. I will look at it this weekend.



attached updated version that works with cache.

second patch is optional but could be usefull if frame with alpha been 
cloned.


--

Maksym Veremeyenko
From d13a842181a9bc55c40b84af9c385ddbd0965987 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Fri, 17 Feb 2012 12:01:40 +0200
Subject: [PATCH] alpha extracting from planar formats

---
 src/modules/avformat/producer_avformat.c |   59 ++
 1 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index 87b87af..f58e287 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -115,6 +115,7 @@ struct producer_avformat_s
 	unsigned int invalid_pts_counter;
 	double resample_factor;
 	mlt_cache image_cache;
+	mlt_cache alpha_cache;
 	int colorspace;
 	pthread_mutex_t video_mutex;
 	pthread_mutex_t audio_mutex;
@@ -1243,7 +1244,7 @@ static mlt_image_format pick_format( enum PixelFormat pix_fmt )
 }
 
 static void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
-	mlt_image_format *format, int width, int height, int colorspace )
+	mlt_image_format *format, int width, int height, int colorspace, uint8_t **alpha )
 {
 #ifdef SWSCALE
 	int full_range = -1;
@@ -1256,6 +1257,21 @@ static void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
 	flags |= SWS_CPU_CAPS_MMX2;
 #endif
 
+	/* extract alpha from planar formats */
+	if ( ( pix_fmt == PIX_FMT_YUVA420P || pix_fmt == PIX_FMT_YUVA444P ) 
+		*format != mlt_image_rgb24a  *format != mlt_image_opengl 
+		frame-data[3]  frame-linesize[3] )
+	{
+		int i;
+		uint8_t *src, *dst;
+
+		dst = *alpha = mlt_pool_alloc( width * height );
+		src = frame-data[3];
+
+		for(i = 0; i  height; dst += width, src += frame-linesize[3], i++)
+			memcpy(dst, src, FFMIN(width, frame-linesize[3]));
+	}
+
 	if ( *format == mlt_image_yuv420p )
 	{
 		struct SwsContext *context = sws_getContext( width, height, pix_fmt,
@@ -1388,9 +1404,14 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 	// Get codec context
 	AVCodecContext *codec_context = stream-codec;
 
+	uint8_t *alpha = NULL;
+
 	// Get the image cache
 	if ( ! self-image_cache  ! mlt_properties_get_int( properties, noimagecache ) )
+	{
 		self-image_cache = mlt_cache_init();
+		self-alpha_cache = mlt_cache_init();
+	}
 	if ( self-image_cache )
 	{
 		mlt_cache_item item = mlt_cache_get( self-image_cache, (void*) position );
@@ -1422,6 +1443,16 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 			}
 			self-got_picture = 1;
 
+			/* check for alpha */
+			item = mlt_cache_get( self-alpha_cache, (void*) position );
+			original = mlt_cache_item_data( item, size );
+			if( original )
+			{
+alpha = mlt_pool_alloc( size );
+memcpy( alpha, original, size );
+mlt_cache_item_close( item );
+			}
+
 			goto exit_get_image;
 		}
 	}
@@ -1464,7 +1495,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 	context = self-video_format;
 	stream = context-streams[ self-video_index ];
 	codec_context = stream-codec;
-
 	if ( *format == mlt_image_none ||
 			codec_context-pix_fmt == PIX_FMT_ARGB ||
 			codec_context-pix_fmt == PIX_FMT_RGBA ||
@@ -1495,12 +1525,12 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 picture.linesize[1] = codec_context-width / 2;
 picture.linesize[2] = codec_context-width / 2;
 convert_image( (AVFrame*) picture, *buffer,
-	PIX_FMT_YUV420P, format, *width, *height, self-colorspace );
+	PIX_FMT_YUV420P, format, *width, *height, self-colorspace, alpha );
 			}
 			else
 #endif
 			convert_image( self-av_frame, *buffer, 

Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-16 Thread Maksym Veremeyenko

02.02.12 19:03, Maksym Veremeyenko написав(ла):

Hi,

i am trying to decrease cpu usage, so i would like to use
PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
alpha channel) but has no luck..

video with such pixel format in *nut* container has detected by ffmpeg
properly, but mlt did not use it alpha channel.

i can provide a sample if required...



alpha been ignored for PIX_FMT_YUVA420P and PIX_FMT_YUVA444P pixel 
format. moreover current implementation of libswscale drop alpha channel 
if destination format has no alpha and not planar (even if buffer specified)


attached patch extract alpha plane during image decoding. it works 
almost fine except moments when image fetched from cache (even if 
*noimagecache* specified). another problem is artifact that appear if 
last frame in movie is not transparent but producer specifies *out* out 
of animation.


another attempt to fix this was to fix mlt_frame_clone (patch attached) 
but it has no luck too...


--

Maksym Veremeyenko

From 7efb254ffa82b34d289cf7a0bb574be061541259 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Thu, 16 Feb 2012 17:44:40 +0200
Subject: [PATCH 1/2] alpha extracting from planar formats

---
 src/modules/avformat/producer_avformat.c |   36 +++--
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index 87b87af..8938fa4 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -1243,7 +1243,7 @@ static mlt_image_format pick_format( enum PixelFormat pix_fmt )
 }
 
 static void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
-	mlt_image_format *format, int width, int height, int colorspace )
+	mlt_image_format *format, int width, int height, int colorspace, uint8_t **alpha )
 {
 #ifdef SWSCALE
 	int full_range = -1;
@@ -1256,6 +1256,21 @@ static void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
 	flags |= SWS_CPU_CAPS_MMX2;
 #endif
 
+	/* extract alpha from planar formats */
+	if ( ( pix_fmt == PIX_FMT_YUVA420P || pix_fmt == PIX_FMT_YUVA444P ) 
+		*format != mlt_image_rgb24a  *format != mlt_image_opengl 
+		frame-data[3]  frame-linesize[3] )
+	{
+		int i;
+		uint8_t *src, *dst;
+
+		dst = *alpha = mlt_pool_alloc( width * height );
+		src = frame-data[3];
+
+		for(i = 0; i  height; dst += width, src += frame-linesize[3], i++)
+			memcpy(dst, src, FFMIN(width, frame-linesize[3]));
+	}
+
 	if ( *format == mlt_image_yuv420p )
 	{
 		struct SwsContext *context = sws_getContext( width, height, pix_fmt,
@@ -1388,6 +1403,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 	// Get codec context
 	AVCodecContext *codec_context = stream-codec;
 
+	uint8_t *alpha = NULL;
+
 	// Get the image cache
 	if ( ! self-image_cache  ! mlt_properties_get_int( properties, noimagecache ) )
 		self-image_cache = mlt_cache_init();
@@ -1464,7 +1481,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 	context = self-video_format;
 	stream = context-streams[ self-video_index ];
 	codec_context = stream-codec;
-
 	if ( *format == mlt_image_none ||
 			codec_context-pix_fmt == PIX_FMT_ARGB ||
 			codec_context-pix_fmt == PIX_FMT_RGBA ||
@@ -1495,12 +1511,12 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 picture.linesize[1] = codec_context-width / 2;
 picture.linesize[2] = codec_context-width / 2;
 convert_image( (AVFrame*) picture, *buffer,
-	PIX_FMT_YUV420P, format, *width, *height, self-colorspace );
+	PIX_FMT_YUV420P, format, *width, *height, self-colorspace, alpha );
 			}
 			else
 #endif
 			convert_image( self-av_frame, *buffer, codec_context-pix_fmt,
-format, *width, *height, self-colorspace );
+format, *width, *height, self-colorspace, alpha );
 		}
 		else
 			mlt_frame_get_image( frame, buffer, format, width, height, writable );
@@ -1690,7 +1706,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 			if ( status == VDP_STATUS_OK )
 			{
 convert_image( self-av_frame, *buffer, PIX_FMT_YUV420P,
-	format, *width, *height, self-colorspace );
+	format, *width, *height, self-colorspace, alpha );
 			}
 			else
 			{
@@ -1707,7 +1723,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 	else
 #endif
 	convert_image( self-av_frame, *buffer, codec_context-pix_fmt,
-		format, *width, *height, self-colorspace );
+		format, *width, *height, self-colorspace, alpha );
 	self-top_field_first |= self-av_frame-top_field_first;
 	self-current_position = int_position;
 	self-got_picture = 1;
@@ -1749,12 +1765,12 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 picture.linesize[1] = 

Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-16 Thread Dan Dennedy
2012/2/16 Maksym Veremeyenko ve...@m1stereo.tv:
 02.02.12 19:03, Maksym Veremeyenko написав(ла):

 Hi,


 i am trying to decrease cpu usage, so i would like to use
 PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
 alpha channel) but has no luck..

 video with such pixel format in *nut* container has detected by ffmpeg
 properly, but mlt did not use it alpha channel.

 i can provide a sample if required...


 alpha been ignored for PIX_FMT_YUVA420P and PIX_FMT_YUVA444P pixel format.
 moreover current implementation of libswscale drop alpha channel if
 destination format has no alpha and not planar (even if buffer specified)

 attached patch extract alpha plane during image decoding. it works almost
 fine except moments when image fetched from cache (even if *noimagecache*
 specified). another problem is artifact that appear if last frame in movie
 is not transparent but producer specifies *out* out of animation.

 another attempt to fix this was to fix mlt_frame_clone (patch attached) but
 it has no luck too...

OK, thank you for the start of this effort. I will look at it this weekend.

-- 
+-DRD-+

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel


Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-15 Thread Maksym Veremeyenko
02.02.12 19:03, Maksym Veremeyenko написав(ла):
 Hi,

 i am trying to decrease cpu usage, so i would like to use
 PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with
 alpha channel) but has no luck..
i think i found where it should be fixed, now its clear why 32bit rgba 
formats not converted in avformat_producer but converted with alpha 
extracting later in convert_image in filter_avcolour_space.c

-- 

Maksym Veremeyenko


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel


[Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-02 Thread Maksym Veremeyenko
Hi,

i am trying to decrease cpu usage, so i would like to use 
PIX_FMT_YUVA420P animation instead of PIX_FMT_BGRA (or other rgb with 
alpha channel) but has no luck..

video with such pixel format in *nut* container has detected by ffmpeg 
properly, but mlt did not use it alpha channel.

i can provide a sample if required...

-- 

Maksym Veremeyenko

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel


Re: [Mlt-devel] no alpha channel for video with PIX_FMT_YUVA420P pixel format

2012-02-02 Thread Dan Dennedy
2012/2/2 Maksym Veremeyenko ve...@m1stereo.tv:
 Hi,

 i am trying to decrease cpu usage, so i would like to use PIX_FMT_YUVA420P
 animation instead of PIX_FMT_BGRA (or other rgb with alpha channel) but has
 no luck..

producer_avformat.c only retain the alpha components of yuva420p.

 video with such pixel format in *nut* container has detected by ffmpeg
 properly, but mlt did not use it alpha channel.

 i can provide a sample if required...

You can ftp it to mltframework.org. It is anonymous write-only; you
cannot list it so most GUI FTP clients fail. Just let me know the
name.

-- 
+-DRD-+

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel