[FFmpeg-cvslog] lavc/videotoolboxenc: Support pixel aspect ratio
Rick Kern
git at videolan.org
Wed May 4 18:41:29 CEST 2016
ffmpeg | branch: master | Rick Kern <kernrj at gmail.com> | Wed Apr 27 10:53:14 2016 -0400| [c356b6865d373642685a6b445341ebb37ecbcc91] | committer: wm4
lavc/videotoolboxenc: Support pixel aspect ratio
Signed-off-by: Rick Kern <kernrj at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c356b6865d373642685a6b445341ebb37ecbcc91
---
libavcodec/videotoolboxenc.c | 63 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 5f02756..4a40f35 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -748,6 +748,69 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
}
}
+ if (avctx->sample_aspect_ratio.num != 0) {
+ CFNumberRef num;
+ CFNumberRef den;
+ CFMutableDictionaryRef par;
+ AVRational *avpar = &avctx->sample_aspect_ratio;
+
+ av_reduce(&avpar->num, &avpar->den,
+ avpar->num, avpar->den,
+ 0xFFFFFFFF);
+
+ num = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberIntType,
+ &avpar->num);
+
+ den = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberIntType,
+ &avpar->den);
+
+
+
+ par = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 2,
+ &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,
More information about the ffmpeg-cvslog
mailing list