Signed-off-by: Rick Kern <ker...@gmail.com> --- libavcodec/videotoolboxenc.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 0a79ee0..72743b5 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -765,6 +765,60 @@ static av_cold int vtenc_init(AVCodecContext *avctx) } } + if (avctx->sample_aspect_ratio.num != 0) { + CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, + kCFNumberIntType, + &avctx->sample_aspect_ratio.num); + + CFNumberRef den = CFNumberCreate(kCFAllocatorDefault, + kCFNumberIntType, + &avctx->sample_aspect_ratio.den); + + CFMutableDictionaryRef par = CFDictionaryCreateMutable( + kCFAllocatorDefault, + 20, + &kCFCopyStringDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + if (!par || !num || !den) { + if (par) CFRelease(par); + if (num) CFRelease(num); + if (den) CFRelease(den); + + return AVERROR(ENOMEM); + } + + CFDictionarySetValue( + par, + kCMFormatDescriptionKey_PixelAspectRatioHorizontalSpacing, + num); + + CFDictionarySetValue( + par, + kCMFormatDescriptionKey_PixelAspectRatioVerticalSpacing, + den); + + status = VTSessionSetProperty(vtctx->session, + kVTCompressionPropertyKey_PixelAspectRatio, + par); + + CFRelease(par); + CFRelease(num); + CFRelease(den); + + if (status) { + av_log( + avctx, + AV_LOG_ERROR, + "Error setting pixel aspect ratio to %d:%d: %d.\n", + avctx->sample_aspect_ratio.num, + avctx->sample_aspect_ratio.den, + status); + + return AVERROR_EXTERNAL; + } + } + if (!vtctx->has_b_frames) { status = VTSessionSetProperty(vtctx->session, kVTCompressionPropertyKey_AllowFrameReordering, -- 2.7.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel