/*
* producer_avformat.c -- avformat producer
- * Copyright (C) 2003-2012 Ushodaya Enterprises Limited
+ * Copyright (C) 2003-2014 Ushodaya Enterprises Limited
* Author: Charles Yates <charles.yates@pandora.be>
* Author: Dan Dennedy <dan@dennedy.org>
* Much code borrowed from ffmpeg.c: Copyright (c) 2000-2003 Fabrice Bellard
width, height, PIX_FMT_RGB24, flags | SWS_FULL_CHR_H_INT, NULL, NULL, NULL);
AVPicture output;
avpicture_fill( &output, buffer, PIX_FMT_RGB24, width, height );
- set_luma_transfer( context, self->yuv_colorspace, profile->colorspace, self->full_luma );
+ // libswscale wants the RGB colorspace to be SWS_CS_DEFAULT, which is = SWS_CS_ITU601.
+ set_luma_transfer( context, self->yuv_colorspace, 601, self->full_luma );
sws_scale( context, (const uint8_t* const*) frame->data, frame->linesize, 0, height,
output.data, output.linesize);
sws_freeContext( context );
width, height, PIX_FMT_RGBA, flags | SWS_FULL_CHR_H_INT, NULL, NULL, NULL);
AVPicture output;
avpicture_fill( &output, buffer, PIX_FMT_RGBA, width, height );
- set_luma_transfer( context, self->yuv_colorspace, profile->colorspace, self->full_luma );
+ // libswscale wants the RGB colorspace to be SWS_CS_DEFAULT, which is = SWS_CS_ITU601.
+ set_luma_transfer( context, self->yuv_colorspace, 601, self->full_luma );
sws_scale( context, (const uint8_t* const*) frame->data, frame->linesize, 0, height,
output.data, output.linesize);
sws_freeContext( context );
// Duplicate it
if ( ( image_size = allocate_buffer( frame, codec_context, buffer, format, width, height ) ) )
{
+ int yuv_colorspace;
// Workaround 1088 encodings missing cropping info.
if ( *height == 1088 && mlt_profile_dar( mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) ) ) == 16.0/9.0 )
*height = 1080;
picture.linesize[0] = codec_context->width;
picture.linesize[1] = codec_context->width / 2;
picture.linesize[2] = codec_context->width / 2;
- int yuv_colorspace = convert_image( self, (AVFrame*) &picture, *buffer,
+ yuv_colorspace = convert_image( self, (AVFrame*) &picture, *buffer,
PIX_FMT_YUV420P, format, *width, *height, &alpha );
- mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
}
else
#endif
- int yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
+ yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
format, *width, *height, &alpha );
mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
got_picture = 1;
{
if ( ( image_size = allocate_buffer( frame, codec_context, buffer, format, width, height ) ) )
{
+ int yuv_colorspace;
// Workaround 1088 encodings missing cropping info.
if ( *height == 1088 && mlt_profile_dar( mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) ) ) == 16.0/9.0 )
*height = 1080;
VdpStatus status = vdp_surface_get_bits( render->surface, dest_format, planes, pitches );
if ( status == VDP_STATUS_OK )
{
- int yuv_colorspace = convert_image( self, self->video_frame, *buffer, PIX_FMT_YUV420P,
+ yuv_colorspace = convert_image( self, self->video_frame, *buffer, PIX_FMT_YUV420P,
format, *width, *height, &alpha );
mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
}
}
else
#endif
- int yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
+ yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
format, *width, *height, &alpha );
mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
self->top_field_first |= self->video_frame->top_field_first;
// Duplicate it
if ( ( image_size = allocate_buffer( frame, codec_context, buffer, format, width, height ) ) )
{
+ int yuv_colorspace;
// Workaround 1088 encodings missing cropping info.
if ( *height == 1088 && mlt_profile_dar( mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) ) ) == 16.0/9.0 )
*height = 1080;
picture.linesize[0] = codec_context->width;
picture.linesize[1] = codec_context->width / 2;
picture.linesize[2] = codec_context->width / 2;
- int yuv_colorspace = convert_image( self, (AVFrame*) &picture, *buffer,
+ yuv_colorspace = convert_image( self, (AVFrame*) &picture, *buffer,
PIX_FMT_YUV420P, format, *width, *height, &alpha );
mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
}
else
#endif
- int yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
+ yuv_colorspace = convert_image( self, self->video_frame, *buffer, codec_context->pix_fmt,
format, *width, *height, &alpha );
mlt_properties_set_int( frame_properties, "colorspace", yuv_colorspace );
got_picture = 1;
#endif
double fps = av_q2d( frame_rate );
-#if LIBAVFORMAT_VERSION_MAJOR < 55
+#if LIBAVFORMAT_VERSION_MAJOR < 55 || defined(FFUDIV)
// Verify and sanitize the muxer frame rate.
if ( isnan( fps ) || isinf( fps ) || fps == 0 )
{
fps = av_q2d( frame_rate );
}
#endif
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(42<<8)+0) && LIBAVFORMAT_VERSION_MAJOR < 55
+#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(42<<8)+0) && ( LIBAVFORMAT_VERSION_MAJOR < 55 || defined(FFUDIV) )
// With my samples when r_frame_rate != 1000 but avg_frame_rate is valid,
// avg_frame_rate gives some approximate value that does not well match the media.
// Also, on my sample where r_frame_rate = 1000, using avg_frame_rate directly
}
// Update the video properties if the index changed
- if ( index != self->video_index )
+ if ( context && index > -1 && index != self->video_index )
{
// Reset the video properties if the index changed
self->video_index = index;