From: lilo_booter Date: Fri, 23 Sep 2005 06:13:58 +0000 (+0000) Subject: filter_avcolour_space.c X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=78cb03b80c9483db3f3c6bb44eb420da69ca60c0;p=melted filter_avcolour_space.c + Correction for uneven width filter_avdeinterlace.c + Correction for cases were the interlace state of frame is only known after rendering producer_avformat.c + Corrections for uneven width + Corrections for state propogation of top field first and interlaced state git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@827 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/modules/avformat/filter_avcolour_space.c b/src/modules/avformat/filter_avcolour_space.c index 4a53e94..50eb2ce 100644 --- a/src/modules/avformat/filter_avcolour_space.c +++ b/src/modules/avformat/filter_avcolour_space.c @@ -57,57 +57,11 @@ static inline int convert_mlt_to_av_cs( mlt_image_format format ) static inline void convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt, int width, int height ) { - if ( in_fmt == PIX_FMT_YUV420P && out_fmt == PIX_FMT_YUV422 ) - { - register int i, j; - register int half = width >> 1; - register uint8_t *Y = in; - register uint8_t *U = Y + width * height; - register uint8_t *V = U + width * height / 2; - register uint8_t *d = out; - register uint8_t *y, *u, *v; - - i = height >> 1; - while ( i -- ) - { - y = Y; - u = U; - v = V; - j = half; - while ( j -- ) - { - *d ++ = *y ++; - *d ++ = *u ++; - *d ++ = *y ++; - *d ++ = *v ++; - } - - Y += width; - y = Y; - u = U; - v = V; - j = half; - while ( j -- ) - { - *d ++ = *y ++; - *d ++ = *u ++; - *d ++ = *y ++; - *d ++ = *v ++; - } - - Y += width; - U += width / 2; - V += width / 2; - } - } - else - { - AVPicture input; - AVPicture output; - avpicture_fill( &output, out, out_fmt, width, height ); - avpicture_fill( &input, in, in_fmt, width, height ); - img_convert( &output, out_fmt, &input, in_fmt, width, height ); - } + AVPicture input; + AVPicture output; + avpicture_fill( &output, out, out_fmt, width, height ); + avpicture_fill( &input, in, in_fmt, width, height ); + img_convert( &output, out_fmt, &input, in_fmt, width, height ); } /** Do it :-). diff --git a/src/modules/avformat/filter_avdeinterlace.c b/src/modules/avformat/filter_avdeinterlace.c index 84f9cb9..b071f6e 100644 --- a/src/modules/avformat/filter_avdeinterlace.c +++ b/src/modules/avformat/filter_avdeinterlace.c @@ -304,7 +304,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * error = mlt_frame_get_image( this, image, format, width, height, writable ); // Check that we want progressive and we aren't already progressive - if ( deinterlace && *format == mlt_image_yuv422 && *image != NULL ) + if ( deinterlace && *format == mlt_image_yuv422 && *image != NULL && !mlt_properties_get_int( MLT_FRAME_PROPERTIES( this ), "progressive" ) ) { // Create a picture AVPicture *output = mlt_pool_alloc( sizeof( AVPicture ) ); diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index b589468..8cbdad4 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -344,51 +344,7 @@ static double producer_time_of_frame( mlt_producer this, mlt_position position ) static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt, mlt_image_format format, int width, int height ) { - // EXPERIMENTAL IMAGE NORMALISATIONS - if ( pix_fmt == PIX_FMT_YUV420P && format == mlt_image_yuv422 ) - { - register int i, j; - register int half = width >> 1; - register uint8_t *Y = ( ( AVPicture * )frame )->data[ 0 ]; - register uint8_t *U = ( ( AVPicture * )frame )->data[ 1 ]; - register uint8_t *V = ( ( AVPicture * )frame )->data[ 2 ]; - register uint8_t *d = buffer; - register uint8_t *y, *u, *v; - - i = height >> 1; - while ( i -- ) - { - y = Y; - u = U; - v = V; - j = half; - while ( j -- ) - { - *d ++ = *y ++; - *d ++ = *u ++; - *d ++ = *y ++; - *d ++ = *v ++; - } - - Y += ( ( AVPicture * )frame )->linesize[ 0 ]; - y = Y; - u = U; - v = V; - j = half; - while ( j -- ) - { - *d ++ = *y ++; - *d ++ = *u ++; - *d ++ = *y ++; - *d ++ = *v ++; - } - - Y += ( ( AVPicture * )frame )->linesize[ 0 ]; - U += ( ( AVPicture * )frame )->linesize[ 1 ]; - V += ( ( AVPicture * )frame )->linesize[ 2 ]; - } - } - else if ( format == mlt_image_yuv420p ) + if ( format == mlt_image_yuv420p ) { AVPicture pict; pict.data[0] = buffer; @@ -589,7 +545,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form { got_picture = 0; } - mlt_properties_set_int( properties, "top_field_first", av_frame->top_field_first ); } } @@ -600,6 +555,9 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Now handle the picture if we have one if ( got_picture ) { + mlt_properties_set_int( frame_properties, "progressive", !av_frame->interlaced_frame ); + mlt_properties_set_int( frame_properties, "top_field_first", av_frame->top_field_first ); + convert_image( av_frame, *buffer, codec_context->pix_fmt, *format, *width, *height ); mlt_properties_set_data( frame_properties, "image", *buffer, size, (mlt_destructor)mlt_pool_release, NULL );